forked from bitwarden/clients
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a new component to display contact labels
io.cozy.contacts label management has been improved. A phone number, an address or an email can have : - a type which can be "cell", "voice", "fax" or a custom string - a label which can be "home" or "work" - both See io.cozy.contacts documentation to learn more. Here we introduce and use a new component to display correctly the label value. We also modify our types to correspond to io.cozy.contacts.
- Loading branch information
Showing
8 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apps/browser/src/vault/popup/components/vault/view-label.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<span aria-hidden="true"> · {{ this.stringifiedLabel }}</span> |
35 changes: 35 additions & 0 deletions
35
apps/browser/src/vault/popup/components/vault/view-label.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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) { | ||
this.stringifiedLabel = this.getTranslatedType(this.label.type); | ||
} else if (!this.label.type && this.label.label) { | ||
this.stringifiedLabel = this.getTranslatedLabel(this.label.label); | ||
} else if (this.label.type && this.label.label) { | ||
this.stringifiedLabel = `${this.getTranslatedType( | ||
this.label.type | ||
)} (${this.getTranslatedLabel(this.label.label).toLowerCase()})`; | ||
} | ||
} | ||
|
||
getTranslatedType(type: string) { | ||
return ["cell", "voice", "fax"].includes(type) ? this.i18nService.translate(type) : type; | ||
} | ||
|
||
getTranslatedLabel(label: string) { | ||
return this.i18nService.translate(label); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Cozy customization | ||
export type LabelData = { | ||
type: string; | ||
type?: string; | ||
label?: "home" | "work"; | ||
}; | ||
// Cozy customization end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters