Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Work End Date Can Be Set Before Work Start Date #8593

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/gauzy/src/app/pages/employees/employees.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export class EmployeesComponent extends PaginationFilterBaseComponent implements
const dialog = this._dialogService.open(EmployeeEndWorkComponent, {
context: {
endWorkValue: this.selectedEmployee.endWork,
startWorkValue: this.selectedEmployee.startedWorkOn,
employeeFullName: this.selectedEmployee.fullName
}
});
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/ach.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3683,6 +3683,9 @@
"ADD_AWARD": "تمت إضافة جائزة جديدة '{{ name }}'",
"INVALID_AWARD_NAME_YEAR": "يرجى التحقق من الاسم والسنة المدخلة للجائزة",
"REMOVE_AWARD": "تمت إزالة الجائزة '{{ name }}'"
},
"END_WORK": {
"DATE_CONFLICT": "تاريخ الانتهاء ({{ endDate }}) لا يمكن أن يكون قبل تاريخ البدء ({{ startDate }})."
}
},
"ORGANIZATIONS": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -3704,6 +3704,9 @@
"ADD_AWARD": "Новая награда '{{ name }}' была добавлена",
"INVALID_AWARD_NAME_YEAR": "Пожалуйста, проверьте имя и год для получения награды",
"REMOVE_AWARD": "Награда '{{ name }}' была удалена"
},
"END_WORK": {
"DATE_CONFLICT": "Дата окончания ({{ endDate }}) не может быть раньше даты начала ({{ startDate }})."
}
},
"ORGANIZATIONS": {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-core/i18n/assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -3685,6 +3685,9 @@
"ADD_AWARD": "新奖项'{{ name }}'已添加",
"INVALID_AWARD_NAME_YEAR": "请检查奖项输入的名称和年份。",
"REMOVE_AWARD": "奖项“{{ name }}”已被移除"
},
"END_WORK": {
"DATE_CONFLICT": "结束日期 ({{ endDate }}) 不能早于开始日期 ({{ startDate }})."
}
},
"ORGANIZATIONS": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@
<nb-card-header class="d-flex flex-column">
<span class="cancel"><i (click)="closeDialog()" class="fas fa-times"></i></span>
<h5 *ngIf="backToWork" class="title">
{{
employeeFullName.trim()
? employeeFullName
: ('POP_UPS.EMPLOYEE' | translate)
}}
{{ employeeFullName.trim() ? employeeFullName : ('POP_UPS.EMPLOYEE' | translate) }}
{{ 'POP_UPS.BACK_TO_WORK' | translate }}
</h5>
<h5 *ngIf="!backToWork" class="title">
{{ 'POP_UPS.END_WORK' | translate }}
{{
employeeFullName.trim()
? employeeFullName
: ('POP_UPS.EMPLOYEE' | translate)
}}
{{ employeeFullName.trim() ? employeeFullName : ('POP_UPS.EMPLOYEE' | translate) }}
</h5>
</nb-card-header>
<nb-card-body *ngIf="!backToWork">
Expand All @@ -29,6 +21,9 @@ <h5 *ngIf="!backToWork" class="title">
placeholder="{{ 'POP_UPS.PICK_DATE' | translate }}"
/>
<nb-datepicker #datepicker></nb-datepicker>
<div *ngIf="errorMessage" class="error-text">
{{ errorMessage }}
</div>
</div>
</div>
</nb-card-body>
Expand All @@ -37,12 +32,7 @@ <h5 *ngIf="!backToWork" class="title">
{{ 'BUTTONS.CANCEL' | translate }}
</button>
<button status="success" (click)="endWork()" nbButton>
{{
(backToWork
? 'EMPLOYEES_PAGE.BACK_TO_WORK'
: 'EMPLOYEES_PAGE.END_WORK'
) | translate
}}
{{ (backToWork ? 'EMPLOYEES_PAGE.BACK_TO_WORK' : 'EMPLOYEES_PAGE.END_WORK') | translate }}
</button>
</nb-card-footer>
</nb-card>
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<EmployeeEndWorkComponent>
) { }
constructor(
protected dialogRef: NbDialogRef<EmployeeEndWorkComponent>,
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());
}
}
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());
}
}
Loading