salix/modules/travel/front/descriptor/index.js

64 lines
1.5 KiB
JavaScript

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.agencyFk) {
travelFilter = this.travel && JSON.stringify({
agencyFk: this.travel.agencyFk
});
}
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: '<'
}
});