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; } set invoiceOutId(id) { if (id == this._invoiceOutId) return; this._invoiceOutId = id; this.invoiceOut = null; this.loadData(); } get invoiceOutId() { return this._invoiceOutId; } set quicklinks(value = {}) { this._quicklinks = Object.assign(value, this._quicklinks); } get quicklinks() { return this._quicklinks; } show() { this.$.popover.parent = this.parent; this.$.popover.show(); } loadData() { let query = `api/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(); }); }); } } Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q']; ngModule.component('vnInvoiceOutDescriptorPopover', { template: require('./index.html'), controller: Controller, bindings: { invoiceOutId: '<', quicklinks: '<' } });