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

62 lines
1.3 KiB
JavaScript

import ngModule from '../module';
class Controller {
constructor($http, $state) {
this.$state = $state;
this.$http = $http;
this.moreOptions = [
{callback: this.newTicket, name: 'Simple ticket'}
];
}
onMoreChange(callback) {
callback.call(this);
}
set client(value) {
this._client = value;
if (!value) return;
this._quicklinks = {
btnOne: {
icon: 'icon-ticket',
state: `ticket.index({q: '{"clientFk": ${value.id}}'})`,
tooltip: 'Client ticket list'
},
btnTwo: {
icon: 'icon-basket',
state: `order.create({clientFk: ${value.id}})`,
tooltip: 'New order'
}
};
}
get client() {
return this._client;
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this._quicklinks);
}
get quicklinks() {
return this._quicklinks;
}
newTicket() {
this.$state.go('ticket.create', {clientFk: this.client.id});
}
}
Controller.$inject = ['$http', '$state'];
ngModule.component('vnClientDescriptor', {
template: require('./index.html'),
bindings: {
client: '<',
quicklinks: '<'
},
controller: Controller
});