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-05-15 11:15:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$element', '$scope', '$rootScope'];
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnWorkerDepartmentDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2023-05-30 07:16:02 +00:00
|
|
|
department: '<'
|
2023-05-15 11:15:33 +00:00
|
|
|
}
|
|
|
|
});
|