import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); this.filter = { include: [{ relation: 'item' }] }; this.ticketVolumes = []; } get sales() { return this._sales; } set sales(value) { this._sales = value; if (value) this.applyVolumes(); } get volumes() { return this._volumes; } set volumes(value) { this._volumes = value; if (value) this.applyVolumes(); } applyVolumes() { if (!this.sales || !this.volumes) return; this.sales.forEach(sale => { this.volumes.forEach(volume => { if (sale.id === volume.saleFk) sale.volume = volume; }); }); } } ngModule.component('vnTicketVolume', { template: require('./index.html'), controller: Controller, bindings: { ticket: '<' } });