salix/modules/worker/front/index/index.js

52 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-01-28 15:24:45 +00:00
import ngModule from '../module';
export default class Controller {
constructor($) {
Object.assign(this, {
$,
2019-01-29 15:37:59 +00:00
selectedWorker: null,
include: [
{
relation: 'user',
scope: {fields: ['nickname', 'email']}
2019-01-29 15:37:59 +00:00
}, {
relation: 'client',
scope: {fields: ['fi']}
}
]
2019-01-28 15:24:45 +00:00
});
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? {id: value}
2019-01-29 15:37:59 +00:00
: {or: [
{firstName: {like: `%${value}%`}},
{name: {like: `%${value}%`}}
]};
2019-01-28 15:24:45 +00:00
case 'name':
2019-01-29 15:37:59 +00:00
case 'firstName':
2019-01-28 15:24:45 +00:00
return {[param]: {like: `%${value}%`}};
case 'id':
return {[param]: value};
}
}
preview(event, worker) {
if (event.defaultPrevented) return;
event.preventDefault();
this.selectedWorker = worker;
this.$.preview.show();
event.stopImmediatePropagation();
}
}
Controller.$inject = ['$scope'];
ngModule.component('vnWorkerIndex', {
template: require('./index.html'),
controller: Controller
});