Skip to content

Commit

Permalink
moved logic from template to class
Browse files Browse the repository at this point in the history
  • Loading branch information
gbubemismith committed Sep 25, 2023
1 parent b6f68c1 commit 3785618
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DatePipe } from "@angular/common";
import { Component } from "@angular/core";

import { AuditService } from "@bitwarden/common/abstractions/audit.service";
Expand Down Expand Up @@ -47,7 +48,8 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent {
organizationService: OrganizationService,
logService: LogService,
sendApiService: SendApiService,
dialogService: DialogService
dialogService: DialogService,
datePipe: DatePipe
) {
super(
cipherService,
Expand All @@ -66,7 +68,8 @@ export class EmergencyAddEditComponent extends BaseAddEditComponent {
logService,
passwordRepromptService,
sendApiService,
dialogService
dialogService,
datePipe
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ <h1 class="modal-title" id="cipherAddEditTitle">{{ title }}</h1>
class="form-control"
type="text"
name="Login.Fido2key"
[value]="
('dateCreated' | i18n) +
' ' +
(cipher.login.fido2Keys[0].creationDate | date : 'short')
"
[value]="fido2KeyCreationDateValue"
appInputVerbatim
disabled
readonly
Expand Down
13 changes: 12 additions & 1 deletion apps/web/src/app/vault/individual-vault/add-edit.component.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/app/vault/org-vault/add-edit.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DatePipe } from "@angular/common";
import { Component } from "@angular/core";

import { ApiService } from "@bitwarden/common/abstractions/api.service";
Expand Down Expand Up @@ -49,7 +50,8 @@ export class AddEditComponent extends BaseAddEditComponent {
passwordRepromptService: PasswordRepromptService,
organizationService: OrganizationService,
sendApiService: SendApiService,
dialogService: DialogService
dialogService: DialogService,
datePipe: DatePipe
) {
super(
cipherService,
Expand All @@ -68,7 +70,8 @@ export class AddEditComponent extends BaseAddEditComponent {
logService,
passwordRepromptService,
sendApiService,
dialogService
dialogService,
datePipe
);
}

Expand Down

0 comments on commit 3785618

Please sign in to comment.