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

78 lines
1.9 KiB
JavaScript

import ngModule from '../module';
import './style.scss';
export default class Controller {
constructor($scope) {
this.$ = $scope;
this.ticketSelected = null;
this.filter = {
include: [
{
relation: 'client',
scope: {
fields: ['name']
}
},
{
relation: 'worker',
scope: {
fields: ['firstName', 'name']
}
},
{
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};
}
}
showDescriptor(event, clientFk) {
this.$.descriptor.clientFk = clientFk;
this.$.descriptor.parent = event.target;
this.$.descriptor.show();
event.preventDefault();
event.stopImmediatePropagation();
}
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
});