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

50 lines
1.3 KiB
JavaScript

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