Skip to content

Commit 727951f

Browse files
committed
WEB-389: Fix date format issue when editing holidays
- Changed formatDate() to formatDateAsString() to properly handle Java date format patterns - Added type='submit' attribute to submit button to enable form submission - Applied fix to both edit and create holiday components for consistency
1 parent 3b5a68b commit 727951f

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,23 @@ export class CreateHolidayComponent implements OnInit {
330330
const holidayFormData = this.holidayForm.value;
331331
const dateFormat = this.settings.dateFormat;
332332
const locale = this.settings.language.code;
333-
const prevFromDate: Date = this.holidayForm.value.fromDate;
334-
const prevToDate: Date = this.holidayForm.value.toDate;
335-
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
336-
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
333+
const prevFromDate = this.holidayForm.value.fromDate;
334+
const prevToDate = this.holidayForm.value.toDate;
335+
336+
if (prevFromDate instanceof Date) {
337+
holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
338+
}
339+
if (prevToDate instanceof Date) {
340+
holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
341+
}
337342
if (this.holidayForm.contains('repaymentsRescheduledTo')) {
338-
const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo;
339-
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat);
343+
const prevRepaymentsRescheduledTo = this.holidayForm.value.repaymentsRescheduledTo;
344+
if (prevRepaymentsRescheduledTo instanceof Date) {
345+
holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(
346+
prevRepaymentsRescheduledTo,
347+
dateFormat
348+
);
349+
}
340350
}
341351
const offices = this.holidayForm.value.offices.map((office: string) => {
342352
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: 12 additions & 9 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);
137+
const prevFromDate = this.holidayForm.value.fromDate;
138+
const prevToDate = this.holidayForm.value.toDate;
139+
140+
if (prevFromDate instanceof Date) {
141+
holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
140142
}
141-
const prevFromDate: Date = this.holidayForm.value.fromDate;
142-
const prevToDate: Date = this.holidayForm.value.toDate;
143-
if (holidayFormData.closureDate instanceof Date) {
144-
holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat);
143+
if (prevToDate instanceof Date) {
144+
holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
145145
}
146-
if (holidayFormData.closureDate instanceof Date) {
147-
holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat);
146+
if (this.reSchedulingType === 2) {
147+
const repaymentScheduledTo = 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)