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

68 lines
1.8 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;
}
2023-05-30 11:21:57 +00:00
2023-05-30 13:13:16 +00:00
filterDepartments(department, event) {
if (event.defaultPrevented) return;
event.preventDefault();
event.stopPropagation();
this.$state.go(`worker.index`,
{q: JSON.stringify({departmentFk: department.id})});
}
2023-05-31 10:02:22 +00:00
2023-05-30 11:21:57 +00:00
deleteDepartment() {
2023-05-31 10:02:22 +00:00
return this.$http.delete(`Departments/${this.id}`)
2023-05-30 11:21:57 +00:00
.then(() => {
2023-05-31 10:02:22 +00:00
this.$state.go('worker.department');
2023-05-30 11:21:57 +00:00
this.vnApp.showSuccess(this.$t('Department deleted.'));
});
}
2023-08-01 08:25:44 +00:00
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);
}
2023-05-15 11:15:33 +00:00
}
Controller.$inject = ['$element', '$scope', '$rootScope'];
ngModule.vnComponent('vnWorkerDepartmentDescriptor', {
template: require('./index.html'),
controller: Controller,
bindings: {
department: '<'
2023-05-15 11:15:33 +00:00
}
});