89 lines
2.1 KiB
JavaScript
89 lines
2.1 KiB
JavaScript
import ngModule from '../module';
|
|
import Component from 'core/lib/component';
|
|
|
|
class Controller extends Component {
|
|
constructor($element, $scope, $http, $timeout, $q) {
|
|
super($element, $scope);
|
|
this.$timeout = $timeout;
|
|
this.$http = $http;
|
|
this.$q = $q;
|
|
this.travel = null;
|
|
this._quicklinks = {};
|
|
}
|
|
|
|
set travelId(travelId) {
|
|
if (travelId == this._travelId) return;
|
|
|
|
this._travelId = travelId;
|
|
this.travel = null;
|
|
this.loadData();
|
|
}
|
|
|
|
get travelId() {
|
|
return this._travelId;
|
|
}
|
|
|
|
get quicklinks() {
|
|
return this._quicklinks;
|
|
}
|
|
|
|
set quicklinks(value = {}) {
|
|
Object.keys(value).forEach(key => {
|
|
this._quicklinks[key] = value[key];
|
|
});
|
|
}
|
|
|
|
show() {
|
|
this.$.popover.parent = this.parent;
|
|
this.$.popover.show();
|
|
}
|
|
|
|
loadData() {
|
|
let query = `Travels/findOne`;
|
|
let filter = {
|
|
fields: [
|
|
'id',
|
|
'ref',
|
|
'shipped',
|
|
'landed',
|
|
'totalEntries',
|
|
'warehouseInFk',
|
|
'warehouseOutFk'
|
|
],
|
|
where: {
|
|
id: this._travelId
|
|
},
|
|
include: [
|
|
{
|
|
relation: 'warehouseIn',
|
|
scope: {
|
|
fields: ['name']
|
|
}
|
|
}, {
|
|
relation: 'warehouseOut',
|
|
scope: {
|
|
fields: ['name']
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
this.$http.get(query, {params: {filter}}).then(res => {
|
|
this.travel = res.data;
|
|
this.$.$applyAsync(() => {
|
|
this.$.popover.relocate();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
|
|
|
|
ngModule.component('vnTravelDescriptorPopover', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
travelId: '<',
|
|
quicklinks: '<'
|
|
}
|
|
});
|