mirror of
https://github.com/openMF/web-app.git
synced 2026-02-06 14:11:48 +00:00
Merge 84ca84ee43 into ad99027843
This commit is contained in:
commit
38cb90363f
@ -11,6 +11,7 @@ import { Component, OnInit, inject } from '@angular/core';
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/** Custom Services */
|
||||
import { SystemService } from '../../../system.service';
|
||||
@ -35,6 +36,7 @@ export class EditConfigurationComponent implements OnInit {
|
||||
private settingsService = inject(SettingsService);
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dateUtils = inject(Dates);
|
||||
|
||||
/** Minimum transaction date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
@ -94,20 +96,33 @@ export class EditConfigurationComponent implements OnInit {
|
||||
this.configurationForm.value.stringValue != null ||
|
||||
this.configurationForm.value.dateValue != null
|
||||
) {
|
||||
const payload = {
|
||||
const payload: any = {
|
||||
...this.configurationForm.value
|
||||
};
|
||||
|
||||
if (!this.configurationForm.value.stringValue) {
|
||||
delete payload.stringValue;
|
||||
}
|
||||
|
||||
if (this.configurationForm.value.dateValue != null) {
|
||||
payload.locale = this.settingsService.language.code;
|
||||
payload.dateFormat = this.settingsService.dateFormat;
|
||||
// Format the date according to the dateFormat setting
|
||||
const dateFormat = this.settingsService.dateFormat || 'dd MMMM yyyy';
|
||||
|
||||
const formattedDate = this.dateUtils.formatDate(this.configurationForm.value.dateValue, dateFormat);
|
||||
|
||||
if (formattedDate) {
|
||||
payload.dateValue = formattedDate;
|
||||
payload.locale = this.settingsService.language.code;
|
||||
payload.dateFormat = dateFormat;
|
||||
} else {
|
||||
// Avoid sending invalid/null date to backend
|
||||
delete payload.dateValue;
|
||||
}
|
||||
} else {
|
||||
delete payload.dateValue;
|
||||
}
|
||||
|
||||
this.systemService.updateConfiguration(this.configuration.id, payload).subscribe((response: any) => {
|
||||
this.systemService.updateConfiguration(this.configuration.id, payload).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user