From 3785618d961ca37c95369921066b4996bf841d61 Mon Sep 17 00:00:00 2001 From: gbubemismith Date: Mon, 25 Sep 2023 08:16:28 -0400 Subject: [PATCH] moved logic from template to class --- .../emergency-add-edit.component.ts | 7 +++++-- .../vault/individual-vault/add-edit.component.html | 6 +----- .../vault/individual-vault/add-edit.component.ts | 13 ++++++++++++- .../src/app/vault/org-vault/add-edit.component.ts | 7 +++++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/apps/web/src/app/auth/settings/emergency-access/emergency-add-edit.component.ts b/apps/web/src/app/auth/settings/emergency-access/emergency-add-edit.component.ts index 925ebbf3ea6..9bdca5d793c 100644 --- a/apps/web/src/app/auth/settings/emergency-access/emergency-add-edit.component.ts +++ b/apps/web/src/app/auth/settings/emergency-access/emergency-add-edit.component.ts @@ -1,3 +1,4 @@ +import { DatePipe } from "@angular/common"; import { Component } from "@angular/core"; import { AuditService } from "@bitwarden/common/abstractions/audit.service"; @@ -47,7 +48,8 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent { organizationService: OrganizationService, logService: LogService, sendApiService: SendApiService, - dialogService: DialogService + dialogService: DialogService, + datePipe: DatePipe ) { super( cipherService, @@ -66,7 +68,8 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent { logService, passwordRepromptService, sendApiService, - dialogService + dialogService, + datePipe ); } diff --git a/apps/web/src/app/vault/individual-vault/add-edit.component.html b/apps/web/src/app/vault/individual-vault/add-edit.component.html index 9c783366a4a..571fd3b5505 100644 --- a/apps/web/src/app/vault/individual-vault/add-edit.component.html +++ b/apps/web/src/app/vault/individual-vault/add-edit.component.html @@ -201,11 +201,7 @@

{{ title }}

class="form-control" type="text" name="Login.Fido2key" - [value]=" - ('dateCreated' | i18n) + - ' ' + - (cipher.login.fido2Keys[0].creationDate | date : 'short') - " + [value]="fido2KeyCreationDateValue" appInputVerbatim disabled readonly diff --git a/apps/web/src/app/vault/individual-vault/add-edit.component.ts b/apps/web/src/app/vault/individual-vault/add-edit.component.ts index 986a1efb55b..8c34149c564 100644 --- a/apps/web/src/app/vault/individual-vault/add-edit.component.ts +++ b/apps/web/src/app/vault/individual-vault/add-edit.component.ts @@ -1,3 +1,4 @@ +import { DatePipe } from "@angular/common"; import { Component, OnDestroy, OnInit } from "@angular/core"; import { AddEditComponent as BaseAddEditComponent } from "@bitwarden/angular/vault/components/add-edit.component"; @@ -42,6 +43,15 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On protected totpInterval: number; protected override componentName = "app-vault-add-edit"; + get fido2KeyCreationDateValue(): string { + const dateCreated = this.i18nService.t("dateCreated"); + const creationDate = this.datePipe.transform( + this.cipher?.login?.fido2Keys?.[0]?.creationDate, + "short" + ); + return `${dateCreated} ${creationDate}`; + } + constructor( cipherService: CipherService, folderService: FolderService, @@ -59,7 +69,8 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On logService: LogService, passwordRepromptService: PasswordRepromptService, sendApiService: SendApiService, - dialogService: DialogService + dialogService: DialogService, + private datePipe: DatePipe ) { super( cipherService, diff --git a/apps/web/src/app/vault/org-vault/add-edit.component.ts b/apps/web/src/app/vault/org-vault/add-edit.component.ts index 46d8440d489..4772f4d9004 100644 --- a/apps/web/src/app/vault/org-vault/add-edit.component.ts +++ b/apps/web/src/app/vault/org-vault/add-edit.component.ts @@ -1,3 +1,4 @@ +import { DatePipe } from "@angular/common"; import { Component } from "@angular/core"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; @@ -49,7 +50,8 @@ export class AddEditComponent extends BaseAddEditComponent { passwordRepromptService: PasswordRepromptService, organizationService: OrganizationService, sendApiService: SendApiService, - dialogService: DialogService + dialogService: DialogService, + datePipe: DatePipe ) { super( cipherService, @@ -68,7 +70,8 @@ export class AddEditComponent extends BaseAddEditComponent { logService, passwordRepromptService, sendApiService, - dialogService + dialogService, + datePipe ); }