2020-02-18 09:33:17 +00:00
|
|
|
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 = {};
|
|
|
|
}
|
|
|
|
|
2020-02-18 10:07:55 +00:00
|
|
|
set travelId(travelId) {
|
|
|
|
if (travelId == this._travelId) return;
|
2020-02-18 09:33:17 +00:00
|
|
|
|
2020-02-18 10:07:55 +00:00
|
|
|
this._travelId = travelId;
|
2020-02-18 09:33:17 +00:00
|
|
|
this.travel = null;
|
|
|
|
this.loadData();
|
|
|
|
}
|
|
|
|
|
2020-02-18 10:07:55 +00:00
|
|
|
get travelId() {
|
|
|
|
return this._travelId;
|
2020-02-18 09:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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: {
|
2020-02-18 10:07:55 +00:00
|
|
|
id: this._travelId
|
2020-02-18 09:33:17 +00:00
|
|
|
},
|
|
|
|
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: {
|
2020-02-18 10:07:55 +00:00
|
|
|
travelId: '<',
|
2020-02-18 09:33:17 +00:00
|
|
|
quicklinks: '<'
|
|
|
|
}
|
|
|
|
});
|