2017-06-03 11:01:47 +00:00
|
|
|
import ngModule from '../module';
|
2020-04-25 09:50:04 +00:00
|
|
|
import Descriptor from 'salix/components/descriptor';
|
2019-11-21 13:00:27 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
class Controller extends Descriptor {
|
2020-04-28 12:26:02 +00:00
|
|
|
constructor($element, $, $transclude, $httpParamSerializer) {
|
|
|
|
super($element, $, $transclude);
|
2020-02-11 12:25:41 +00:00
|
|
|
this.$httpParamSerializer = $httpParamSerializer;
|
2018-08-02 08:06:11 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 12:21:52 +00:00
|
|
|
get client() {
|
2020-04-28 12:26:02 +00:00
|
|
|
return this.entity;
|
2019-10-21 12:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-08-02 08:06:11 +00:00
|
|
|
set client(value) {
|
2020-04-28 12:26:02 +00:00
|
|
|
this.entity = value;
|
2018-08-02 08:06:11 +00:00
|
|
|
if (!value) return;
|
|
|
|
|
2019-11-21 13:00:27 +00:00
|
|
|
if (this.$params.sendSMS)
|
|
|
|
this.showSMSDialog();
|
|
|
|
|
2018-08-02 08:06:11 +00:00
|
|
|
this._quicklinks = {
|
2018-08-01 10:15:09 +00:00
|
|
|
btnOne: {
|
|
|
|
icon: 'icon-ticket',
|
2018-09-04 09:49:00 +00:00
|
|
|
state: `ticket.index({q: '{"clientFk": ${value.id}}'})`,
|
2018-08-01 10:15:09 +00:00
|
|
|
tooltip: 'Client ticket list'
|
2018-11-23 06:59:51 +00:00
|
|
|
},
|
|
|
|
btnTwo: {
|
2019-05-07 09:55:47 +00:00
|
|
|
icon: 'icon-basketadd',
|
2018-11-23 06:59:51 +00:00
|
|
|
state: `order.create({clientFk: ${value.id}})`,
|
|
|
|
tooltip: 'New order'
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
};
|
2018-03-09 15:44:18 +00:00
|
|
|
}
|
2018-08-01 10:15:09 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
get filter() {
|
2020-04-28 12:26:02 +00:00
|
|
|
return JSON.stringify({clientFk: this.client.id});
|
2019-01-07 07:49:01 +00:00
|
|
|
}
|
2019-11-21 13:00:27 +00:00
|
|
|
|
|
|
|
showSMSDialog() {
|
2020-04-25 09:50:04 +00:00
|
|
|
const client = this.client || {};
|
2019-11-21 13:00:27 +00:00
|
|
|
this.newSMS = {
|
2020-02-21 07:37:37 +00:00
|
|
|
destinationFk: client.id,
|
2020-04-25 09:50:04 +00:00
|
|
|
destination: this.$params.phone || client.mobile || client.phone,
|
|
|
|
message: this.$params.message || ''
|
2019-11-21 13:00:27 +00:00
|
|
|
};
|
|
|
|
this.$.sms.open();
|
|
|
|
}
|
2020-02-11 12:25:41 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
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}`);
|
2020-02-11 12:25:41 +00:00
|
|
|
}
|
2018-03-09 15:44:18 +00:00
|
|
|
}
|
2020-04-28 12:26:02 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$transclude', '$httpParamSerializer'];
|
2018-03-09 15:44:18 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
ngModule.vnComponent('vnClientDescriptor', {
|
2020-04-28 12:26:02 +00:00
|
|
|
slotTemplate: require('./index.html'),
|
2017-01-31 13:13:06 +00:00
|
|
|
bindings: {
|
2020-04-25 09:50:04 +00:00
|
|
|
client: '<'
|
2018-03-09 15:44:18 +00:00
|
|
|
},
|
2018-05-23 12:26:51 +00:00
|
|
|
controller: Controller
|
2017-06-03 11:01:47 +00:00
|
|
|
});
|