import { computed } from '@ember/object' import Component from '@ember/component'; export default Component.extend({ classNames: ['form-group'], optionsKeyMapping: { dateAdded: 'model.dateAddedList', countryCode: 'model.countryCodeList', state: 'model.stateList', city: 'model.cityList', region: 'model.regionList', ms: 'model.msList', salesperson: 'model.salespersonList', status: 'model.statusList' }, valOptions: computed('criterion.col', function() { let me = this; let optionsKey = me.get('optionsKeyMapping.' + me.get('criterion.col')); optionsKey && me.set('criterion.val', ''); return optionsKey && me.get(optionsKey) || null; }), actions: { remove() { let me = this; let criterion = me.get('criterion'); console.info('Remove Criterion: ', criterion); let removeAction = me.get('removeCriterion'); removeAction && removeAction(criterion); }, onColChanged(col) { let me = this; me.get('valOptions') && me.set('criterion.val', ''); me.set('criterion.col', col); }, onOpChanged(op) { this.set('criterion.op', op); }, onValChanged(val) { this.set('criterion.val', val); } } });