2023-05-30 12:49:28 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
import Autocomplete from '../autocomplete';
|
|
|
|
|
|
|
|
export default class WorkerAutocomplete extends Autocomplete {
|
2023-06-08 09:07:57 +00:00
|
|
|
constructor(...args) {
|
|
|
|
super(...args);
|
2023-06-21 12:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$onInit() {
|
2023-07-12 11:12:51 +00:00
|
|
|
super.$onInit();
|
|
|
|
|
2023-06-21 12:07:36 +00:00
|
|
|
let url = 'Workers/search';
|
|
|
|
if (this.departments) {
|
|
|
|
const parameter = encodeURIComponent(JSON.stringify(this.departments));
|
|
|
|
url = `Workers/search?departmentCodes=${parameter}`;
|
|
|
|
}
|
2023-06-08 09:07:57 +00:00
|
|
|
Object.assign(this, {
|
|
|
|
label: 'Worker',
|
2023-08-24 05:40:37 +00:00
|
|
|
url,
|
2023-06-08 11:12:30 +00:00
|
|
|
searchFunction: function({$search}) {
|
2023-06-08 09:07:57 +00:00
|
|
|
return {and: [
|
2023-07-12 11:12:51 +00:00
|
|
|
{'active': {neq: false}},
|
2023-06-08 09:07:57 +00:00
|
|
|
{or: [
|
2023-07-12 11:12:51 +00:00
|
|
|
{'name': $search},
|
|
|
|
{'nickname': {like: '%' + $search + '%'}},
|
|
|
|
{'code': {like: $search + '%'}}
|
2023-06-08 09:07:57 +00:00
|
|
|
]}
|
|
|
|
]};
|
2023-06-21 12:07:36 +00:00
|
|
|
},
|
2023-06-08 09:07:57 +00:00
|
|
|
});
|
2023-05-30 12:49:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnWorkerAutocomplete', {
|
2023-06-08 09:07:57 +00:00
|
|
|
slotTemplate: require('./index.html'),
|
2023-06-21 12:07:36 +00:00
|
|
|
controller: WorkerAutocomplete,
|
|
|
|
bindings: {
|
|
|
|
departments: '<?'
|
|
|
|
},
|
2023-05-30 12:49:28 +00:00
|
|
|
});
|