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

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-02-10 14:03:11 +00:00
import ngModule from '../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
2021-02-12 11:19:42 +00:00
get invoiceIn() {
2021-02-10 14:03:11 +00:00
return this.entity;
}
2021-02-12 11:19:42 +00:00
set invoiceIn(value) {
2021-02-10 14:03:11 +00:00
this.entity = value;
}
2021-04-12 10:43:17 +00:00
get entryFilter() {
if (this.invoiceIn)
return JSON.stringify({invoiceInFk: this.invoiceIn.id});
return null;
}
get invoiceInFilter() {
if (this.invoiceIn)
return JSON.stringify({supplierFk: this.invoiceIn.supplierFk});
return null;
}
deleteInvoiceIn() {
return this.$http.delete(`InvoiceIns/${this.id}`)
.then(() => this.$state.go('invoiceIn.index'))
.then(() => this.vnApp.showSuccess(this.$t('InvoiceIn deleted')));
}
2021-02-10 14:03:11 +00:00
loadData() {
const filter = {
include: [
{
relation: 'company',
scope: {
fields: ['id', 'code']
}
}
]
};
2021-02-12 11:19:42 +00:00
return this.getData(`InvoiceIns/${this.id}`, {filter})
2021-02-10 14:03:11 +00:00
.then(res => this.entity = res.data);
}
}
2021-02-12 11:19:42 +00:00
ngModule.vnComponent('vnInvoiceInDescriptor', {
2021-02-10 14:03:11 +00:00
template: require('./index.html'),
controller: Controller,
bindings: {
2021-02-12 11:19:42 +00:00
invoiceIn: '<'
2021-02-10 14:03:11 +00:00
}
});