From 4b027f015d5ce55d94ad09219989328c0bf88215 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 15 Feb 2019 15:23:39 +0100 Subject: [PATCH 1/6] Pull request: test 1 --- front/salix/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/front/salix/index.js b/front/salix/index.js index 6788bae07..269fba65d 100644 --- a/front/salix/index.js +++ b/front/salix/index.js @@ -2,3 +2,5 @@ import './module'; import './routes'; import './components'; import './styles'; + +// XXX: Pull request: Test 1 From 42e3fede236da95cd7889887fa2ffd79f5d81f57 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 15 Feb 2019 17:33:03 +0100 Subject: [PATCH 2/6] fixed ng-repeat transition --- front/salix/styles/effects.scss | 6 ++++++ modules/item/front/index/style.scss | 3 ++- modules/order/front/line/style.scss | 3 ++- modules/ticket/front/sale/style.scss | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/front/salix/styles/effects.scss b/front/salix/styles/effects.scss index 9763967c4..948b94dba 100644 --- a/front/salix/styles/effects.scss +++ b/front/salix/styles/effects.scss @@ -22,4 +22,10 @@ %active { background-color: $color-active; color: $color-active-font; +} + +// Disable ng-repeat effects +.ng-enter, .ng-leave { + -webkit-transition: none !important; + transition: none !important } \ No newline at end of file diff --git a/modules/item/front/index/style.scss b/modules/item/front/index/style.scss index a349e1f8e..1cbc88124 100644 --- a/modules/item/front/index/style.scss +++ b/modules/item/front/index/style.scss @@ -29,6 +29,7 @@ vn-item-product { vn-table { img { border-radius: 50%; - max-width: 50px; + width: 50px; + height: 50px; } } \ No newline at end of file diff --git a/modules/order/front/line/style.scss b/modules/order/front/line/style.scss index 0487a360e..31a13d592 100644 --- a/modules/order/front/line/style.scss +++ b/modules/order/front/line/style.scss @@ -2,7 +2,8 @@ vn-order-line{ vn-table { img { border-radius: 50%; - max-width: 50px; + width: 50px; + height: 50px; } } } \ No newline at end of file diff --git a/modules/ticket/front/sale/style.scss b/modules/ticket/front/sale/style.scss index a0d6d24a8..91d793290 100644 --- a/modules/ticket/front/sale/style.scss +++ b/modules/ticket/front/sale/style.scss @@ -83,7 +83,8 @@ vn-ticket-sale { vn-table { img { border-radius: 50%; - max-width: 50px; + width: 50px; + height: 50px; } } .taxes { From 3a560446347df6206252a2ca745f3a3038927bca Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sun, 17 Feb 2019 18:35:29 +0100 Subject: [PATCH 3/6] Jenkinsfile fixes --- Jenkinsfile | 26 +++++++++++++------------- front/salix/index.js | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9ae65863d..450861086 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,9 +28,6 @@ pipeline { case 'test': env.PORT = 5001 break - case 'test': - env.PORT = 5000 - break } switch (env.BRANCH_NAME) { case 'master': @@ -39,7 +36,7 @@ pipeline { case 'test': env.NODE_ENV = 'test' break - case 'dev': + default: env.NODE_ENV = 'development' break } @@ -59,9 +56,10 @@ pipeline { } } stage('Test') { - when { - branch 'dev' - } + when { not { anyOf { + branch 'test' + branch 'master' + }}} environment { NODE_ENV = "" FIREFOX_BIN = "/opt/firefox/firefox-bin" @@ -75,9 +73,10 @@ pipeline { } } stage('Build') { - when { - not { branch 'dev' } - } + when { anyOf { + branch 'test' + branch 'master' + }} environment { CREDS = credentials('docker-registry') } @@ -92,9 +91,10 @@ pipeline { } } stage('Deploy') { - when { - not { branch 'dev' } - } + when { anyOf { + branch 'test' + branch 'master' + }} environment { DOCKER_TLS_VERIFY = 1 } diff --git a/front/salix/index.js b/front/salix/index.js index 269fba65d..67e4505a4 100644 --- a/front/salix/index.js +++ b/front/salix/index.js @@ -3,4 +3,4 @@ import './routes'; import './components'; import './styles'; -// XXX: Pull request: Test 1 +// XXX: Pull request: Test 2 From 51a701c7f414f6df87ea2f28dc46461b17d1868d Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sun, 17 Feb 2019 19:29:02 +0100 Subject: [PATCH 4/6] Jenkins file fixes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 450861086..612bf4bb4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,7 +135,7 @@ pipeline { post { always { script { - if (env.BRANCH_NAME == 'dev') { + if (!['master', 'test'].contains(env.BRANCH_NAME) { try { junit '*/junitresults.xml' junit 'junitresults.xml' From 98a62bed2dc506defad19c3b4acf28650f6867f4 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sun, 17 Feb 2019 19:30:35 +0100 Subject: [PATCH 5/6] Jenkinsfile fixes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 612bf4bb4..0235a79e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,7 +135,7 @@ pipeline { post { always { script { - if (!['master', 'test'].contains(env.BRANCH_NAME) { + if (!['master', 'test'].contains(env.BRANCH_NAME)) { try { junit '*/junitresults.xml' junit 'junitresults.xml' From 3b0d00332250a7a553979e3629bbdc95808aa4e7 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 18 Feb 2019 08:37:26 +0100 Subject: [PATCH 6/6] treeview refactor & zone #1140 --- front/core/components/check/check.html | 2 +- front/core/components/check/style.scss | 11 +- front/core/components/treeview/child.html | 32 ++-- front/core/components/treeview/child.js | 4 +- front/core/components/treeview/index.js | 112 +++----------- front/core/components/treeview/style.scss | 48 ++++-- .../agency/back/methods/zone-geo/getLeaves.js | 146 +++++++++++------- .../methods/zone-included/toggleIsIncluded.js | 40 ++--- modules/agency/front/calendar/index.js | 2 +- modules/agency/front/location/index.html | 4 +- modules/agency/front/location/index.js | 7 +- 11 files changed, 190 insertions(+), 218 deletions(-) diff --git a/front/core/components/check/check.html b/front/core/components/check/check.html index c2d16005a..0df887f9b 100644 --- a/front/core/components/check/check.html +++ b/front/core/components/check/check.html @@ -1,5 +1,5 @@ .mdl-checkbox { - width: initial; - } & > i { padding-left: 5px; position: absolute; - bottom: 3px; color: $color-font-secondary; - font-size: 20px !important + font-size: 20px !important; + cursor: help + } + + md-checkbox.md-checked .md-icon { + background-color: $color-main; } } diff --git a/front/core/components/treeview/child.html b/front/core/components/treeview/child.html index af5fe128b..8589790ec 100644 --- a/front/core/components/treeview/child.html +++ b/front/core/components/treeview/child.html @@ -1,24 +1,24 @@
    -
  • +
  • - - - + - - - - - - {{::item.name}} - - - +
    + + + {{::item.name}} +
  • diff --git a/front/core/components/treeview/child.js b/front/core/components/treeview/child.js index 5144a829e..b5bdb67e5 100644 --- a/front/core/components/treeview/child.js +++ b/front/core/components/treeview/child.js @@ -10,8 +10,8 @@ class Controller extends Component { this.treeview.onToggle(item); } - select(item) { - this.treeview.onSelection(item); + select(item, value) { + this.treeview.onSelection(item, value); } } diff --git a/front/core/components/treeview/index.js b/front/core/components/treeview/index.js index e732d4347..f73bf3e38 100644 --- a/front/core/components/treeview/index.js +++ b/front/core/components/treeview/index.js @@ -20,72 +20,10 @@ export default class Treeview extends Component { refresh() { this.model.refresh().then(() => { this.data = this.model.data; - console.log(this.data); - this.repaintAll(); }); } - repaintAll() { - let oldData = this.data; - oldData.forEach(node => { - this.repaintAsc(node); - this.repaintDesc(node); - }); - } - - repaintNode(node) { - this.repaintAsc(node); - this.repaintDesc(node); - } - - repaintAsc(node) { - if (!node.parent) return; - - const parent = node.parent; - if ((node.selected || node.included) && !parent.selected) { - parent.included = true; - parent.hasCheckedChilds = true; - } else if (!this.hasCheckedChilds(parent) && !this.hasCheckedParents(node)) - parent.included = false; - - // FIXME - Propagate hasCheckedCHilds - if (!node.selected && this.hasCheckedParents(node)) { - node.included = true; - parent.hasCheckedChilds = false; - } - - if (!this.hasCheckedChilds(node)) - node.hasCheckedChilds = false; - - this.repaintAsc(parent); - } - - repaintDesc(node) { - /* if (node.hasCheckedChilds) - node.included = false; */ - - if (!node.selected && this.hasCheckedChilds(node)) { - node.hasCheckedChilds = true; - node.included = true; - } else if (!node.selected && node.childs && !this.hasCheckedChilds(node)) - node.hasCheckedChilds = false; - - - const childs = node.childs || []; - for (let i = 0; i < childs.length; i++) { - childs[i].included = false; - - if (((node.selected || node.included && this.hasCheckedParents(childs[i])) && !childs[i].selected) && !node.excluded) - childs[i].included = true; - - this.repaintDesc(childs[i]); - } - - if (!node.selected && node.hasCheckedChilds) - node.included = true; - } - - hasCheckedChilds(node) { + /* hasCheckedChilds(node) { if (!node.childs) return false; const childs = node.childs; @@ -105,44 +43,34 @@ export default class Treeview extends Component { return true; return false; - } + } */ - onSelection(item) { - let canBeExcluded = this.hasCheckedChilds(item) || this.hasCheckedParents(item); - - if (!item.selected && item.included && canBeExcluded) - item.excluded = true; - else - item.excluded = false; - - item.selected = !item.selected; - - if (item.selected && item.included) - item.included = false; - - if (this.hasCheckedChilds(item)) - item.hasCheckedChilds = true; - else if (this.childs) - item.hasCheckedChilds = false; - - this.emit('selection', {item}); + onSelection(item, value) { + this.emit('selection', {item, value}); } onToggle(item) { - if (item.childs && item.childs.length == 0) - return; - - if (item.childs) + if (item.active) item.childs = undefined; else { this.model.applyFilter({}, {parentFk: item.id}).then(() => { - item.childs = this.model.data; - item.childs.forEach(child => { - child.parent = item; - }); - this.repaintNode(item); + const newData = this.model.data; + + if (item.childs) { + let childs = item.childs; + childs.forEach(child => { + let index = newData.findIndex(newChild => { + return newChild.id == child.id; + }); + newData[index] = child; + }); + } + + item.childs = newData.sort((a, b) => b.isIncluded - a.isIncluded); }); } + + item.active = !item.active; } } diff --git a/front/core/components/treeview/style.scss b/front/core/components/treeview/style.scss index cf2885e8e..40f35a1e2 100644 --- a/front/core/components/treeview/style.scss +++ b/front/core/components/treeview/style.scss @@ -2,19 +2,21 @@ vn-treeview { ul { - margin: 0; + line-height: 24px; padding: 0; + margin: 0; + li { list-style: none; cursor: pointer; .actions { - padding: 0.5em; + min-width: 24px; } .description { - padding: 0.5em + padding-left: 5px } } @@ -22,28 +24,42 @@ vn-treeview { padding: 0 1.8em; } + li > vn-horizontal { + padding: 5px + } + li > vn-horizontal:hover { background-color: $color-hover-cd } - li.selected > vn-horizontal > .description .text, - li.included > vn-horizontal > .description .text { - font-weight: bold; - color: $color-main; + li.expanded .actions > vn-icon[icon="keyboard_arrow_down"] { + transition: all 0.2s; + transform: rotate(180deg); + } + + li.collapsed .actions > vn-icon[icon="keyboard_arrow_down"] { + transition: all 0.2s; + transform: rotate(0deg); } li.included { - & > vn-horizontal > .description > vn-horizontal > vn-check { - .mdl-checkbox .mdl-checkbox__box-outline, { - border: 2px solid $color-main-medium; - } - fieldset[disabled] .mdl-checkbox .mdl-checkbox__box-outline, .mdl-checkbox.is-disabled .mdl-checkbox__box-outline { - border: 2px solid rgba(0,0,0,.26); - } - .mdl-checkbox .mdl-checkbox__tick-outline { - background: $color-main-medium; + & > vn-horizontal > .description { + color: $color-notice; + font-weight: bold; + + & > vn-check .md-icon { + background-color: $color-notice } } + + } + + li.excluded { + & > vn-horizontal > .description { + color: $color-alert; + font-weight: bold; + + } } } } diff --git a/modules/agency/back/methods/zone-geo/getLeaves.js b/modules/agency/back/methods/zone-geo/getLeaves.js index c0496f765..9f819e83a 100644 --- a/modules/agency/back/methods/zone-geo/getLeaves.js +++ b/modules/agency/back/methods/zone-geo/getLeaves.js @@ -6,12 +6,6 @@ module.exports = Self => { description: 'Returns the first shipped and landed possible for params', accessType: '', accepts: [{ - arg: 'filter', - type: 'Object', - description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - http: {source: 'query'} - }, - { arg: 'zoneFk', type: 'Number', required: true, @@ -21,6 +15,12 @@ module.exports = Self => { type: 'Number', default: 1, required: false, + }, + { + arg: 'filter', + type: 'Object', + description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', + http: {source: 'query'} }], returns: { type: ['object'], @@ -32,64 +32,106 @@ module.exports = Self => { } }); - Self.getLeaves = async(filter, zoneFk, parentFk = 1) => { + Self.getLeaves = async(zoneFk, parentFk = 1, filter) => { let conn = Self.dataSource.connector; let stmts = []; + let geo = await Self.findById(parentFk); + + stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.checkedChilds`); stmts.push(new ParameterizedSQL( - `SELECT lft, rgt, depth + 1 INTO @lft, @rgt, @depth - FROM zoneGeo WHERE id = ?`, [parentFk])); + `CREATE TEMPORARY TABLE tmp.checkedChilds ( + id INT, + name VARCHAR(100), + lft INT, + rgt INT, + depth BIGINT(22), + sons DECIMAL(10, 0), + isIncluded TINYINT + ) ENGINE = MEMORY`)); - stmts.push(`DROP TEMPORARY TABLE IF EXISTS tChilds`); - - let stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tChilds - ENGINE = MEMORY - SELECT id, lft, rgt - FROM zoneGeo pt`); - stmt.merge(conn.makeSuffix(filter)); - - if (!filter.where) { - stmt.merge(`WHERE pt.lft > @lft AND pt.rgt < @rgt - AND pt.depth = @depth`); + if (parentFk === 1) { + stmts.push(new ParameterizedSQL( + `INSERT INTO tmp.checkedChilds + SELECT + zg.id, + zg.name, + zg.lft, + zg.rgt, + zg.depth, + zg.sons, + zi.isIncluded + FROM zoneGeo zg + JOIN zoneIncluded zi ON zi.geoFk = zg.id + AND zoneFk = ?`, [zoneFk])); } - stmts.push(stmt); + let stmt = new ParameterizedSQL( + `SELECT * FROM ( + SELECT + zg.id, + zg.name, + zg.lft, + zg.rgt, + zg.depth, + zg.sons, + IF(ch.id = zg.id, isIncluded, null) isIncluded + FROM zoneGeo zg + JOIN tmp.checkedChilds ch ON zg.lft <= ch.lft AND zg.rgt >= ch.rgt + UNION ALL + SELECT + child.id, + child.name, + child.lft, + child.rgt, + child.depth, + child.sons, + zi.isIncluded + FROM zoneGeo parent + JOIN zoneGeo child ON child.lft > parent.lft + AND child.rgt < parent.rgt + AND child.depth = parent.depth + 1 + LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id + AND zoneFk = ? + WHERE parent.id = ?) AS nst`, [zoneFk, parentFk]); - stmts.push(`DROP TEMPORARY TABLE IF EXISTS tZones`); - stmts.push(new ParameterizedSQL( - `CREATE TEMPORARY TABLE tZones - (INDEX (id)) - ENGINE = MEMORY - SELECT t.id - FROM tChilds t - JOIN zoneGeo zt - ON zt.lft > t.lft AND zt.rgt < t.rgt - JOIN zoneIncluded zi - ON zi.geoFk = zt.id AND zi.zoneFk = ? - GROUP BY t.id`, [zoneFk])); + // Get nodes from depth greather than Origin + stmt.merge(conn.makeSuffix(filter)); + stmt.merge('GROUP BY nst.id'); - const resultIndex = stmts.push(new ParameterizedSQL( - `SELECT - pt.id, - pt.name, - pt.lft, - pt.rgt, - pt.depth, - pt.sons, - ti.id IS NOT NULL hasCheckedChilds, - zi.geoFk IS NOT NULL AS selected, - zi.isIncluded AS excluded - FROM zoneGeo pt - LEFT JOIN vn.zoneIncluded zi - ON zi.geoFk = pt.id AND zi.zoneFk = ? - JOIN tChilds c ON c.id = pt.id - LEFT JOIN tZones ti ON ti.id = pt.id - ORDER BY selected DESC, name`, [zoneFk])) - 1; + const resultIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await Self.rawStmt(sql); + const nodes = result[resultIndex]; - return result[resultIndex]; + // Get parent nodes + const parentNodes = nodes.filter(element => { + return element.depth === geo.depth + 1; + }); + + const sortedLeaves = parentNodes.sort((a, b) => b.isIncluded - a.isIncluded); + const leaves = Object.assign([], sortedLeaves); + + nestLeaves(leaves); + + function nestLeaves(elements) { + elements.forEach(element => { + element.childs = Object.assign([], getLeaves(element)); + + nestLeaves(element.childs); + }); + } + + function getLeaves(parent) { + let elements = nodes.filter(element => { + return element.lft > parent.lft && element.rgt < parent.rgt + && element.depth === parent.depth + 1; + }); + + return elements; + } + + return leaves; }; }; diff --git a/modules/agency/back/methods/zone-included/toggleIsIncluded.js b/modules/agency/back/methods/zone-included/toggleIsIncluded.js index f93df8b35..0b15a7171 100644 --- a/modules/agency/back/methods/zone-included/toggleIsIncluded.js +++ b/modules/agency/back/methods/zone-included/toggleIsIncluded.js @@ -8,8 +8,8 @@ module.exports = Self => { required: true, }, { - arg: 'geoFk', - type: 'Number', + arg: 'item', + type: 'Object', required: true, }], returns: { @@ -22,31 +22,15 @@ module.exports = Self => { } }); - Self.toggleIsIncluded = async(zoneFk, geoFk) => { - const models = Self.app.models; - const geo = await models.ZoneGeo.findById(geoFk); - const isIncluded = await Self.findOne({ - where: {zoneFk, geoFk} - }); - - const hasCheckedParents = await Self.rawSql( - `SELECT id - FROM vn.zoneGeo zt - JOIN vn.zoneIncluded zi ON zi.geoFk = zt.id - WHERE zt.lft < ? AND zt.rgt > ?`, [geo.lft, geo.rgt] - ); - const hasCheckedChilds = await Self.rawSql( - `SELECT id - FROM vn.zoneGeo zt - JOIN vn.zoneIncluded zi ON zi.geoFk = zt.id - WHERE zt.lft > ? AND zt.rgt < ?`, [geo.lft, geo.rgt] - ); - - const isExcluded = hasCheckedParents.length || hasCheckedChilds.length; - - if (isIncluded) - return Self.destroyAll({zoneFk, geoFk}); - else - return Self.upsert({zoneFk, geoFk, isIncluded: isExcluded}); + Self.toggleIsIncluded = async(zoneFk, item) => { + if (item.isIncluded === null) + return Self.destroyAll({zoneFk, geoFk: item.id}); + else { + return Self.upsert({ + zoneFk: zoneFk, + geoFk: item.id, + isIncluded: item.isIncluded + }); + } }; }; diff --git a/modules/agency/front/calendar/index.js b/modules/agency/front/calendar/index.js index f08a47601..81b07dafe 100644 --- a/modules/agency/front/calendar/index.js +++ b/modules/agency/front/calendar/index.js @@ -33,7 +33,7 @@ class Controller { res.data.forEach(holiday => { events.push({ date: holiday.dated, - color: 'blue-circle', + color: 'red', title: holiday.description || holiday.name, isRemovable: false }); diff --git a/modules/agency/front/location/index.html b/modules/agency/front/location/index.html index 27de3bc1f..4482ff52e 100644 --- a/modules/agency/front/location/index.html +++ b/modules/agency/front/location/index.html @@ -2,7 +2,7 @@ vn-id="model" url="/agency/api/ZoneGeos/getLeaves" filter="::$ctrl.filter" - params="{zoneFk: $ctrl.$stateParams.id, parentFk: 1}"> + params="{zoneFk: $ctrl.$stateParams.id}" auto-load="false">
    @@ -13,7 +13,7 @@ vn-focus> + on-selection="$ctrl.onSelection(item, value)"> diff --git a/modules/agency/front/location/index.js b/modules/agency/front/location/index.js index 92e893297..00b0159ec 100644 --- a/modules/agency/front/location/index.js +++ b/modules/agency/front/location/index.js @@ -22,11 +22,12 @@ class Controller { } } - onSelection(item) { + onSelection(item, isIncluded) { + item.isIncluded = isIncluded; const path = '/agency/api/ZoneIncludeds/toggleIsIncluded'; - const params = {geoFk: item.id, zoneFk: this.zone.id}; + const params = {zoneFk: this.zone.id, item}; this.$http.post(path, params).then(() => { - this.$scope.treeview.repaintNode(item); + }); } }