131 lines
3.3 KiB
JavaScript
131 lines
3.3 KiB
JavaScript
|
import ngModule from '../module';
|
||
|
import Component from 'core/lib/component';
|
||
|
import './style.scss';
|
||
|
|
||
|
class Controller extends Component {
|
||
|
constructor($element, $scope, $http, $timeout, $q) {
|
||
|
super($element, $scope);
|
||
|
this.$timeout = $timeout;
|
||
|
this.$http = $http;
|
||
|
this.$q = $q;
|
||
|
this.route = null;
|
||
|
this._quicklinks = {};
|
||
|
}
|
||
|
|
||
|
set routeFk(id) {
|
||
|
if (id == this._routeFk) return;
|
||
|
|
||
|
this._routeFk = id;
|
||
|
this.route = null;
|
||
|
this.getCard();
|
||
|
}
|
||
|
|
||
|
get routeFk() {
|
||
|
return this._routeFk;
|
||
|
}
|
||
|
|
||
|
set route(value) {
|
||
|
this._route = value;
|
||
|
this.$timeout(() => this.$.popover.relocate());
|
||
|
}
|
||
|
|
||
|
get route() {
|
||
|
return this._route;
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
}
|
||
|
|
||
|
getCard() {
|
||
|
if (this.canceler)
|
||
|
this.canceler.resolve();
|
||
|
|
||
|
this.canceler = this.$q.defer();
|
||
|
|
||
|
let query = `Routes/findOne`;
|
||
|
|
||
|
let filter = {
|
||
|
fields: [
|
||
|
'id',
|
||
|
'workerFk',
|
||
|
'agencyModeFk',
|
||
|
'created',
|
||
|
'm3',
|
||
|
'warehouseFk',
|
||
|
'description',
|
||
|
'vehicleFk',
|
||
|
'kmStart',
|
||
|
'kmEnd',
|
||
|
'started',
|
||
|
'finished',
|
||
|
'cost',
|
||
|
'zoneFk'
|
||
|
],
|
||
|
include: [
|
||
|
{
|
||
|
relation: 'agencyMode',
|
||
|
scope: {
|
||
|
fields: ['id', 'name']
|
||
|
}
|
||
|
}, {
|
||
|
relation: 'vehicle',
|
||
|
scope: {
|
||
|
fields: ['id', 'm3']
|
||
|
}
|
||
|
}, {
|
||
|
relation: 'zone',
|
||
|
scope: {
|
||
|
fields: ['id', 'name']
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
relation: 'worker',
|
||
|
scope: {
|
||
|
fields: ['userFk'],
|
||
|
include: {
|
||
|
relation: 'user',
|
||
|
scope: {
|
||
|
fields: ['id'],
|
||
|
include: {
|
||
|
relation: 'emailUser',
|
||
|
scope: {
|
||
|
fields: ['email']
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
};
|
||
|
this.$http.get(query, {params: {filter}}).then(res => {
|
||
|
this.route = res.data;
|
||
|
this.$.$applyAsync(() => {
|
||
|
this.$.popover.relocate();
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
|
||
|
|
||
|
ngModule.component('vnRouteDescriptorPopover', {
|
||
|
template: require('./index.html'),
|
||
|
controller: Controller,
|
||
|
bindings: {
|
||
|
routeFk: '<',
|
||
|
quicklinks: '<'
|
||
|
}
|
||
|
});
|