Pull request #396: RED-6136, fixed date formatting, fixed valid from and to fields not getting filled after being updated.
Merge in RED/ui from RED-6136 to master * commit '5e81560e8956682c7ba492049452c2baa9aeb19e': RED-6136, fixed date formatting, fixed valid from and to fields not getting filled after being updated.
This commit is contained in:
commit
4b761cd29b
@ -110,11 +110,11 @@ export class AddEditCloneDossierTemplateDialogComponent extends BaseDialogCompon
|
||||
name: [this._getCloneName(), Validators.required],
|
||||
description: [this.dossierTemplate?.description],
|
||||
validFrom: [
|
||||
this.dossierTemplate?.validFrom ? dayjs(this.dossierTemplate?.validFrom) : null,
|
||||
this.dossierTemplate?.validFrom ? dayjs(this.dossierTemplate?.validFrom).toDate() : null,
|
||||
this._requiredIfValidator(() => this.hasValidFrom),
|
||||
],
|
||||
validTo: [
|
||||
this.dossierTemplate?.validTo ? dayjs(this.dossierTemplate?.validTo) : null,
|
||||
this.dossierTemplate?.validTo ? dayjs(this.dossierTemplate?.validTo).toDate() : null,
|
||||
this._requiredIfValidator(() => this.hasValidTo),
|
||||
],
|
||||
downloadFileTypes: [this.dossierTemplate?.downloadFileTypes || ['PREVIEW', 'REDACTED']],
|
||||
|
||||
13
apps/red-ui/src/app/modules/shared/CustomDateAdapter.ts
Normal file
13
apps/red-ui/src/app/modules/shared/CustomDateAdapter.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { NativeDateAdapter } from '@angular/material/core';
|
||||
import dayjs from 'dayjs';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
dayjs.extend(customParseFormat);
|
||||
|
||||
export class CustomDateAdapter extends NativeDateAdapter {
|
||||
parse(value: any, parseFormat: string): Date | null {
|
||||
return dayjs(value, parseFormat).toDate();
|
||||
}
|
||||
format(date: Date, displayFormat: string): string {
|
||||
return dayjs(date).format(displayFormat);
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ import { DossierStateComponent } from './components/dossier-state/dossier-state.
|
||||
import { FileStatsComponent } from './components/file-stats/file-stats.component';
|
||||
import { FileNameColumnComponent } from './components/file-name-column/file-name-column.component';
|
||||
import { DossierNameColumnComponent } from './components/dossier-name-column/dossier-name-column.component';
|
||||
import { MAT_DATE_FORMATS } from '@angular/material/core';
|
||||
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
|
||||
import { DossiersTypeSwitchComponent } from './components/dossiers-type-switch/dossiers-type-switch.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
@ -43,6 +43,7 @@ import { ColorPickerModule } from 'ngx-color-picker';
|
||||
import { WatermarkSelectorComponent } from './components/dossier-watermark-selector/watermark-selector.component';
|
||||
import { OcrProgressBarComponent } from './components/ocr-progress-bar/ocr-progress-bar.component';
|
||||
import { DownloadDialogComponent } from './dialogs/download-dialog/download-dialog.component';
|
||||
import { CustomDateAdapter } from '@shared/CustomDateAdapter';
|
||||
|
||||
const buttons = [FileDownloadBtnComponent];
|
||||
|
||||
@ -93,14 +94,18 @@ const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, Iqs
|
||||
exports: [...modules, ...components, ...utils],
|
||||
providers: [
|
||||
...services,
|
||||
{
|
||||
provide: DateAdapter,
|
||||
useClass: CustomDateAdapter,
|
||||
},
|
||||
{
|
||||
provide: MAT_DATE_FORMATS,
|
||||
useValue: {
|
||||
parse: {
|
||||
dateInput: 'DD/MM/YY',
|
||||
dateInput: 'D/M/YY',
|
||||
},
|
||||
display: {
|
||||
dateInput: 'DD/MM/YY',
|
||||
dateInput: 'D/M/YY',
|
||||
monthYearLabel: 'YYYY',
|
||||
dateA11yLabel: 'LL',
|
||||
monthYearA11yLabel: 'YYYY',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user