From d5aae8f824562074ca7693c0669227b489e1d784 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 31 May 2023 14:53:31 +0200 Subject: [PATCH 1/8] refs #5688 refactor: muestra un mensaje de error controlado --- loopback/locale/es.json | 5 +++-- modules/worker/back/methods/calendar/absences.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d88a4ebc95..56ecb741fb 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -84,7 +84,7 @@ "The current ticket can't be modified": "El ticket actual no puede ser modificado", "The current claim can't be modified": "La reclamación actual no puede ser modificada", "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", "Please select at least one sale": "Por favor selecciona al menos una linea", "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", @@ -293,5 +293,6 @@ "comercialName": "Comercial", "Invalid NIF for VIES": "Invalid NIF for VIES", "Ticket does not exist": "Este ticket no existe", - "Ticket is already signed": "Este ticket ya ha sido firmado" + "Ticket is already signed": "Este ticket ya ha sido firmado", + "This worker does not have a work center": "Este trabajador no tiene centro de trabajo" } diff --git a/modules/worker/back/methods/calendar/absences.js b/modules/worker/back/methods/calendar/absences.js index 8420ed7705..e78e49698d 100644 --- a/modules/worker/back/methods/calendar/absences.js +++ b/modules/worker/back/methods/calendar/absences.js @@ -117,7 +117,10 @@ module.exports = Self => { absences.push(absence); } - for (let day of contract.workCenter().holidays()) { + const workCenter = contract.workCenter(); + if (!workCenter) throw new UserError(`This worker does not have a work center`); + + for (let day of workCenter.holidays()) { day.dated = new Date(day.dated); day.dated.setHours(0, 0, 0, 0); From b7b6f413ba45e66f32e080d6022998cc5c1eb326 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 15 Jun 2023 14:15:22 +0200 Subject: [PATCH 2/8] refs #5688 feat: no mostrar datos si no tiene workerCenterFk --- modules/worker/front/calendar/index.html | 214 +++++----- modules/worker/front/calendar/index.js | 3 +- modules/worker/front/calendar/locale/es.yml | 3 +- modules/worker/front/card/index.js | 2 + modules/worker/front/time-control/index.html | 406 ++++++++++--------- modules/worker/front/time-control/index.js | 4 + 6 files changed, 327 insertions(+), 305 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index c9eacbd82b..78d4832c88 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -1,104 +1,112 @@ - - -
- - - - - - -
- -
-
-
{{'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 - -
+
+ + +
+ + + + + +
- - - + +
+
+
{{'Contract' | translate}} #{{$ctrl.card.worker.hasWorkCenter}}
+
+ {{'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 +
diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 4ca0fc9297..4b07a2e98a 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -64,8 +64,7 @@ class Controller extends Section { set worker(value) { this._worker = value; - - if (value) { + if (value && value.hasWorkCenter) { this.getIsSubordinate(); this.getActiveContract(); } diff --git a/modules/worker/front/calendar/locale/es.yml b/modules/worker/front/calendar/locale/es.yml index bd75458aab..50bb4bb526 100644 --- a/modules/worker/front/calendar/locale/es.yml +++ b/modules/worker/front/calendar/locale/es.yml @@ -11,4 +11,5 @@ Choose an absence type from the right menu: Elige un tipo de ausencia desde el m To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia You can just add absences within the current year: Solo puedes añadir ausencias dentro del año actual Current day: Día actual -Paid holidays: Vacaciones pagadas \ No newline at end of file +Paid holidays: Vacaciones pagadas +Autonomous worker: Trabajador autónomo diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 415b607874..dacdc954ad 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -34,6 +34,8 @@ class Controller extends ModuleCard { 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.worker.hasWorkCenter = res.data.workCenterFk); } } diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index 044ea4038a..d3a4b5640d 100644 --- a/modules/worker/front/time-control/index.html +++ b/modules/worker/front/time-control/index.html @@ -4,211 +4,219 @@ filter="::$ctrl.filter" data="$ctrl.hours"> - - - - - -
{{::$ctrl.weekdayNames[$index].name}}
-
- {{::weekday.dated | date: 'dd'}} - - {{::weekday.dated | date: 'MMMM'}} - -
- - - +
+ + + + + +
{{::$ctrl.weekdayNames[$index].name}}
- {{::weekday.event.name}} + {{::weekday.dated | date: 'dd'}} + + {{::weekday.dated | date: 'MMMM'}} +
- -
-
-
- - - -
- - - - - - - {{::hour.timed | date: 'HH:mm'}} + title="{{::weekday.event.name}}" + ng-class="{invisible: !weekday.event}"> + + +
+ {{::weekday.event.name}} +
-
-
-
-
- - - - {{$ctrl.formatHours(weekday.workedHours)}} h. - - - - - - - - - -
-
+ + + + + + +
+ + + + + + + + {{::hour.timed | date: 'HH:mm'}} + +
+
+
+
+ + + + {{$ctrl.formatHours(weekday.workedHours)}} h. + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - -
-
-
Hours
- - - - + +
+
+
Hours
+ + + + +
+ +
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- + + + - -
-
- - - - -
+ + + + + + + + + + + - - - Are you sure you want to send it? - - - - - - + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + Are you sure you want to send it? + + + + + + +
+
+ Autonomous worker +
diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 85ddcedfe6..0f62085e35 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -151,6 +151,7 @@ class Controller extends Section { } getAbsences() { + if (!this.card.worker.hasWorkerCenter) return; const fullYear = this.started.getFullYear(); let params = { workerFk: this.$params.id, @@ -485,5 +486,8 @@ ngModule.vnComponent('vnWorkerTimeControl', { controller: Controller, bindings: { worker: '<' + }, + require: { + card: '^vnWorkerCard' } }); From 55990869e2bfc87ca44815e33342b0c4486fcc2d Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 15 Jun 2023 14:16:26 +0200 Subject: [PATCH 3/8] refs #5688 ya no muestra mensaje de error --- loopback/locale/es.json | 3 +-- modules/worker/back/methods/calendar/absences.js | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 768a36297b..d352319144 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -293,6 +293,5 @@ "Pass expired": "La contraseña ha caducado, cambiela desde Salix", "Invalid NIF for VIES": "Invalid NIF for VIES", "Ticket does not exist": "Este ticket no existe", - "Ticket is already signed": "Este ticket ya ha sido firmado", - "This worker does not have a work center": "Este trabajador no tiene centro de trabajo" + "Ticket is already signed": "Este ticket ya ha sido firmado" } diff --git a/modules/worker/back/methods/calendar/absences.js b/modules/worker/back/methods/calendar/absences.js index e78e49698d..8420ed7705 100644 --- a/modules/worker/back/methods/calendar/absences.js +++ b/modules/worker/back/methods/calendar/absences.js @@ -117,10 +117,7 @@ module.exports = Self => { absences.push(absence); } - const workCenter = contract.workCenter(); - if (!workCenter) throw new UserError(`This worker does not have a work center`); - - for (let day of workCenter.holidays()) { + for (let day of contract.workCenter().holidays()) { day.dated = new Date(day.dated); day.dated.setHours(0, 0, 0, 0); From 5f4b62f133754dd6aa2a9974df03b063323e2ebe Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Jun 2023 09:48:14 +0200 Subject: [PATCH 4/8] refs #5688 fix: test front --- modules/worker/front/calendar/index.spec.js | 2 +- modules/worker/front/time-control/index.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js index 586a7223d2..4b78d883b7 100644 --- a/modules/worker/front/calendar/index.spec.js +++ b/modules/worker/front/calendar/index.spec.js @@ -74,7 +74,7 @@ describe('Worker', () => { let yesterday = new Date(today.getTime()); yesterday.setDate(yesterday.getDate() - 1); - controller.worker = {id: 1107}; + controller.worker = {id: 1107, hasWorkCenter: true}; expect(controller.getIsSubordinate).toHaveBeenCalledWith(); expect(controller.getActiveContract).toHaveBeenCalledWith(); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 94f9d3d485..445ddeecd5 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -16,6 +16,12 @@ describe('Component vnWorkerTimeControl', () => { $scope = $rootScope.$new(); $element = angular.element(''); controller = $componentController('vnWorkerTimeControl', {$element, $scope}); + controller.card = { + worker: { + hasWorkerCenter: true + } + + }; })); describe('date() setter', () => { From d26778e94e8dbe2160a071cc3b7ed654d9f73595 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Jun 2023 13:30:53 +0200 Subject: [PATCH 5/8] refs #5688 fix: e2e --- modules/worker/front/time-control/index.html | 218 +++++++++---------- modules/worker/front/time-control/index.js | 5 +- 2 files changed, 110 insertions(+), 113 deletions(-) diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html index d3a4b5640d..5f0855ee63 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,114 +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.js b/modules/worker/front/time-control/index.js index 0f62085e35..90ec33293d 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -151,7 +151,7 @@ class Controller extends Section { } getAbsences() { - if (!this.card.worker.hasWorkerCenter) return; + if (!this.worker.hasWorkerCenter) return; const fullYear = this.started.getFullYear(); let params = { workerFk: this.$params.id, @@ -486,8 +486,5 @@ ngModule.vnComponent('vnWorkerTimeControl', { controller: Controller, bindings: { worker: '<' - }, - require: { - card: '^vnWorkerCard' } }); From d272121258ae9c373fc9c88ae80a93dc550444b8 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Jun 2023 14:52:42 +0200 Subject: [PATCH 6/8] refs 5688 fix: e2e --- modules/worker/front/calendar/index.html | 175 ++++++++++++----------- 1 file changed, 88 insertions(+), 87 deletions(-) diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html index 78d4832c88..ace2f4e276 100644 --- a/modules/worker/front/calendar/index.html +++ b/modules/worker/front/calendar/index.html @@ -1,9 +1,9 @@ + +
- -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.card.worker.hasWorkCenter}}
-
- {{'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.card.worker.hasWorkCenter}}
+
+ {{'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 + +
+
+
+ + + From d9b1f4b8a1e0a19ed22d7f31955837a6a0f8fb95 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Jun 2023 15:06:27 +0200 Subject: [PATCH 7/8] refs #5688 fix: test e2e --- modules/worker/front/card/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index dacdc954ad..e1eb97327b 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -35,7 +35,9 @@ class Controller extends ModuleCard { 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.worker.hasWorkCenter = res.data.workCenterFk); + .then(res => { + if (res.data) this.worker.hasWorkCenter = res.data.workCenterFk; + }); } } From 6894da7e2216a36e814dcc195cd1067d660ab41f Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 28 Jun 2023 13:27:18 +0200 Subject: [PATCH 8/8] refs #5688 fix: front test --- modules/worker/front/time-control/index.spec.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 445ddeecd5..0132f50fe1 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -16,10 +16,8 @@ describe('Component vnWorkerTimeControl', () => { $scope = $rootScope.$new(); $element = angular.element(''); controller = $componentController('vnWorkerTimeControl', {$element, $scope}); - controller.card = { - worker: { - hasWorkerCenter: true - } + controller.worker = { + hasWorkerCenter: true }; }));