52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import ngModule from '../module';
|
|
|
|
export default class Controller {
|
|
constructor($) {
|
|
Object.assign(this, {
|
|
$,
|
|
selectedWorker: null,
|
|
include: [
|
|
{
|
|
relation: 'user',
|
|
scope: {fields: ['nickname', 'email']}
|
|
}, {
|
|
relation: 'client',
|
|
scope: {fields: ['fi']}
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
exprBuilder(param, value) {
|
|
switch (param) {
|
|
case 'search':
|
|
return /^\d+$/.test(value)
|
|
? {id: value}
|
|
: {or: [
|
|
{firstName: {like: `%${value}%`}},
|
|
{name: {like: `%${value}%`}}
|
|
]};
|
|
case 'name':
|
|
case 'firstName':
|
|
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
|
|
});
|