From 80af356fd1817c55faba866364e5ef18d5b29997 Mon Sep 17 00:00:00 2001 From: Jason Ng Date: Tue, 30 Jul 2024 15:54:45 -0400 Subject: [PATCH] [PM-7901] added new card view (#10321) * added new card view --- .../additional-options.component.html | 4 +- .../card-details-view.component.html | 83 ++++++++++++++ .../card-details-view.component.ts | 45 ++++++++ .../cipher-view/cipher-view.component.html | 5 + .../src/cipher-view/cipher-view.component.ts | 7 ++ .../custom-fields-v2.component.html | 104 ++++++++---------- 6 files changed, 186 insertions(+), 62 deletions(-) create mode 100644 libs/vault/src/cipher-view/card-details/card-details-view.component.html create mode 100644 libs/vault/src/cipher-view/card-details/card-details-view.component.ts diff --git a/libs/vault/src/cipher-view/additional-options/additional-options.component.html b/libs/vault/src/cipher-view/additional-options/additional-options.component.html index 1650ba2d12..1f33bb7882 100644 --- a/libs/vault/src/cipher-view/additional-options/additional-options.component.html +++ b/libs/vault/src/cipher-view/additional-options/additional-options.component.html @@ -3,10 +3,8 @@

{{ "additionalOptions" | i18n }}

- + {{ "note" | i18n }} + + + + {{ "expiration" | i18n }} + + + + {{ "securityCode" | i18n }} + + + + + + diff --git a/libs/vault/src/cipher-view/card-details/card-details-view.component.ts b/libs/vault/src/cipher-view/card-details/card-details-view.component.ts new file mode 100644 index 0000000000..a3c55977a2 --- /dev/null +++ b/libs/vault/src/cipher-view/card-details/card-details-view.component.ts @@ -0,0 +1,45 @@ +import { CommonModule } from "@angular/common"; +import { Component, Input } from "@angular/core"; + +import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { CardView } from "@bitwarden/common/vault/models/view/card.view"; +import { + CardComponent, + SectionComponent, + SectionHeaderComponent, + TypographyModule, + FormFieldModule, + IconButtonModule, +} from "@bitwarden/components"; + +import { OrgIconDirective } from "../../components/org-icon.directive"; + +@Component({ + selector: "app-card-details-view", + templateUrl: "card-details-view.component.html", + standalone: true, + imports: [ + CommonModule, + JslibModule, + CardComponent, + SectionComponent, + SectionHeaderComponent, + TypographyModule, + OrgIconDirective, + FormFieldModule, + IconButtonModule, + ], +}) +export class CardDetailsComponent { + @Input() card: CardView; + + constructor(private i18nService: I18nService) {} + + get setSectionTitle() { + if (this.card.brand && this.card.brand !== "Other") { + return this.i18nService.t("cardBrandDetails", this.card.brand); + } + return this.i18nService.t("cardDetails"); + } +} diff --git a/libs/vault/src/cipher-view/cipher-view.component.html b/libs/vault/src/cipher-view/cipher-view.component.html index 1463cbd731..6046bb48fd 100644 --- a/libs/vault/src/cipher-view/cipher-view.component.html +++ b/libs/vault/src/cipher-view/cipher-view.component.html @@ -8,6 +8,11 @@ > + + + + + diff --git a/libs/vault/src/cipher-view/cipher-view.component.ts b/libs/vault/src/cipher-view/cipher-view.component.ts index 7e72424e1f..094a3e72c7 100644 --- a/libs/vault/src/cipher-view/cipher-view.component.ts +++ b/libs/vault/src/cipher-view/cipher-view.component.ts @@ -19,6 +19,7 @@ import { PopupPageComponent } from "../../../../apps/browser/src/platform/popup/ import { AdditionalOptionsComponent } from "./additional-options/additional-options.component"; import { AttachmentsV2ViewComponent } from "./attachments/attachments-v2-view.component"; +import { CardDetailsComponent } from "./card-details/card-details-view.component"; import { CustomFieldV2Component } from "./custom-fields/custom-fields-v2.component"; import { ItemDetailsV2Component } from "./item-details/item-details-v2.component"; import { ItemHistoryV2Component } from "./item-history/item-history-v2.component"; @@ -40,6 +41,7 @@ import { ViewIdentitySectionsComponent } from "./view-identity-sections/view-ide AttachmentsV2ViewComponent, ItemHistoryV2Component, CustomFieldV2Component, + CardDetailsComponent, ViewIdentitySectionsComponent, ], }) @@ -64,6 +66,11 @@ export class CipherViewComponent implements OnInit { this.destroyed$.complete(); } + get hasCard() { + const { cardholderName, code, expMonth, expYear, brand, number } = this.cipher.card; + return cardholderName || code || expMonth || expYear || brand || number; + } + async loadCipherData() { if (this.cipher.collectionIds.length > 0) { this.collections$ = this.collectionService diff --git a/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html b/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html index 0adb8535fa..39d261d1bc 100644 --- a/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html +++ b/libs/vault/src/cipher-view/custom-fields/custom-fields-v2.component.html @@ -8,65 +8,51 @@ *ngFor="let field of fields; let last = last" [ngClass]="{ 'tw-mb-4': !last }" > - - - - - - - - - - - - - - - - - - - {{ field.name }} - - - - - - - - + + {{ field.name }} + + + + + {{ field.name }} + + + + + + + {{ field.name }} + + + {{ "linked" | i18n }}: {{ field.name }} + +