79 lines
2.2 KiB
JavaScript
79 lines
2.2 KiB
JavaScript
|
import ngModule from '../module';
|
||
|
import Component from 'core/src/lib/component';
|
||
|
import './style.scss';
|
||
|
|
||
|
class Controller extends Component {
|
||
|
constructor($element, $scope, $http) {
|
||
|
super($element, $scope);
|
||
|
this.$http = $http;
|
||
|
this.isTooltip = true;
|
||
|
this.clear();
|
||
|
}
|
||
|
|
||
|
set ticketFk(value) {
|
||
|
if (value) {
|
||
|
let filter = {
|
||
|
include: [
|
||
|
{relation: 'warehouse', scope: {fields: ['name']}},
|
||
|
{relation: 'agencyMode', scope: {fields: ['name']}},
|
||
|
{
|
||
|
relation: 'client',
|
||
|
scope: {
|
||
|
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
|
||
|
include: {
|
||
|
relation: 'salesPerson',
|
||
|
fields: ['firstName', 'name']
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
relation: 'tracking',
|
||
|
scope: {
|
||
|
fields: ['stateFk'],
|
||
|
include: {
|
||
|
relation: 'state',
|
||
|
fields: ['name']
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
};
|
||
|
|
||
|
let json = encodeURIComponent(JSON.stringify(filter));
|
||
|
let query = `/ticket/api/Tickets/${value}?filter=${json}`;
|
||
|
this.$http.get(query).then(res => {
|
||
|
if (res.data)
|
||
|
this.ticket = res.data;
|
||
|
});
|
||
|
} else
|
||
|
this.clear();
|
||
|
}
|
||
|
|
||
|
get quicklinks() {
|
||
|
return this._quicklinks;
|
||
|
}
|
||
|
|
||
|
set quicklinks(value = {}) {
|
||
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
||
|
}
|
||
|
|
||
|
clear() {
|
||
|
this.ticket = null;
|
||
|
}
|
||
|
|
||
|
show() {
|
||
|
this.$.popover.parent = this.parent;
|
||
|
this.$.popover.show();
|
||
|
}
|
||
|
}
|
||
|
Controller.$inject = ['$element', '$scope', '$http'];
|
||
|
|
||
|
ngModule.component('vnTicketDescriptorPopover', {
|
||
|
template: require('./index.html'),
|
||
|
bindings: {
|
||
|
ticketFk: '<',
|
||
|
quicklinks: '<'
|
||
|
},
|
||
|
controller: Controller
|
||
|
});
|