2018-08-30 06:50:03 +00:00
|
|
|
import ngModule from '../module';
|
2018-12-27 11:54:16 +00:00
|
|
|
import Component from 'core/lib/component';
|
2018-08-30 06:50:03 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
2020-03-18 07:35:59 +00:00
|
|
|
constructor($element, $scope) {
|
2018-08-30 06:50:03 +00:00
|
|
|
super($element, $scope);
|
2018-10-18 09:41:25 +00:00
|
|
|
this.ticket = null;
|
2019-05-07 09:32:35 +00:00
|
|
|
this._quicklinks = {};
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
set ticketFk(id) {
|
|
|
|
if (id == this._ticketFk) return;
|
2018-08-30 06:50:03 +00:00
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
this._ticketFk = id;
|
|
|
|
this.ticket = null;
|
|
|
|
this.getCard();
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
set ticket(value) {
|
|
|
|
this._ticket = value;
|
|
|
|
this.$timeout(() => this.$.popover.relocate());
|
|
|
|
}
|
|
|
|
|
|
|
|
get ticket() {
|
|
|
|
return this._ticket;
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
2019-05-07 09:32:35 +00:00
|
|
|
set quicklinks(value = {}) {
|
|
|
|
Object.keys(value).forEach(key => {
|
|
|
|
this._quicklinks[key] = value[key];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-08-30 06:50:03 +00:00
|
|
|
show() {
|
|
|
|
this.$.popover.parent = this.parent;
|
|
|
|
this.$.popover.show();
|
|
|
|
}
|
2018-10-18 09:41:25 +00:00
|
|
|
|
|
|
|
getCard() {
|
|
|
|
if (this.canceler)
|
|
|
|
this.canceler.resolve();
|
|
|
|
|
|
|
|
this.canceler = this.$q.defer();
|
|
|
|
|
|
|
|
let options = {timeout: this.canceler.promise};
|
|
|
|
|
|
|
|
let filter = {
|
|
|
|
include: [
|
2019-01-31 13:14:39 +00:00
|
|
|
{
|
|
|
|
relation: 'warehouse',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'agencyMode',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
2018-10-18 09:41:25 +00:00
|
|
|
{
|
|
|
|
relation: 'client',
|
|
|
|
scope: {
|
|
|
|
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
|
|
|
|
include: {
|
|
|
|
relation: 'salesPerson',
|
2019-01-31 13:14:39 +00:00
|
|
|
scope: {
|
|
|
|
fields: ['userFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'user',
|
|
|
|
scope: {
|
|
|
|
fields: ['nickname']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-18 09:41:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2019-01-31 13:14:39 +00:00
|
|
|
relation: 'state',
|
2018-10-18 09:41:25 +00:00
|
|
|
scope: {
|
|
|
|
fields: ['stateFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'state',
|
2019-01-31 13:14:39 +00:00
|
|
|
fields: ['id', 'name'],
|
2018-10-18 09:41:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
let json = encodeURIComponent(JSON.stringify(filter));
|
2019-10-24 22:53:53 +00:00
|
|
|
let query = `Tickets/${this._ticketFk}?filter=${json}`;
|
2018-10-18 09:41:25 +00:00
|
|
|
this.$http.get(query, options).then(
|
|
|
|
response => {
|
|
|
|
this.ticket = response.data;
|
|
|
|
this.canceler = null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2018-08-30 06:50:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnTicketDescriptorPopover', {
|
|
|
|
template: require('./index.html'),
|
2018-10-18 09:41:25 +00:00
|
|
|
controller: Controller,
|
2018-08-30 06:50:03 +00:00
|
|
|
bindings: {
|
|
|
|
ticketFk: '<',
|
|
|
|
quicklinks: '<'
|
2018-10-18 09:41:25 +00:00
|
|
|
}
|
2018-08-30 06:50:03 +00:00
|
|
|
});
|