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

69 lines
1.8 KiB
JavaScript

import ngModule from '../module';
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
constructor($element, $, $httpParamSerializer) {
super($element, $);
this.$httpParamSerializer = $httpParamSerializer;
}
get client() {
return this._client;
}
set client(value) {
this._client = 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 this.client ? JSON.stringify({clientFk: this.client.id}) : null;
}
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', '$httpParamSerializer'];
ngModule.vnComponent('vnClientDescriptor', {
template: require('./index.html'),
bindings: {
client: '<'
},
controller: Controller
});