From 2a732ba22fd39aa6b202aea21db0e49efe985a63 Mon Sep 17 00:00:00 2001 From: RIHTARSIC Joze <joze.rihtarsic@ext.ec.europa.eu> Date: Tue, 24 Sep 2024 06:01:13 +0200 Subject: [PATCH] [EDELIVERY-13979] allow to choose same day for expiration --- .../credential-dialog.component.ts | 16 ++++++++++++++++ .../access-token-panel.component.ts | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts b/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts index 1deb1ae92..73f7dfc18 100644 --- a/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts +++ b/smp-angular/src/app/common/dialogs/credential-dialog/credential-dialog.component.ts @@ -205,7 +205,23 @@ export class CredentialDialogComponent { } if (this.isCertificateType) { credential.certificate = this.certificateData; + } else { + let dateFrom = this.credentialForm.controls['activeFrom'].value; + if (dateFrom) { + // make date mutable and the modification + dateFrom = new Date(dateFrom); + dateFrom.setHours(0, 0, 0, 0); + } + credential.activeFrom = dateFrom + let dateTo = this.credentialForm.controls['expireOn'].value; + if (dateTo) { + // make date mutable and the modification + dateTo = new Date(dateTo); + dateTo.setHours(23, 59, 59, 999); + } + credential.expireOn = dateTo } + return credential; } diff --git a/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts b/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts index f290f68ea..285eb0024 100644 --- a/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts +++ b/smp-angular/src/app/user-settings/user-access-tokens/access-token-panel/access-token-panel.component.ts @@ -12,7 +12,12 @@ import {GlobalLookups} from "../../../common/global-lookups"; export function notAfterCurrentDateValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const date = control.value; + let date = control.value; + if (date) { + // make date mutable and the modification + date = new Date(date); + date.setHours(0, 0, 0, 0); + } const forbidden = date && date > Date.now(); return forbidden ? { 'matStartDateInvalid': { value: control.value } } : null; @@ -21,7 +26,12 @@ export function notAfterCurrentDateValidator(): ValidatorFn { export function notBeforeCurrentDateValidator(): ValidatorFn { return (control: AbstractControl): { [key: string]: any } | null => { - const date = control.value; + let date = control.value; + if (date) { + // make date mutable and the modification + date = new Date(date); + date.setHours(23, 59, 59, 999); + } const forbidden = date && date < Date.now(); return forbidden ? { 'matEndDateInvalid': { value: control.value } } : null; }; @@ -101,7 +111,7 @@ export class AccessTokenPanelComponent implements BeforeLeaveGuard { if (dateTo) { // make date mutable and the modification dateTo = new Date(dateTo); - dateTo.setHours(0, 0, 0, 0); + dateTo.setHours(23, 59, 59, 999); } this._credential.expireOn = dateTo -- GitLab