salix/modules/invoiceOut/front/descriptor-popover/index.js

82 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-04-05 11:20:34 +00:00
import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
constructor($element, $scope, $http, $timeout, $q) {
super($element, $scope);
this.$timeout = $timeout;
this.$http = $http;
this.$q = $q;
this.worker = null;
2019-05-07 09:32:35 +00:00
this._quicklinks = {};
2019-04-05 11:20:34 +00:00
}
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;
}
2019-05-07 09:32:35 +00:00
set quicklinks(value = {}) {
Object.keys(value).forEach(key => {
this._quicklinks[key] = value[key];
});
}
2019-04-05 11:20:34 +00:00
show() {
this.$.popover.parent = this.parent;
this.$.popover.show();
}
loadData() {
let query = `InvoiceOuts/findOne`;
2019-04-05 11:20:34 +00:00
let filter = {
where: {
id: this._invoiceOutId
},
include: [
{
relation: 'company',
scope: {
fields: ['id', 'code']
}
2019-04-08 14:53:37 +00:00
},
{
relation: 'client',
scope: {
fields: ['id', 'name']
}
2019-04-05 11:20:34 +00:00
}
]
};
this.$http.get(query, {params: {filter}}).then(res => {
this.invoiceOut = res.data;
this.$.$applyAsync(() => {
this.$.popover.relocate();
});
});
}
}
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
ngModule.component('vnInvoiceOutDescriptorPopover', {
template: require('./index.html'),
controller: Controller,
bindings: {
invoiceOutId: '<',
quicklinks: '<'
}
});