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

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-10-24 10:49:18 +00:00
import ngModule from '../module';
2020-04-25 09:50:04 +00:00
import Descriptor from 'salix/components/descriptor';
2019-10-24 10:49:18 +00:00
class Controller extends Descriptor {
get travel() {
return this.entity;
}
set travel(value) {
this.entity = value;
}
2020-11-16 13:50:03 +00:00
get travelFilter() {
let travelFilter;
const travel = this.travel;
2022-07-13 12:36:03 +00:00
if (travel && travel.agencyModeFk) {
2020-11-16 13:50:03 +00:00
travelFilter = this.travel && JSON.stringify({
2022-07-13 12:36:03 +00:00
agencyModeFk: this.travel.agencyModeFk
2020-11-16 13:50:03 +00:00
});
}
return travelFilter;
}
loadData() {
const filter = {
fields: [
'id',
'ref',
'shipped',
'landed',
'totalEntries',
'warehouseInFk',
2020-11-16 13:50:03 +00:00
'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);
}
}
2020-04-25 09:50:04 +00:00
ngModule.vnComponent('vnTravelDescriptor', {
2019-10-24 10:49:18 +00:00
template: require('./index.html'),
controller: Controller,
2019-10-24 10:49:18 +00:00
bindings: {
travel: '<'
}
2019-10-24 10:49:18 +00:00
});