From 357c6e4c07a4a3ada0fa35f58d2ca1f29a14f7a4 Mon Sep 17 00:00:00 2001 From: samuelmbabhazi Date: Tue, 17 Dec 2024 13:28:04 +0200 Subject: [PATCH 1/2] Fix: Work End Date Can Be Set Before Work Start Date --- .../pages/employees/employees.component.ts | 3 ++ packages/ui-core/i18n/assets/i18n/ach.json | 3 ++ packages/ui-core/i18n/assets/i18n/ar.json | 3 ++ packages/ui-core/i18n/assets/i18n/bg.json | 3 ++ packages/ui-core/i18n/assets/i18n/de.json | 3 ++ packages/ui-core/i18n/assets/i18n/en.json | 3 ++ packages/ui-core/i18n/assets/i18n/es.json | 3 ++ packages/ui-core/i18n/assets/i18n/fr.json | 3 ++ packages/ui-core/i18n/assets/i18n/he.json | 3 ++ packages/ui-core/i18n/assets/i18n/it.json | 3 ++ packages/ui-core/i18n/assets/i18n/nl.json | 3 ++ packages/ui-core/i18n/assets/i18n/pl.json | 3 ++ packages/ui-core/i18n/assets/i18n/pt.json | 3 ++ packages/ui-core/i18n/assets/i18n/ru.json | 3 ++ packages/ui-core/i18n/assets/i18n/zh.json | 3 ++ .../employee-end-work.component.html | 22 +++----- .../employee-end-work.component.scss | 17 +++++-- .../employee-end-work.component.ts | 50 +++++++++++++------ 18 files changed, 97 insertions(+), 37 deletions(-) diff --git a/apps/gauzy/src/app/pages/employees/employees.component.ts b/apps/gauzy/src/app/pages/employees/employees.component.ts index 41be82c458e..133e5e14db9 100644 --- a/apps/gauzy/src/app/pages/employees/employees.component.ts +++ b/apps/gauzy/src/app/pages/employees/employees.component.ts @@ -371,10 +371,13 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements const { id: organizationId, tenantId } = this.organization; + console.log(this.selectedEmployee.endWork); + // Open the end work dialog const dialog = this._dialogService.open(EmployeeEndWorkComponent, { context: { endWorkValue: this.selectedEmployee.endWork, + startWorkValue: this.selectedEmployee.startedWorkOn, employeeFullName: this.selectedEmployee.fullName } }); diff --git a/packages/ui-core/i18n/assets/i18n/ach.json b/packages/ui-core/i18n/assets/i18n/ach.json index 0924ad35677..50bf4a48e50 100644 --- a/packages/ui-core/i18n/assets/i18n/ach.json +++ b/packages/ui-core/i18n/assets/i18n/ach.json @@ -3427,6 +3427,9 @@ "ADD_AWARD": "crwdns9176:0{{ name }}crwdne9176:0", "INVALID_AWARD_NAME_YEAR": "crwdns8006:0crwdne8006:0", "REMOVE_AWARD": "crwdns9178:0{{ name }}crwdne9178:0" + }, + "END_WORK": { + "DATE_CONFLICT": "Kare megi ({{ endDate }}) pe kany ni kede kare makare ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/ar.json b/packages/ui-core/i18n/assets/i18n/ar.json index 109ec2c712f..1c851a832db 100644 --- a/packages/ui-core/i18n/assets/i18n/ar.json +++ b/packages/ui-core/i18n/assets/i18n/ar.json @@ -3683,6 +3683,9 @@ "ADD_AWARD": "تمت إضافة جائزة جديدة '{{ name }}'", "INVALID_AWARD_NAME_YEAR": "يرجى التحقق من الاسم والسنة المدخلة للجائزة", "REMOVE_AWARD": "تمت إزالة الجائزة '{{ name }}'" + }, + "END_WORK": { + "DATE_CONFLICT": "تاريخ الانتهاء ({{ endDate }}) لا يمكن أن يكون قبل تاريخ البدء ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/bg.json b/packages/ui-core/i18n/assets/i18n/bg.json index ba1422b7cbf..412af7b6dd7 100644 --- a/packages/ui-core/i18n/assets/i18n/bg.json +++ b/packages/ui-core/i18n/assets/i18n/bg.json @@ -3734,6 +3734,9 @@ "ADD_AWARD": "New award '{{ name }}' was added", "INVALID_AWARD_NAME_YEAR": "Please check the Name and Year for Award input", "REMOVE_AWARD": "Award '{{ name }}' was removed" + }, + "END_WORK": { + "DATE_CONFLICT": "Крайната дата ({{ endDate }}) не може да бъде преди началната дата ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/de.json b/packages/ui-core/i18n/assets/i18n/de.json index 95beb071776..a70b1702a23 100644 --- a/packages/ui-core/i18n/assets/i18n/de.json +++ b/packages/ui-core/i18n/assets/i18n/de.json @@ -3681,6 +3681,9 @@ "ADD_AWARD": "Neue Auszeichnung '{{ name }}' wurde hinzugefügt.", "INVALID_AWARD_NAME_YEAR": "Bitte überprüfen Sie den eingegebenen Namen und das Jahr für die Auszeichnung.", "REMOVE_AWARD": "Auszeichnung '{{ name }}' wurde entfernt" + }, + "END_WORK": { + "DATE_CONFLICT": "Das Enddatum ({{ endDate }}) darf nicht vor dem Startdatum ({{ startDate }}) liegen." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/en.json b/packages/ui-core/i18n/assets/i18n/en.json index 218eb685cf4..9bf65294a58 100644 --- a/packages/ui-core/i18n/assets/i18n/en.json +++ b/packages/ui-core/i18n/assets/i18n/en.json @@ -3812,6 +3812,9 @@ "ADD_AWARD": "New award '{{ name }}' was added", "INVALID_AWARD_NAME_YEAR": "Please check the Name and Year for Award input", "REMOVE_AWARD": "Award '{{ name }}' was removed" + }, + "END_WORK": { + "DATE_CONFLICT": "The end date ({{ endDate }}) cannot be earlier than the start date ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/es.json b/packages/ui-core/i18n/assets/i18n/es.json index 927bb30523f..b72040a15b7 100644 --- a/packages/ui-core/i18n/assets/i18n/es.json +++ b/packages/ui-core/i18n/assets/i18n/es.json @@ -3687,6 +3687,9 @@ "ADD_AWARD": "Nuevo premio '{{ name }}' fue agregado.", "INVALID_AWARD_NAME_YEAR": "Por favor, verifica el nombre y el año de la entrada para el premio.", "REMOVE_AWARD": "El premio '{{ name }}' fue eliminado." + }, + "END_WORK": { + "DATE_CONFLICT": "La fecha de finalización ({{ endDate }}) no puede ser anterior a la fecha de inicio ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/fr.json b/packages/ui-core/i18n/assets/i18n/fr.json index 193d4065b8e..cb159f3cae4 100644 --- a/packages/ui-core/i18n/assets/i18n/fr.json +++ b/packages/ui-core/i18n/assets/i18n/fr.json @@ -3686,6 +3686,9 @@ "ADD_AWARD": "Nouveau prix '{{ name }}' a été ajouté", "INVALID_AWARD_NAME_YEAR": "Veuillez vérifier le nom et l'année pour l'entrée de récompense.", "REMOVE_AWARD": "Le prix '{{ name }}' a été supprimé." + }, + "END_WORK": { + "DATE_CONFLICT": "La date de fin ({{ endDate }}) ne peut pas être antérieure à la date de début ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/he.json b/packages/ui-core/i18n/assets/i18n/he.json index 0cddca52746..3c2c9002530 100644 --- a/packages/ui-core/i18n/assets/i18n/he.json +++ b/packages/ui-core/i18n/assets/i18n/he.json @@ -3698,6 +3698,9 @@ "ADD_AWARD": "New award '{{ name }}' was added", "INVALID_AWARD_NAME_YEAR": "Please check the Name and Year for Award input", "REMOVE_AWARD": "Award '{{ name }}' was removed" + }, + "END_WORK": { + "DATE_CONFLICT": "תאריך הסיום ({{ endDate }}) לא יכול להיות מוקדם מתאריך ההתחלה ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/it.json b/packages/ui-core/i18n/assets/i18n/it.json index 174c5ef9e47..f40b1fc5a4b 100644 --- a/packages/ui-core/i18n/assets/i18n/it.json +++ b/packages/ui-core/i18n/assets/i18n/it.json @@ -3685,6 +3685,9 @@ "ADD_AWARD": "Nuovo premio '{{ name }}' è stato aggiunto", "INVALID_AWARD_NAME_YEAR": "Si prega di verificare il Nome e l'Anno per l'inserimento del premio", "REMOVE_AWARD": "Il premio '{{ name }}' è stato rimosso" + }, + "END_WORK": { + "DATE_CONFLICT": "La data di fine ({{ endDate }}) non può essere precedente alla data di inizio ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/nl.json b/packages/ui-core/i18n/assets/i18n/nl.json index d2df6860bf4..d351ad364c7 100644 --- a/packages/ui-core/i18n/assets/i18n/nl.json +++ b/packages/ui-core/i18n/assets/i18n/nl.json @@ -3685,6 +3685,9 @@ "ADD_AWARD": "Nieuwe award '{{ name }}' is toegevoegd", "INVALID_AWARD_NAME_YEAR": "Controleer alstublieft de Naam en het Jaar voor de Award invoer.", "REMOVE_AWARD": "Prijs '{{ name }}' is verwijderd." + }, + "END_WORK": { + "DATE_CONFLICT": "De einddatum ({{ endDate }}) mag niet eerder zijn dan de startdatum ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/pl.json b/packages/ui-core/i18n/assets/i18n/pl.json index 80923029a1d..832cf1d7167 100644 --- a/packages/ui-core/i18n/assets/i18n/pl.json +++ b/packages/ui-core/i18n/assets/i18n/pl.json @@ -3685,6 +3685,9 @@ "ADD_AWARD": "Nowa nagroda '{{ name }}' została dodana", "INVALID_AWARD_NAME_YEAR": "Proszę sprawdzić wprowadzone imię, nazwisko oraz rok otrzymania nagrody", "REMOVE_AWARD": "Nagroda '{{ name }}' została usunięta" + }, + "END_WORK": { + "DATE_CONFLICT": "Data zakończenia ({{ endDate }}) nie może być wcześniejsza niż data rozpoczęcia ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/pt.json b/packages/ui-core/i18n/assets/i18n/pt.json index f2e4e066e31..59ba71099a0 100644 --- a/packages/ui-core/i18n/assets/i18n/pt.json +++ b/packages/ui-core/i18n/assets/i18n/pt.json @@ -3685,6 +3685,9 @@ "ADD_AWARD": "Novo prêmio '{{ name }}' foi adicionado.", "INVALID_AWARD_NAME_YEAR": "Por favor, verifique o nome e o ano do prêmio inserido.", "REMOVE_AWARD": "O prêmio '{{ name }}' foi removido." + }, + "END_WORK": { + "DATE_CONFLICT": "A data de término ({{ endDate }}) não pode ser anterior à data de início ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/ru.json b/packages/ui-core/i18n/assets/i18n/ru.json index 72f68c6c2f1..2676b116ef9 100644 --- a/packages/ui-core/i18n/assets/i18n/ru.json +++ b/packages/ui-core/i18n/assets/i18n/ru.json @@ -3704,6 +3704,9 @@ "ADD_AWARD": "Новая награда '{{ name }}' была добавлена", "INVALID_AWARD_NAME_YEAR": "Пожалуйста, проверьте имя и год для получения награды", "REMOVE_AWARD": "Награда '{{ name }}' была удалена" + }, + "END_WORK": { + "DATE_CONFLICT": "Дата окончания ({{ endDate }}) не может быть раньше даты начала ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/i18n/assets/i18n/zh.json b/packages/ui-core/i18n/assets/i18n/zh.json index b8e61bfd313..9577745e267 100644 --- a/packages/ui-core/i18n/assets/i18n/zh.json +++ b/packages/ui-core/i18n/assets/i18n/zh.json @@ -3685,6 +3685,9 @@ "ADD_AWARD": "新奖项'{{ name }}'已添加", "INVALID_AWARD_NAME_YEAR": "请检查奖项输入的名称和年份。", "REMOVE_AWARD": "奖项“{{ name }}”已被移除" + }, + "END_WORK": { + "DATE_CONFLICT": "结束日期 ({{ endDate }}) 不能早于开始日期 ({{ startDate }})." } }, "ORGANIZATIONS": { diff --git a/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.html b/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.html index 51af62dd571..756b9fb678a 100644 --- a/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.html +++ b/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.html @@ -2,20 +2,12 @@
- {{ - employeeFullName.trim() - ? employeeFullName - : ('POP_UPS.EMPLOYEE' | translate) - }} + {{ employeeFullName.trim() ? employeeFullName : ('POP_UPS.EMPLOYEE' | translate) }} {{ 'POP_UPS.BACK_TO_WORK' | translate }}
{{ 'POP_UPS.END_WORK' | translate }} - {{ - employeeFullName.trim() - ? employeeFullName - : ('POP_UPS.EMPLOYEE' | translate) - }} + {{ employeeFullName.trim() ? employeeFullName : ('POP_UPS.EMPLOYEE' | translate) }}
@@ -29,6 +21,9 @@
placeholder="{{ 'POP_UPS.PICK_DATE' | translate }}" /> +
+ {{ errorMessage }} +
@@ -37,12 +32,7 @@
{{ 'BUTTONS.CANCEL' | translate }} diff --git a/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.scss b/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.scss index d9a4697f3c4..9f15f5e6d66 100644 --- a/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.scss +++ b/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.scss @@ -1,9 +1,16 @@ @import 'gauzy/_gauzy-dialogs'; nb-card { - width: 375px; - nb-card-footer{ - display: flex; - gap: 1rem; - } + width: 375px; + nb-card-footer { + display: flex; + gap: 1rem; + } +} +.error-text { + margin: 0; + color: red; + font-size: 0.75rem; + font-weight: 300; + line-height: initial; } diff --git a/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.ts b/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.ts index a65748a6709..3ded049ff99 100644 --- a/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.ts +++ b/packages/ui-core/shared/src/lib/employee/employee-end-work-popup/employee-end-work.component.ts @@ -1,25 +1,43 @@ +import { DatePipe } from '@angular/common'; import { Component } from '@angular/core'; import { NbDialogRef } from '@nebular/theme'; +import { TranslateService } from '@ngx-translate/core'; @Component({ - selector: 'ga-employee-end-work', - templateUrl: 'employee-end-work.component.html', - styleUrls: ['employee-end-work.component.scss'], + selector: 'ga-employee-end-work', + templateUrl: 'employee-end-work.component.html', + styleUrls: ['employee-end-work.component.scss'] }) export class EmployeeEndWorkComponent { - backToWork: boolean; - endWorkValue: Date; - employeeFullName: string; + backToWork: boolean; + endWorkValue: Date; + startWorkValue: Date; + employeeFullName: string; + errorMessage: string | null = null; - constructor( - protected dialogRef: NbDialogRef - ) { } + constructor( + protected dialogRef: NbDialogRef, + private datePipe: DatePipe, + private translate: TranslateService + ) {} - closeDialog() { - this.dialogRef.close(); - } + closeDialog() { + this.dialogRef.close(); + } + endWork() { + const formattedStartDate = this.datePipe.transform(this.startWorkValue, 'yyyy-MM-dd'); + const formattedEndDate = this.datePipe.transform(this.endWorkValue, 'yyyy-MM-dd'); - endWork() { - this.dialogRef.close(this.endWorkValue || new Date()); - } -} \ No newline at end of file + if (formattedEndDate && formattedStartDate && formattedEndDate < formattedStartDate) { + this.translate + .get('NOTES.EMPLOYEE.END_WORK.DATE_CONFLICT', { endDate: formattedEndDate, startDate: formattedStartDate }) + .subscribe((translatedMessage: string) => { + this.errorMessage = translatedMessage; + }); + return; + } + + this.errorMessage = null; + this.dialogRef.close(this.endWorkValue || new Date()); + } +} From c4421b1b84a9c7aa18958e332b38240500fc06c9 Mon Sep 17 00:00:00 2001 From: samuelmbabhazi Date: Tue, 17 Dec 2024 13:46:23 +0200 Subject: [PATCH 2/2] Remove console log --- apps/gauzy/src/app/pages/employees/employees.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/gauzy/src/app/pages/employees/employees.component.ts b/apps/gauzy/src/app/pages/employees/employees.component.ts index 133e5e14db9..0503c04358e 100644 --- a/apps/gauzy/src/app/pages/employees/employees.component.ts +++ b/apps/gauzy/src/app/pages/employees/employees.component.ts @@ -371,8 +371,6 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements const { id: organizationId, tenantId } = this.organization; - console.log(this.selectedEmployee.endWork); - // Open the end work dialog const dialog = this._dialogService.open(EmployeeEndWorkComponent, { context: {