diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 0b153ee06ee1..1de43e6e9557 100755 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -2423,5 +2423,20 @@ }, "encryptedInfoDismiss": { "message": "I understand" + }, + "home": { + "message": "Home" + }, + "work": { + "message": "Work" + }, + "cell": { + "message": "Cell" + }, + "voice": { + "message": "Voice" + }, + "fax": { + "message": "Fax" } } diff --git a/apps/browser/src/_locales/fr/messages.json b/apps/browser/src/_locales/fr/messages.json index f7dec8f9a042..dde066a32bb7 100755 --- a/apps/browser/src/_locales/fr/messages.json +++ b/apps/browser/src/_locales/fr/messages.json @@ -2471,5 +2471,20 @@ }, "encryptedInfoDismiss": { "message": "J'ai compris" + }, + "home": { + "message": "Perso" + }, + "work": { + "message": "Pro" + }, + "cell": { + "message": "Mobile" + }, + "voice": { + "message": "Fixe" + }, + "fax": { + "message": "Fax" } } diff --git a/apps/browser/src/popup/app.module.ts b/apps/browser/src/popup/app.module.ts index fef6311e79b1..cdc0ab81e51e 100755 --- a/apps/browser/src/popup/app.module.ts +++ b/apps/browser/src/popup/app.module.ts @@ -82,6 +82,7 @@ import { FlagConditionalComponent } from "../cozy/components/flag-conditional/fl import { IfFlagDirective } from "../cozy/components/flag-conditional/if-flag.directive"; import { AddGenericComponent } from "../cozy/components/add-generic/add-generic.component"; import { ViewExpirationDateComponent } from "../vault/popup/components/vault/view-expiration-date.component"; +import { ViewLabelComponent } from "../vault/popup/components/vault/view-label.component"; import { ContactAvatarComponent } from "../vault/popup/components/vault/contact-avatar.component"; import { ProfilesMigrationComponent } from "../cozy/components/profiles-migration/profiles-migration.component"; import { EncryptedInfoComponent } from "../cozy/components/encrypted-info/encrypted-info.component"; @@ -170,6 +171,7 @@ import { EncryptedInfoComponent } from "../cozy/components/encrypted-info/encryp IfFlagDirective, AddGenericComponent, ViewExpirationDateComponent, + ViewLabelComponent, ContactAvatarComponent, ProfilesMigrationComponent, EncryptedInfoComponent, diff --git a/apps/browser/src/vault/popup/components/vault/view-custom-fields.component.html b/apps/browser/src/vault/popup/components/vault/view-custom-fields.component.html index 8c72a1a74985..21d96b01f4fd 100644 --- a/apps/browser/src/vault/popup/components/vault/view-custom-fields.component.html +++ b/apps/browser/src/vault/popup/components/vault/view-custom-fields.component.html @@ -47,10 +47,7 @@

(dragstart)="setTextDataOnDrag($event, field.value)" > {{ field.name }} - - - {{ field.label.type }} - + {{ field.name }} diff --git a/apps/browser/src/vault/popup/components/vault/view-label.component.html b/apps/browser/src/vault/popup/components/vault/view-label.component.html new file mode 100644 index 000000000000..50c029126147 --- /dev/null +++ b/apps/browser/src/vault/popup/components/vault/view-label.component.html @@ -0,0 +1,2 @@ + +{{ this.stringifiedLabel }} diff --git a/apps/browser/src/vault/popup/components/vault/view-label.component.ts b/apps/browser/src/vault/popup/components/vault/view-label.component.ts new file mode 100644 index 000000000000..ab8524b3ce7e --- /dev/null +++ b/apps/browser/src/vault/popup/components/vault/view-label.component.ts @@ -0,0 +1,40 @@ +import { Component, Input, OnInit } from "@angular/core"; + +import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; +import { LabelData } from "@bitwarden/common/vault/models/data/label.data"; + +@Component({ + selector: "app-vault-view-label", + templateUrl: "./view-label.component.html", +}) +export class ViewLabelComponent implements OnInit { + @Input() label: LabelData; + stringifiedLabel: string; + + constructor(private i18nService: I18nService) {} + + ngOnInit(): void { + if (this.label.type && !this.label.label) { + const type = this.getTranslatedType(this.label.type); + + this.stringifiedLabel = type; + } else if (!this.label.type && this.label.label) { + const label = this.getTranslatedLabel(this.label.label); + + this.stringifiedLabel = label; + } else if (this.label.type && this.label.label) { + const type = this.getTranslatedType(this.label.type); + const label = this.getTranslatedLabel(this.label.label); + + this.stringifiedLabel = `${type} (${label.toLowerCase()})`; + } + } + + getTranslatedType(type: string) { + return ["cell", "voice", "fax"].includes(type) ? this.i18nService.translate(type) : type; + } + + getTranslatedLabel(label: string) { + return this.i18nService.translate(label); + } +} diff --git a/libs/common/src/vault/models/data/label.data.ts b/libs/common/src/vault/models/data/label.data.ts index b80adb5f22e8..105a861b1d5d 100644 --- a/libs/common/src/vault/models/data/label.data.ts +++ b/libs/common/src/vault/models/data/label.data.ts @@ -1,6 +1,6 @@ // Cozy customization export type LabelData = { - type: string; + type?: string; label?: "home" | "work"; }; // Cozy customization end diff --git a/libs/cozy/fields.helper.ts b/libs/cozy/fields.helper.ts index a4c03b89e7fa..4f79b304b4f1 100644 --- a/libs/cozy/fields.helper.ts +++ b/libs/cozy/fields.helper.ts @@ -151,7 +151,7 @@ const buildContactField = ({ const fieldOptions: FieldOptions = {}; - if (type) { + if (type || label) { fieldOptions.label = { type, label,