Skip to content

Commit 02bbf9a

Browse files
committed
WEB-389: Fix date format issue when editing holidays
Fixed two issues in the holiday management feature: 1. Date Formatting Error: - Changed from formatDate() to formatDateAsString() to properly handle Java date format patterns (e.g., 'dd MMMM yyyy') - formatDate() uses Angular DatePipe which doesn't understand Java patterns - formatDateAsString() uses moment.js which correctly handles Java patterns - Applied fix to both edit and create holiday components 2. Submit Button Not Responding: - Added type='submit' attribute to submit button in edit-holiday template - This ensures the form's (ngSubmit) event is properly triggered Files modified: - src/app/organization/holidays/edit-holiday/edit-holiday.component.ts - src/app/organization/holidays/edit-holiday/edit-holiday.component.html - src/app/organization/holidays/create-holiday/create-holiday.component.ts
1 parent 5ff63d4 commit 02bbf9a

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

src/app/organization/holidays/create-holiday/create-holiday.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,14 @@ export class CreateHolidayComponent implements OnInit {
332332
const locale = this.settings.language.code;
333333
const prevFromDate: Date = this.holidayForm.value.fromDate;
334334
const prevToDate: Date = this.holidayForm.value.toDate;
335-
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
336-
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
335+
holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
336+
holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
337337
if (this.holidayForm.contains('repaymentsRescheduledTo')) {
338338
const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
339-
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat);
339+
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(
340+
prevRepaymentsRescheduledTo,
341+
dateFormat
342+
);
340343
}
341344
const offices = this.holidayForm.value.offices.map((office: string) => {
342345
return { officeId: Number.parseInt(office, 10) };

src/app/organization/holidays/edit-holiday/edit-holiday.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
{{ 'labels.buttons.Cancel' | translate }}
9292
</button>
9393
<button
94+
type="submit"
9495
mat-raised-button
9596
color="primary"
9697
[disabled]="!holidayForm.valid"

src/app/organization/holidays/edit-holiday/edit-holiday.component.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,20 @@ export class EditHolidayComponent implements OnInit {
134134
const locale = this.settingsService.language.code;
135135
const dateFormat = this.settingsService.dateFormat;
136136
if (!this.isActiveHoliday) {
137-
if (this.reSchedulingType === 2) {
138-
const repaymentScheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
139-
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(repaymentScheduledTo, dateFormat);
140-
}
141137
const prevFromDate: Date = this.holidayForm.value.fromDate;
142138
const prevToDate: Date = this.holidayForm.value.toDate;
143-
if (holidayFormData.closureDate instanceof Date) {
144-
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
139+
140+
if (prevFromDate instanceof Date) {
141+
holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
145142
}
146-
if (holidayFormData.closureDate instanceof Date) {
147-
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
143+
if (prevToDate instanceof Date) {
144+
holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
145+
}
146+
if (this.reSchedulingType === 2) {
147+
const repaymentScheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
148+
if (repaymentScheduledTo instanceof Date) {
149+
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(repaymentScheduledTo, dateFormat);
150+
}
148151
}
149152
}
150153
const data = {

0 commit comments

Comments
 (0)