From 720803facb71e59f10e64b2db33e0ac802447d06 Mon Sep 17 00:00:00 2001 From: Gerard Date: Fri, 8 Mar 2019 13:12:13 +0100 Subject: [PATCH] =?UTF-8?q?#1220=20item.index=20a=C3=B1adir=20campos=20a?= =?UTF-8?q?=20buscador=20avanzado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../06_create_item_botanical.spec.js | 2 +- .../08_item_create_and_clone.spec.js | 4 +- modules/item/front/index/index.js | 6 +- modules/item/front/search-panel/index.html | 58 +++++++++++++------ modules/item/front/search-panel/index.js | 26 ++++++++- modules/item/front/search-panel/locale/es.yml | 7 ++- 6 files changed, 78 insertions(+), 25 deletions(-) diff --git a/e2e/paths/item-module/06_create_item_botanical.spec.js b/e2e/paths/item-module/06_create_item_botanical.spec.js index c17a7adc7..fd1e1bf1d 100644 --- a/e2e/paths/item-module/06_create_item_botanical.spec.js +++ b/e2e/paths/item-module/06_create_item_botanical.spec.js @@ -7,7 +7,7 @@ describe('Item Create botanical path', () => { beforeAll(() => { nightmare .loginAndModule('buyer', 'item') - .accessToSearchResult('Object5 Weapon 50') + .accessToSearchResult('Object5 Weapon 50 hasVisible:false') .accessToSection('item.card.botanical'); }); diff --git a/e2e/paths/item-module/08_item_create_and_clone.spec.js b/e2e/paths/item-module/08_item_create_and_clone.spec.js index b5e33cc4a..025c958b7 100644 --- a/e2e/paths/item-module/08_item_create_and_clone.spec.js +++ b/e2e/paths/item-module/08_item_create_and_clone.spec.js @@ -95,7 +95,7 @@ describe('Item Create/Clone path', () => { it(`should search for the item Infinity Gauntlet`, async() => { const result = await nightmare - .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet hasVisible:false') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .countElement(selectors.itemsIndex.searchResult); @@ -117,7 +117,7 @@ describe('Item Create/Clone path', () => { it('should search for the item Infinity Gauntlet and find two', async() => { const result = await nightmare .waitToClick(selectors.itemTags.goToItemIndexButton) - .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .write(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet hasVisible:false') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) .countElement(selectors.itemsIndex.searchResult); diff --git a/modules/item/front/index/index.js b/modules/item/front/index/index.js index d8d0ebbe2..76d966170 100644 --- a/modules/item/front/index/index.js +++ b/modules/item/front/index/index.js @@ -13,9 +13,6 @@ class Controller { id: false, actions: false }; - - if (!$stateParams.q) - this.filter = {hasVisible: true, isActive: true}; } stopEvent(event) { @@ -24,6 +21,9 @@ class Controller { } onSearch(params) { + if (params && params.hasVisible === undefined && params.isActive === undefined) + Object.assign(params, {hasVisible: true, isActive: true}); + if (params) this.$.model.applyFilter(null, params); else diff --git a/modules/item/front/search-panel/index.html b/modules/item/front/search-panel/index.html index fca01dc2a..ba512c1d0 100644 --- a/modules/item/front/search-panel/index.html +++ b/modules/item/front/search-panel/index.html @@ -9,18 +9,6 @@ vn-focus> - - - - - - - - + + + More fields + + + + + + + + + + + + + + diff --git a/modules/item/front/search-panel/index.js b/modules/item/front/search-panel/index.js index 0c98b707a..458382a99 100644 --- a/modules/item/front/search-panel/index.js +++ b/modules/item/front/search-panel/index.js @@ -2,6 +2,21 @@ import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; class Controller extends SearchPanel { + constructor($scope) { + super(); + this.$ = $scope; + this.moreFields = [ + {field: 'id'}, + {field: 'description'}, + {field: 'name'} + ]; + } + + initializeMoreFields() { + if (!this.$.filter.moreFields || !this.$.filter.moreFields.length) + this.$.filter.moreFields = [{}]; + } + set filter(value) { if (!value) value = {}; @@ -20,7 +35,14 @@ class Controller extends SearchPanel { } get filter() { - return this.$.filter; + if (this.$.filter.moreFields) { + this.$.filter.moreFields.forEach(element => { + this.$.filter[element.field] = element.value; + }); + } + let filter = Object.assign({}, this.$.filter); + delete filter.moreFields; + return filter; } getSourceTable(selection) { @@ -36,6 +58,8 @@ class Controller extends SearchPanel { } } +Controller.$inject = ['$scope']; + ngModule.component('vnItemSearchPanel', { template: require('./index.html'), controller: Controller diff --git a/modules/item/front/search-panel/locale/es.yml b/modules/item/front/search-panel/locale/es.yml index 1411cc42d..660991827 100644 --- a/modules/item/front/search-panel/locale/es.yml +++ b/modules/item/front/search-panel/locale/es.yml @@ -1,3 +1,8 @@ Ink: Tinta Origin: Origen -Producer: Productor \ No newline at end of file +Producer: Productor. +With visible: Con visible +Field: Campo +More fields: Mas campos +Add field: AƱadir campo +Remove field: Quitar campo \ No newline at end of file