diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index 5ebbba3d3..00913caa4 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -182,18 +182,6 @@ class Controller extends Section { this.itemTypes = res.data); } - /** - * Search by item id filter - * @param {object} event - */ - onSearchById(event) { - const value = this.$.itemId.value; - if (event.key === 'Enter' && value) { - this.itemId = value; - this.$.itemId.value = null; - } - } - /** * Search by tag value * @param {object} event @@ -238,20 +226,12 @@ class Controller extends Section { if (this.typeId) newFilter.typeFk = this.typeId; - /* if (this.itemId) - newFilter = {'i.id': this.itemId}; - - if (this.itemName) - newFilter = {'i.name': {like: `%${this.itemName}%`}}; */ - newParams = { orderFk: this.$params.id, orderBy: this.getOrderBy(), tags: this.tags, }; - console.log(newFilter); - return model.applyFilter({where: newFilter}, newParams); } diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index 86fb7c179..9a9742f7f 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -115,30 +115,6 @@ describe('Order', () => { }); }); - describe('itemId() setter', () => { - it(`should set itemId property and then call updateStateParams() and applyFilters() methods`, () => { - jest.spyOn(controller, 'updateStateParams'); - jest.spyOn(controller, 'applyFilters'); - - controller.itemId = 1; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - }); - - describe('itemName() setter', () => { - it(`should set itemName property and then call updateStateParams() and applyFilters() methods`, () => { - jest.spyOn(controller, 'updateStateParams'); - jest.spyOn(controller, 'applyFilters'); - - controller.itemName = 'Bow'; - - expect(controller.updateStateParams).toHaveBeenCalledWith(); - expect(controller.applyFilters).toHaveBeenCalledWith(); - }); - }); - describe('tags() setter', () => { it(`should set tags property and then call updateStateParams() and applyFilters() methods`, () => { jest.spyOn(controller, 'updateStateParams'); @@ -173,23 +149,27 @@ describe('Order', () => { }); }); - describe('onSearchById()', () => { - it(`should not filter by id if the event key code doesn't equals to 'Enter'`, () => { + describe('onSearch()', () => { + it(`should apply a filter by item id an then call the applyFilters method`, () => { jest.spyOn(controller, 'applyFilters'); - controller.$.itemId.value = 1; - controller.onSearchById({key: 'Tab'}); + const itemId = 1; + controller.onSearch({search: itemId}); - expect(controller.applyFilters).not.toHaveBeenCalledWith(); + expect(controller.applyFilters).toHaveBeenCalledWith({ + 'i.id': itemId + }); }); - it(`should filter by id if the event key code equals to 'Enter' an then call applyFilters()`, () => { + it(`should apply a filter by item name an then call the applyFilters method`, () => { jest.spyOn(controller, 'applyFilters'); - controller.$.itemId.value = 1; - controller.onSearchById({key: 'Enter'}); + const itemName = 'Bow'; + controller.onSearch({search: itemName}); - expect(controller.applyFilters).toHaveBeenCalledWith(); + expect(controller.applyFilters).toHaveBeenCalledWith({ + 'i.name': {like: `%${itemName}%`} + }); }); }); @@ -239,7 +219,6 @@ describe('Order', () => { controller._categoryId = 2; controller._typeId = 4; - controller._itemId = 1; controller._tags = [ {tagFk: 11, value: 'Precission', tagSelection: {name: 'Category'}} ]; @@ -247,7 +226,7 @@ describe('Order', () => { value: 'Precission', tagFk: 11, tagSelection: {name: 'Category'}} ]); - let result = {categoryId: 2, typeId: 4, itemId: 1, tags: tags}; + let result = {categoryId: 2, typeId: 4, tags: tags}; controller.updateStateParams(); expect(controller.$state.go).toHaveBeenCalledWith('my.current.state', result);