102 lines
2.7 KiB
JavaScript
102 lines
2.7 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
export default class Controller {
|
|
constructor($scope) {
|
|
this.$ = $scope;
|
|
this.ticketSelected = null;
|
|
|
|
this.filter = {
|
|
include: [
|
|
{
|
|
relation: 'client',
|
|
scope: {
|
|
fields: ['name']
|
|
}
|
|
},
|
|
{
|
|
relation: 'worker',
|
|
scope: {
|
|
fields: ['userFk'],
|
|
include: {
|
|
relation: 'user',
|
|
scope: {
|
|
fields: ['nickname']
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
relation: 'claimState',
|
|
scope: {
|
|
fields: ['description']
|
|
}
|
|
}
|
|
],
|
|
order: 'claimStateFk ASC, created DESC'
|
|
};
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'search':
|
|
return /^\d+$/.test(value)
|
|
? {id: value}
|
|
: {client: {like: `%${value}%`}};
|
|
case 'client':
|
|
return {[param]: {like: `%${value}%`}};
|
|
case 'created':
|
|
return {created: {between: [value, value]}};
|
|
case 'id':
|
|
case 'clientFk':
|
|
case 'workerFk':
|
|
case 'claimStateFk':
|
|
return {[param]: value};
|
|
}
|
|
}
|
|
|
|
stateColor(claim) {
|
|
switch (claim.claimState.description) {
|
|
case 'Pendiente':
|
|
return 'warning';
|
|
case 'Gestionado':
|
|
return 'notice';
|
|
case 'Resuelto':
|
|
return 'success';
|
|
}
|
|
}
|
|
|
|
showClientDescriptor(event, clientFk) {
|
|
this.$.clientDescriptor.clientFk = clientFk;
|
|
this.$.clientDescriptor.parent = event.target;
|
|
this.$.clientDescriptor.show();
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
showWorkerDescriptor(event, userId) {
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
this.selectedWorker = userId;
|
|
this.$.workerDescriptor.parent = event.target;
|
|
this.$.workerDescriptor.show();
|
|
}
|
|
|
|
preview(event, claim) {
|
|
this.claimSelected = claim;
|
|
this.$.dialogSummaryClaim.show();
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
onDescriptorLoad() {
|
|
this.$.popover.relocate();
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$scope'];
|
|
|
|
ngModule.component('vnClaimIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller
|
|
});
|