diff --git a/client/client/src/index/index.html b/client/client/src/index/index.html index ea5c80f5f..0d1c2d71a 100644 --- a/client/client/src/index/index.html +++ b/client/client/src/index/index.html @@ -7,7 +7,9 @@ index="index" on-search="$ctrl.search(index)" advanced="true" - popover="vn-client-search-panel"> + popover="vn-client-search-panel" + ignore-keys = "['page', 'size', 'search']" + > diff --git a/client/core/src/lib/crud.js b/client/core/src/lib/crud.js index df5c5d062..fe2c39af2 100644 --- a/client/core/src/lib/crud.js +++ b/client/core/src/lib/crud.js @@ -8,6 +8,14 @@ function index(mgIndex) { } module.factory('vnIndex', index); +nonAuto.$inject = ['mgIndex']; +function nonAuto(mgIndex) { + return Object.assign({}, mgIndex, { + auto: false + }); +} +module.factory('vnIndexNonAuto', nonAuto); + successFactoryCreate.$inject = ['mgSuccessFactoryCreate']; function successFactoryCreate(create) { return Object.assign({}, create, { diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index 5f215808d..ae0e88160 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -1,33 +1,30 @@ - + Finder - -
- - - - -
- + + + + - + initial-value="$ctrl.filter.warehouseFk" + show-field="name" + value-field="id" + field="$ctrl.filter.warehouseFk" + url="/production/api/Warehouses/production" + on-change = "$ctrl.onChangeWareHouse(item)" + label="Store" + >
diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index fff350580..b926f5fa0 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -2,11 +2,10 @@ import ngModule from '../module'; import './style.scss'; export default class ProductionIndex { - constructor($element, $scope, $http, vnPopover, aclConstant) { + constructor($element, $scope, $http, aclConstant) { this.$element = $element; this.$ = $scope; this.$http = $http; - this.vnPopover = vnPopover; this.filter = {}; this.tickets = []; this.states = []; @@ -23,17 +22,6 @@ export default class ProductionIndex { this.filter.warehouseFk = this.userProfile.warehouseId; } - get search() { - return this._search; - } - set search(value) { - this._search = value; - this.filter.q = value; - if (!value) { - this.searchTickets(); - } - } - get checkAll() { return this._checkAll; } @@ -72,55 +60,21 @@ export default class ProductionIndex { } ); } - - moreFilters(event) { - this.child = this.vnPopover.showComponent('vn-production-filter-panel', this.$, this.$element[0].querySelector('.filterPanel')); - var childCtrl = angular.element(this.child).isolateScope().$ctrl; - childCtrl.filter = Object.assign({}, this.filter); - childCtrl.data = Object.assign({}, {states: this.states}, {hourItems: this.hourItems}); - childCtrl.onSubmit = filter => this.onChildSubmit(filter); - childCtrl.onCancel = () => this.onChildCancel(); - event.preventDefault(); - } - onChildSubmit(filter) { - let newFilter = {}; - Object.keys(filter).forEach( - field => { - if (filter[field] !== null) { - newFilter[field] = filter[field]; - } - } - ); - this.searchTickets(newFilter); - this.onChildCancel(); - } - onChildCancel() { - angular.element(this.child).scope().$destroy(); - angular.element(this.child).remove(); - delete this.child; - } searchTickets(filter) { - this.filter = Object.assign({}, this.filter, filter || {}); - let filters = Object.assign({}, { - where: this.filter - }, { - page: 1, - limit: 1000 - }); + this.$.index.filter.filter = Object.assign({}, this.filter, filter || {}); this.checkAll = 0; - this.$http.get('/production/api/FakeProductions/list?filter=' + JSON.stringify(filters)).then( + this.$.index.accept().then( json => { - this.tickets = json.data.tickets; - this.footer.lines = json.data.lines; - this.footer.meters = json.data.m3; - this.footer.total = json.data.total; + this.tickets = json.tickets; + this.footer.lines = json.lines; + this.footer.meters = json.m3; + this.footer.total = json.total; } ); } refreshTickets() { this.filter = {}; this.filter.warehouseFk = this.$.displayValue = this.userProfile.warehouseId; - this.search = null; } onChangeWareHouse(warehouse) { if (warehouse && warehouse != this.filter.warehouseFk) { @@ -141,7 +95,7 @@ export default class ProductionIndex { } } -ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover', 'aclConstant']; +ProductionIndex.$inject = ['$element', '$scope', '$http', 'aclConstant']; ngModule.component('vnProductionIndex', { template: require('./index.html'), diff --git a/client/salix/src/components/searchbar/searchbar.js b/client/salix/src/components/searchbar/searchbar.js index 12c85bcd3..7c5c62515 100644 --- a/client/salix/src/components/searchbar/searchbar.js +++ b/client/salix/src/components/searchbar/searchbar.js @@ -40,7 +40,8 @@ export default class Controller { let keys = Object.keys(filter); if (keys.length) { keys.forEach(k => { - if (k !== 'page' && k !== 'size' && k !== 'search') { + let ignore = (this.ignoreKeys && this.ignoreKeys instanceof Array && this.ignoreKeys.indexOf(k) !== -1); + if (!ignore) { let value = filter[k]; if (typeof value === 'string' && value.indexOf(' ') !== -1) { @@ -110,7 +111,8 @@ ngModule.component('vnSearchbar', { onSearch: '&', advanced: '=', popover: '@', - label: '@?' + label: '@?', + ignoreKeys: ' { let field = {}; - field[key] = filter.where[key]; + field[key] = filter[key]; newFilter.and.push(field); } ); } - filter.where = newFilter; + } else if (Object.keys(filter).length) { + newFilter = filter; } + + filter.where = newFilter; } function onFinish(err, results) {