From 312faeb3b0f6c1bb811ee108f17fb8e6fde9c8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Wed, 16 Sep 2020 09:54:04 +0200 Subject: [PATCH] Changes to lag list --- .../order/back/methods/order/catalogFilter.js | 7 ++- .../front/catalog-search-panel/index.html | 7 ++- .../order/front/catalog-search-panel/index.js | 5 +- modules/order/front/catalog/index.html | 10 ++-- modules/order/front/catalog/index.js | 52 +++++++------------ 5 files changed, 34 insertions(+), 47 deletions(-) diff --git a/modules/order/back/methods/order/catalogFilter.js b/modules/order/back/methods/order/catalogFilter.js index 067610a16..f361b3849 100644 --- a/modules/order/back/methods/order/catalogFilter.js +++ b/modules/order/back/methods/order/catalogFilter.js @@ -164,10 +164,13 @@ module.exports = Self => { // Get tags from all items const itemTagsIndex = stmts.push( `SELECT + t.id, + t.name, + t.isFree, + t.sourceTable, it.tagFk, it.itemFk, - it.value, - t.name + it.value FROM tmp.ticketCalculateItem tci JOIN vn.itemTag it ON it.itemFk = tci.itemFk JOIN vn.tag t ON t.id = it.tagFk`) - 1; diff --git a/modules/order/front/catalog-search-panel/index.html b/modules/order/front/catalog-search-panel/index.html index 19719e00b..81af31ceb 100644 --- a/modules/order/front/catalog-search-panel/index.html +++ b/modules/order/front/catalog-search-panel/index.html @@ -1,4 +1,3 @@ -
@@ -7,7 +6,7 @@ vn-one selection="filter.tagSelection" ng-model="filter.tagFk" - data="tags.model" + data="$ctrl.resultTags" show-field="name" label="Tag" on-change="itemTag.value = null"> @@ -16,14 +15,14 @@ - @@ -100,14 +97,15 @@ style="cursor: pointer;"> - + + popover="popover" + result-tags="$ctrl.resultTags">
diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index f8e38ca3d..dbb9cf8ea 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -68,8 +68,8 @@ class Controller extends Section { if (!value) return; - this.buildTagsFilter(value); - this.buildOrderFilter(value); + this.fetchResultTags(value); + this.buildOrderFilter(); } get categoryId() { @@ -300,43 +300,29 @@ class Controller extends Section { return tagGroups; } - buildTagsFilter(items) { - const tagValues = []; - items.forEach(item => { - item.tags.forEach(itemTag => { - const alreadyAdded = tagValues.findIndex(tag => { - return tag.value == itemTag.value; + fetchResultTags(items) { + const resultTags = []; + for (let item of items) { + for (let itemTag of item.tags) { + const alreadyAdded = resultTags.findIndex(tag => { + return tag.tagFk == itemTag.tagFk; }); if (alreadyAdded == -1) - tagValues.push(itemTag); - }); - }); - this.tagValues = tagValues; + resultTags.push({...itemTag, priority: 1}); + else + resultTags[alreadyAdded].priority += 1; + } + } + this.resultTags = resultTags; } - buildOrderFilter(items) { - const tags = []; - items.forEach(item => { - item.tags.forEach(itemTag => { - const alreadyAdded = tags.findIndex(tag => { - return tag.field == itemTag.tagFk; - }); + buildOrderFilter() { + const filter = [].concat(this.defaultOrderFields); + for (let tag of this.resultTags) + filter.push({...tag, field: tag.id, isTag: true}); - if (alreadyAdded == -1) { - tags.push({ - name: itemTag.name, - field: itemTag.tagFk, - isTag: true, - priority: 1 - }); - } else - tags[alreadyAdded].priority += 1; - }); - }); - let newFilterList = [].concat(this.defaultOrderFields); - newFilterList = newFilterList.concat(tags); - this.orderFields = newFilterList; + this.orderFields = filter; } onSearch(params) {