salix/modules/claim/front/index/index.js

102 lines
2.7 KiB
JavaScript
Raw Normal View History

2018-08-07 09:57:11 +00:00
import ngModule from '../module';
export default class Controller {
constructor($scope) {
this.$ = $scope;
this.ticketSelected = null;
this.filter = {
include: [
{
2018-08-07 10:48:55 +00:00
relation: 'client',
2018-08-07 09:57:11 +00:00
scope: {
fields: ['name']
}
2018-08-07 10:48:55 +00:00
},
{
relation: 'worker',
2018-08-07 09:57:11 +00:00
scope: {
2019-01-30 14:10:52 +00:00
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
2018-08-07 09:57:11 +00:00
}
2018-08-07 10:48:55 +00:00
},
{
relation: 'claimState',
2018-08-07 09:57:11 +00:00
scope: {
2018-08-07 10:48:55 +00:00
fields: ['description']
2018-08-07 09:57:11 +00:00
}
}
],
2018-08-07 10:48:55 +00:00
order: 'claimStateFk ASC, created DESC'
2018-08-07 09:57:11 +00:00
};
}
2018-08-31 12:35:20 +00:00
exprBuilder(param, value) {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? {id: value}
2019-01-21 10:45:53 +00:00
: {client: {like: `%${value}%`}};
case 'client':
2019-01-21 10:45:53 +00:00
return {[param]: {like: `%${value}%`}};
case 'created':
return {created: {between: [value, value]}};
case 'id':
case 'clientFk':
case 'workerFk':
case 'claimStateFk':
return {[param]: value};
}
}
2019-02-10 21:52:35 +00:00
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();
2018-08-31 12:35:20 +00:00
event.preventDefault();
event.stopImmediatePropagation();
}
showWorkerDescriptor(event, userId) {
event.preventDefault();
event.stopImmediatePropagation();
this.selectedWorker = userId;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
2018-09-05 11:47:15 +00:00
preview(event, claim) {
this.claimSelected = claim;
this.$.dialogSummaryClaim.show();
event.preventDefault();
event.stopImmediatePropagation();
}
2018-08-31 12:35:20 +00:00
onDescriptorLoad() {
this.$.popover.relocate();
}
2018-08-07 09:57:11 +00:00
}
Controller.$inject = ['$scope'];
ngModule.component('vnClaimIndex', {
template: require('./index.html'),
controller: Controller
});