import ngModule from '../module'; import SearchPanel from 'core/components/searchbar/search-panel'; import './style.scss'; class Controller extends SearchPanel { constructor($element, $) { super($element, $); this.filter = {}; const filter = { fields: ['daysAgo'] }; this.$http.get('InvoiceInConfigs', {filter}).then(res => { if (res.data) { this.invoiceInConfig = res.data[0]; this.addFilters(); } }); } removeItemFilter(param) { this.filter[param] = null; this.addFilters(); } onKeyPress($event) { if ($event.key === 'Enter') this.addFilters(); } addFilters() { if (!this.filter.daysAgo) this.filter.daysAgo = this.invoiceInConfig.daysAgo; return this.model.addFilter({}, this.filter); } } ngModule.component('vnInvoiceInSerialSearchPanel', { template: require('./index.html'), controller: Controller, bindings: { model: '<' } });