78 lines
1.8 KiB
JavaScript
78 lines
1.8 KiB
JavaScript
import ngModule from '../module';
|
|
import Component from 'core/lib/component';
|
|
import './style.scss';
|
|
|
|
class Controller extends Component {
|
|
constructor($element, $scope,) {
|
|
super($element, $scope);
|
|
this.worker = null;
|
|
this._quicklinks = {};
|
|
}
|
|
|
|
set invoiceOutId(id) {
|
|
if (id == this._invoiceOutId) return;
|
|
|
|
this._invoiceOutId = id;
|
|
this.invoiceOut = null;
|
|
this.loadData();
|
|
}
|
|
|
|
get invoiceOutId() {
|
|
return this._invoiceOutId;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
loadData() {
|
|
let query = `InvoiceOuts/findOne`;
|
|
let filter = {
|
|
where: {
|
|
id: this._invoiceOutId
|
|
},
|
|
include: [
|
|
{
|
|
relation: 'company',
|
|
scope: {
|
|
fields: ['id', 'code']
|
|
}
|
|
},
|
|
{
|
|
relation: 'client',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
this.$http.get(query, {params: {filter}}).then(res => {
|
|
this.invoiceOut = res.data;
|
|
this.$.$applyAsync(() => {
|
|
this.$.popover.relocate();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnInvoiceOutDescriptorPopover', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
invoiceOutId: '<',
|
|
quicklinks: '<'
|
|
}
|
|
});
|