2017-06-03 11:01:47 +00:00
|
|
|
import ngModule from '../module';
|
2019-11-21 13:00:27 +00:00
|
|
|
import Component from 'core/lib/component';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2019-01-07 07:49:01 +00:00
|
|
|
this.moreOptions = [
|
2019-11-21 13:00:27 +00:00
|
|
|
{name: 'Simple ticket', callback: this.newTicket},
|
|
|
|
{name: 'Send SMS', callback: this.showSMSDialog},
|
2019-01-07 07:49:01 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
2018-08-02 08:06:11 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 12:21:52 +00:00
|
|
|
get client() {
|
|
|
|
return this._client;
|
|
|
|
}
|
|
|
|
|
2018-08-02 08:06:11 +00:00
|
|
|
set client(value) {
|
|
|
|
this._client = value;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
set quicklinks(value = {}) {
|
2018-08-02 08:06:11 +00:00
|
|
|
this._quicklinks = Object.assign(value, this._quicklinks);
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
2019-01-07 07:49:01 +00:00
|
|
|
|
|
|
|
newTicket() {
|
|
|
|
this.$state.go('ticket.create', {clientFk: this.client.id});
|
|
|
|
}
|
2019-11-21 13:00:27 +00:00
|
|
|
|
|
|
|
showSMSDialog() {
|
|
|
|
const phone = this.$params.phone || this.client.phone;
|
|
|
|
const message = this.$params.message || '';
|
|
|
|
this.newSMS = {
|
|
|
|
destinationFk: this.client.id,
|
|
|
|
destination: phone,
|
|
|
|
message: message
|
|
|
|
};
|
|
|
|
this.$.sms.open();
|
|
|
|
}
|
2018-03-09 15:44:18 +00:00
|
|
|
}
|
2018-05-31 06:57:25 +00:00
|
|
|
|
2019-11-21 13:00:27 +00:00
|
|
|
Controller.$inject = ['$element', '$scope'];
|
2018-03-09 15:44:18 +00:00
|
|
|
|
2018-02-12 12:16:49 +00:00
|
|
|
ngModule.component('vnClientDescriptor', {
|
2018-05-23 12:26:51 +00:00
|
|
|
template: require('./index.html'),
|
2017-01-31 13:13:06 +00:00
|
|
|
bindings: {
|
2018-07-26 10:06:53 +00:00
|
|
|
client: '<',
|
2018-08-01 10:15:09 +00:00
|
|
|
quicklinks: '<'
|
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
|
|
|
});
|