62 lines
1.3 KiB
JavaScript
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);
|
|
}
|
|
|
|
get client() {
|
|
return this._client;
|
|
}
|
|
|
|
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-basketadd',
|
|
state: `order.create({clientFk: ${value.id}})`,
|
|
tooltip: 'New order'
|
|
}
|
|
};
|
|
}
|
|
|
|
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
|
|
});
|