import ngModule from '../module'; import Descriptor from 'salix/components/descriptor'; class Controller extends Descriptor { get travel() { return this.entity; } set travel(value) { this.entity = value; } get travelFilter() { let travelFilter; const travel = this.travel; if (travel && travel.agencyModeFk) { travelFilter = this.travel && JSON.stringify({ agencyModeFk: this.travel.agencyModeFk }); } return travelFilter; } loadData() { const filter = { fields: [ 'id', 'ref', 'shipped', 'landed', 'totalEntries', 'warehouseInFk', 'warehouseOutFk', 'cargoSupplierFk' ], include: [ { relation: 'warehouseIn', scope: { fields: ['name'] } }, { relation: 'warehouseOut', scope: { fields: ['name'] } } ] }; return this.getData(`Travels/${this.id}`, {filter}) .then(res => this.entity = res.data); } } ngModule.vnComponent('vnTravelDescriptor', { template: require('./index.html'), controller: Controller, bindings: { travel: '<' } });