salix/modules/ticket/front/request/index/index.js

89 lines
2.4 KiB
JavaScript

import ngModule from '../../module';
class Controller {
constructor($scope, $stateParams) {
this.$stateParams = $stateParams;
this.$ = $scope;
this.filter = {
include: [
{
relation: 'atender',
scope: {
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
},
{
relation: 'requester',
scope: {
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
},
{
relation: 'sale'
}
]
};
}
removeLine(index) {
this.$.model.remove(index);
this.$.watcher.check();
this.$.model.save().then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
});
}
showItemDescriptor(event, itemFk) {
this.quicklinks = {
btnThree: {
icon: 'icon-transaction',
state: `item.card.diary({
id: ${itemFk},
ticketFk: ${this.$stateParams.id}
})`,
tooltip: 'Item diary'
}
};
this.$.itemDescriptor.itemFk = itemFk;
this.$.itemDescriptor.parent = event.target;
this.$.itemDescriptor.show();
}
showWorkerDescriptor(event, workerFk) {
event.preventDefault();
event.stopImmediatePropagation();
this.selectedWorker = workerFk;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
getRequestState(state) {
switch (state) {
case null:
return 'New';
case false:
return 'Denied';
case true:
return 'Acepted';
}
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnTicketRequestIndex', {
template: require('./index.html'),
controller: Controller
});