From 4a7cfe912204156944dc354db1eb256ef101bfb6 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 11:51:15 +0200 Subject: [PATCH 1/4] fix: workCenter --- modules/worker/front/calendar/index.html | 142 ++++++------ modules/worker/front/calendar/index.js | 7 +- modules/worker/front/card/index.js | 15 +- modules/worker/front/time-control/index.html | 222 ++++++++++--------- modules/worker/front/time-control/index.js | 6 +- 5 files changed, 201 insertions(+), 191 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 877add57b..d264e0ebc 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -1,9 +1,9 @@ - - -
+
+ +
-
-
- Autonomous worker -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.businessId}}
-
- {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} + +
+
+
{{'Contract' | translate}} #{{$ctrl.businessId}}
+
+ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} +
+
+ {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} +
-
- {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} -
-
-
-
{{'Year' | translate}} {{$ctrl.year}}
-
- {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
{{'Year' | translate}} {{$ctrl.year}}
+
+ {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} +
-
- {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} -
-
-
- + - - + +
- - - - {{absenceType.name}} - -
-
- - - - Festive - - - - - Current day - -
+ ng-click="$ctrl.pick(absenceType)"> + + + + {{absenceType.name}} +
- - - +
+ + + + Festive + + + + + Current day + +
+
+
+ + +
+
+ Autonomous worker +
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/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/time-control/index.html b/modules/worker/front/time-control/index.html index 5f0855ee6..5d8d2c503 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"> -
+
@@ -105,118 +105,120 @@ ng-show="::$ctrl.isHr"> + + + +
+
+
Hours
+ + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + Are you sure you want to send it? + + + + + +
Autonomous worker
- - -
-
-
Hours
- - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - Are you sure you want to send it? - - - - - - diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 90ec33293..38e6721d6 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -141,6 +141,8 @@ class Controller extends Section { ]} }; this.$.model.applyFilter(filter, params).then(() => { + 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' } }); From 4f183d1c6a6d52d2cf4f55b7b15baff616e3c830 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 12:18:41 +0200 Subject: [PATCH 2/4] fix: worker.basic-data el boton guardar estava activo al hacer F5 --- db/changes/232802/01-aclAddAlias.sql | 4 +++ modules/worker/front/descriptor/index.html | 37 +++++++++------------- modules/worker/front/descriptor/index.js | 25 +++++---------- 3 files changed, 27 insertions(+), 39 deletions(-) create mode 100644 db/changes/232802/01-aclAddAlias.sql diff --git a/db/changes/232802/01-aclAddAlias.sql b/db/changes/232802/01-aclAddAlias.sql new file mode 100644 index 000000000..149dd6f15 --- /dev/null +++ b/db/changes/232802/01-aclAddAlias.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/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() { From 5716acaa3c94b9396553acac874bd9cb58d5c39c Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 13:01:31 +0200 Subject: [PATCH 3/4] fix: test --- modules/worker/front/calendar/index.html | 174 +++++++------- modules/worker/front/calendar/index.spec.js | 5 +- modules/worker/front/time-control/index.html | 219 +++++++++--------- .../worker/front/time-control/index.spec.js | 5 +- 4 files changed, 202 insertions(+), 201 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index d264e0ebc..1b0560185 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -1,9 +1,9 @@ + +
- -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.businessId}}
-
- {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} -
-
- -
-
{{'Year' | translate}} {{$ctrl.year}}
-
- {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- -
- - - - -
#{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}} -
-
-
-
-
- - - - - {{absenceType.name}} - -
-
- - - - Festive - - - - - Current day - -
-
-
- -
Autonomous worker
+ +
+
+
{{'Contract' | translate}} #{{$ctrl.businessId}}
+
+ {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} +
+
+ {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} +
+
+
+
{{'Year' | translate}} {{$ctrl.year}}
+
+ {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} +
+
+ {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} + {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} +
+
+ +
+ + + + +
#{{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.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/time-control/index.html b/modules/worker/front/time-control/index.html index 5d8d2c503..760b0dafc 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -105,116 +105,6 @@ ng-show="::$ctrl.isHr"> - - - -
-
-
Hours
- - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - Are you sure you want to send it? - - - - - -
Autonomous worker
+ + +
+
+
Hours
+ + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + Are you sure you want to send it? + + + + + + 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 }; })); From 6980392ba1a44925b198806c4ec80ee31803a5f1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 14 Jul 2023 13:11:09 +0200 Subject: [PATCH 4/4] fix: tabulacion --- ...clAddAlias.sql => 01-aclWorkerDisable.sql} | 0 modules/worker/front/calendar/index.html | 24 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) rename db/changes/232802/{01-aclAddAlias.sql => 01-aclWorkerDisable.sql} (100%) diff --git a/db/changes/232802/01-aclAddAlias.sql b/db/changes/232802/01-aclWorkerDisable.sql similarity index 100% rename from db/changes/232802/01-aclAddAlias.sql rename to db/changes/232802/01-aclWorkerDisable.sql diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 1b0560185..08f63ddf9 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -59,20 +59,20 @@
+ url="Workers/{{$ctrl.$params.id}}/contracts" + fields="['started', 'ended']" + ng-model="$ctrl.businessId" + search-function="{businessFk: $search}" + value-field="businessFk" + order="businessFk DESC" + limit="5">
#{{businessFk}}
@@ -82,10 +82,8 @@
- - + + {{absenceType.name}}