import ngModule from '../module'; import Descriptor from 'salix/components/descriptor'; class Controller extends Descriptor { constructor($element, $, $transclude, $httpParamSerializer) { super($element, $, $transclude); this.$httpParamSerializer = $httpParamSerializer; } get client() { return this.entity; } set client(value) { this.entity = value; if (!value) return; if (this.$params.sendSMS) this.showSMSDialog(); this._quicklinks = { btnOne: { icon: 'icon-ticket', state: `ticket.index({q: '{"clientFk": ${value.id}}'})`, tooltip: 'Client ticket list' }, btnTwo: { icon: 'icon-basketadd', state: `order.create({clientFk: ${value.id}})`, tooltip: 'New order' } }; } get filter() { return JSON.stringify({clientFk: this.client.id}); } showSMSDialog() { const client = this.client || {}; this.newSMS = { destinationFk: client.id, destination: this.$params.phone || client.mobile || client.phone, message: this.$params.message || '' }; this.$.sms.open(); } onConsumerReportAccept() { const params = this.$httpParamSerializer({ authorization: this.vnToken.token, clientId: this.client.id, from: this.from, to: this.to, }); window.open(`api/report/campaign-metrics?${params}`); } } Controller.$inject = ['$element', '$scope', '$transclude', '$httpParamSerializer']; ngModule.vnComponent('vnClientDescriptor', { slotTemplate: require('./index.html'), bindings: { client: '<' }, controller: Controller });