salix/modules/ticket/front/descriptor/index.js

90 lines
2.2 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
2020-04-25 09:50:04 +00:00
import Descriptor from 'salix/components/descriptor';
2020-04-25 09:50:04 +00:00
class Controller extends Descriptor {
2019-12-17 07:38:36 +00:00
get ticket() {
return this.entity;
2019-12-17 07:38:36 +00:00
}
set ticket(value) {
this.entity = value;
}
2019-12-17 07:38:36 +00:00
get entity() {
return super.entity;
}
2019-12-17 07:38:36 +00:00
set entity(value) {
super.entity = value;
}
get hasInvoicing() {
return this.aclService.hasAny(['invoicing']);
}
loadData() {
const filter = {
include: [
{
relation: 'warehouse',
scope: {
fields: ['name']
}
}, {
relation: 'agencyMode',
scope: {
fields: ['name']
}
}, {
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked'
],
include: {
relation: 'salesPersonUser',
scope: {
fields: ['id', 'name']
}
}
}
}, {
2020-06-23 11:40:49 +00:00
relation: 'ticketState',
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['id', 'name'],
}
}
}
]
};
return this.getData(`Tickets/${this.id}`, {filter})
.then(res => this.entity = res.data);
2019-11-20 05:53:37 +00:00
}
2020-11-10 09:38:25 +00:00
cardReload() {
// Prevents error when not defined
}
get filter() {
return this.ticket ?
JSON.stringify({clientFk: this.ticket.clientFk}) : null;
}
}
2020-04-25 09:50:04 +00:00
ngModule.vnComponent('vnTicketDescriptor', {
template: require('./index.html'),
2020-04-25 09:50:04 +00:00
controller: Controller,
bindings: {
ticket: '<',
cardReload: '&'
2020-04-25 09:50:04 +00:00
}
});