import ngModule from '../../module'; import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); this.filter = { include: [ { relation: 'atender', scope: { include: { relation: 'user', scope: { fields: ['nickname'] } } } }, { relation: 'requester', scope: { include: { relation: 'user', scope: { fields: ['nickname'] } } } }, { relation: 'sale' } ] }; } removeLine(index) { this.$.model.remove(index); this.$.watcher.check(); this.$.model.save().then(() => { this.$.watcher.notifySaved(); this.$.watcher.updateOriginalData(); }); } showItemDescriptor(event, itemFk) { this.quicklinks = { btnThree: { icon: 'icon-transaction', state: `item.card.diary({ id: ${itemFk}, ticketFk: ${this.$params.id} })`, tooltip: 'Item diary' } }; this.$.itemDescriptor.itemFk = itemFk; this.$.itemDescriptor.parent = event.target; this.$.itemDescriptor.show(); } showWorkerDescriptor(event, workerFk) { event.preventDefault(); event.stopImmediatePropagation(); this.selectedWorker = workerFk; this.$.workerDescriptor.parent = event.target; this.$.workerDescriptor.show(); } getRequestState(state) { switch (state) { case null: return 'New'; case false: return 'Denied'; case true: return 'Acepted'; } } updateData() { this.$.model.save().then(() => { this.$.watcher.notifySaved(); this.$.watcher.updateOriginalData(); }); } isEditable(isOk) { if (isOk != null) return true; return false; } } ngModule.component('vnTicketRequestIndex', { template: require('./index.html'), controller: Controller });