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

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2023-05-16 06:54:54 +00:00
import ngModule from '../../module';
2023-05-15 11:15:33 +00:00
import Descriptor from 'salix/components/descriptor';
class Controller extends Descriptor {
constructor($element, $, $rootScope) {
super($element, $);
this.$rootScope = $rootScope;
}
2023-05-16 11:10:26 +00:00
get department() {
return this.entity;
}
2023-05-15 11:15:33 +00:00
2023-05-16 11:10:26 +00:00
set department(value) {
this.entity = value;
}
loadData() {
const filter = {
2023-05-26 12:08:37 +00:00
fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMai', 'hasToMistake', 'clientFk'],
2023-05-16 11:10:26 +00:00
include: [
{
relation: 'client',
2023-05-26 12:08:37 +00:00
scope: {fields: ['name']}
},
{
relation: 'worker',
scope: {fields: ['name']}
2023-05-16 11:10:26 +00:00
}, {
relation: 'department',
2023-05-26 12:08:37 +00:00
scope: {fields: ['name']}
2023-05-16 11:10:26 +00:00
}
]
};
2023-05-15 11:15:33 +00:00
2023-05-16 11:10:26 +00:00
return this.getData(`Workers/${this.id}`, {filter})
.then(res => this.entity = res.data);
}
2023-05-15 11:15:33 +00:00
}
Controller.$inject = ['$element', '$scope', '$rootScope'];
ngModule.vnComponent('vnWorkerDepartmentDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
worker: '<'
}
});