68 lines
1.8 KiB
JavaScript
68 lines
1.8 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;
|
|
}
|
|
|
|
filterDepartments(department, event) {
|
|
if (event.defaultPrevented) return;
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
|
|
this.$state.go(`worker.index`,
|
|
{q: JSON.stringify({departmentFk: department.id})});
|
|
}
|
|
|
|
deleteDepartment() {
|
|
return this.$http.delete(`Departments/${this.id}`)
|
|
.then(() => {
|
|
this.$state.go('worker.department');
|
|
|
|
this.vnApp.showSuccess(this.$t('Department deleted.'));
|
|
});
|
|
}
|
|
|
|
loadData() {
|
|
const filter = {
|
|
fields: ['id', 'name', 'code', 'workerFk', 'isProduction', 'chatName',
|
|
'isTeleworking', 'notificationEmail', 'hasToRefill', 'hasToSendMail', 'hasToMistake', 'clientFk'],
|
|
include: [
|
|
{relation: 'client',
|
|
scope: {
|
|
fields: ['id', 'name']
|
|
}},
|
|
{
|
|
relation: 'worker',
|
|
scope: {
|
|
fields: ['id', 'firstName', 'lastName']
|
|
}
|
|
}
|
|
]
|
|
};
|
|
|
|
return this.getData(`Departments/${this.id}`, {filter})
|
|
.then(res => this.entity = res.data);
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$element', '$scope', '$rootScope'];
|
|
|
|
ngModule.vnComponent('vnWorkerDepartmentDescriptor', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
department: '<'
|
|
}
|
|
});
|