diff --git a/db/changes/232802/01-aclWorkerDisable.sql b/db/changes/232802/01-aclWorkerDisable.sql
new file mode 100644
index 000000000..149dd6f15
--- /dev/null
+++ b/db/changes/232802/01-aclWorkerDisable.sql
@@ -0,0 +1,4 @@
+INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
+ VALUES
+ ('WorkerDisableExcluded', '*', 'READ', 'ALLOW', 'ROLE', 'itManagement'),
+ ('WorkerDisableExcluded', '*', 'WRITE', 'ALLOW', 'ROLE', 'itManagement');
diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html
index 877add57b..08f63ddf9 100644
--- a/modules/worker/front/calendar/index.html
+++ b/modules/worker/front/calendar/index.html
@@ -3,7 +3,7 @@
data="absenceTypes"
auto-load="true">
-
+
Autonomous worker
@@ -73,41 +73,39 @@
value-field="businessFk"
order="businessFk DESC"
limit="5">
-
- #{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
-
-
-
-
-
-
-
-
-
- {{absenceType.name}}
-
-
-
-
-
-
- Festive
-
-
-
-
- Current day
-
-
+
+ #{{businessFk}}
+
+ {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}}
+
+
+
+
+
+
+
+
+ {{absenceType.name}}
+
+
+
+
+
+
+ Festive
+
+
+
+
+ Current day
+
+
+
+
-
diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js
index 87e806cc3..5606ad0ce 100644
--- a/modules/worker/front/calendar/index.js
+++ b/modules/worker/front/calendar/index.js
@@ -31,6 +31,8 @@ class Controller extends Section {
}
set businessId(value) {
+ if (!this.card.hasWorkCenter) return;
+
this._businessId = value;
if (value) {
this.refresh()
@@ -64,7 +66,7 @@ class Controller extends Section {
set worker(value) {
this._worker = value;
- if (value && value.hasWorkCenter) {
+ if (value) {
this.getIsSubordinate();
this.getActiveContract();
}
@@ -293,5 +295,8 @@ ngModule.vnComponent('vnWorkerCalendar', {
controller: Controller,
bindings: {
worker: '<'
+ },
+ require: {
+ card: '^vnWorkerCard'
}
});
diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js
index 4b78d883b..5d7ae0795 100644
--- a/modules/worker/front/calendar/index.spec.js
+++ b/modules/worker/front/calendar/index.spec.js
@@ -20,6 +20,9 @@ describe('Worker', () => {
controller.absenceType = {id: 1, name: 'Holiday', code: 'holiday', rgb: 'red'};
controller.$params.id = 1106;
controller._worker = {id: 1106};
+ controller.card = {
+ hasWorkCenter: true
+ };
}));
describe('year() getter', () => {
@@ -74,7 +77,7 @@ describe('Worker', () => {
let yesterday = new Date(today.getTime());
yesterday.setDate(yesterday.getDate() - 1);
- controller.worker = {id: 1107, hasWorkCenter: true};
+ controller.worker = {id: 1107};
expect(controller.getIsSubordinate).toHaveBeenCalledWith();
expect(controller.getActiveContract).toHaveBeenCalledWith();
diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js
index 35f331764..0bf9ae5c4 100644
--- a/modules/worker/front/card/index.js
+++ b/modules/worker/front/card/index.js
@@ -3,7 +3,7 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
- let filter = {
+ const filter = {
include: [
{
relation: 'user',
@@ -32,13 +32,12 @@ class Controller extends ModuleCard {
]
};
- this.$http.get(`Workers/${this.$params.id}`, {filter})
- .then(res => this.worker = res.data)
- .then(() =>
- this.$http.get(`Workers/${this.$params.id}/activeContract`)
- .then(res => {
- if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk;
- }));
+ return Promise.all([
+ this.$http.get(`Workers/${this.$params.id}`, {filter})
+ .then(res => this.worker = res.data),
+ this.$http.get(`Workers/${this.$params.id}/activeContract`)
+ .then(res => this.hasWorkCenter = res.data.workCenterFk)
+ ]);
}
}
diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html
index 58ac3d9e6..ea005e1a2 100644
--- a/modules/worker/front/descriptor/index.html
+++ b/modules/worker/front/descriptor/index.html
@@ -5,8 +5,8 @@
-
- Click to exclude the user from getting disabled
-
-
- Click to allow the user to be disabled
-
+
+ {{$ctrl.workerExcluded
+ ? 'Click to allow the user to be disabled'
+ : 'Click to exclude the user from getting disabled'}}
+
@@ -84,7 +77,7 @@
-
-
\ No newline at end of file
+
diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js
index ef2f64e85..a53528ef2 100644
--- a/modules/worker/front/descriptor/index.js
+++ b/modules/worker/front/descriptor/index.js
@@ -18,28 +18,19 @@ class Controller extends Descriptor {
this.getIsExcluded();
}
- get excluded() {
- return this.entity.excluded;
- }
-
- set excluded(value) {
- this.entity.excluded = value;
- }
-
getIsExcluded() {
- this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
- this.excluded = data.data.exists;
+ this.$http.get(`WorkerDisableExcludeds/${this.entity.id}/exists`).then(data => {
+ this.workerExcluded = data.data.exists;
});
}
handleExcluded() {
- if (this.excluded) {
- this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
- this.excluded = false;
- } else {
- this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
- this.excluded = true;
- }
+ if (this.workerExcluded)
+ this.$http.delete(`WorkerDisableExcludeds/${this.entity.id}`);
+ else
+ this.$http.post(`WorkerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
+
+ this.workerExcluded = !this.workerExcluded;
}
loadData() {
diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html
index 5f0855ee6..760b0dafc 100644
--- a/modules/worker/front/time-control/index.html
+++ b/modules/worker/front/time-control/index.html
@@ -4,7 +4,7 @@
filter="::$ctrl.filter"
data="$ctrl.hours">
-
+
@@ -107,7 +107,7 @@
Autonomous worker
@@ -136,6 +136,7 @@
+
{
+ if (!this.card.hasWorkCenter) return;
+
this.getWorkedHours(this.started, this.ended);
this.getAbsences();
});
@@ -151,7 +153,6 @@ class Controller extends Section {
}
getAbsences() {
- if (!this.worker.hasWorkerCenter) return;
const fullYear = this.started.getFullYear();
let params = {
workerFk: this.$params.id,
@@ -486,5 +487,8 @@ ngModule.vnComponent('vnWorkerTimeControl', {
controller: Controller,
bindings: {
worker: '<'
+ },
+ require: {
+ card: '^vnWorkerCard'
}
});
diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js
index 0132f50fe..6d8510ba8 100644
--- a/modules/worker/front/time-control/index.spec.js
+++ b/modules/worker/front/time-control/index.spec.js
@@ -16,9 +16,8 @@ describe('Component vnWorkerTimeControl', () => {
$scope = $rootScope.$new();
$element = angular.element('');
controller = $componentController('vnWorkerTimeControl', {$element, $scope});
- controller.worker = {
- hasWorkerCenter: true
-
+ controller.card = {
+ hasWorkCenter: true
};
}));