salix/modules/route/front/descriptor-popover/index.js

127 lines
3.1 KiB
JavaScript
Raw Normal View History

2020-02-05 11:44:14 +00:00
import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
2020-03-17 14:24:55 +00:00
constructor($element, $) {
super($element, $);
2020-02-05 11:44:14 +00:00
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();
2020-02-05 12:37:36 +00:00
let query = 'Routes/findOne';
2020-02-05 11:44:14 +00:00
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();
});
});
}
}
ngModule.component('vnRouteDescriptorPopover', {
template: require('./index.html'),
controller: Controller,
bindings: {
routeFk: '<',
quicklinks: '<'
}
});