mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
[PM-7103] Identity View (#10240)
* make headings of v2 view component lowercase * initial add of view identity sections * adding identification fields * add contact information section * add copy ability to all identity fields * add visibility toggle for passport and ssn * add testids for all identity fields * add test-ids to visibility toggles * refactor visibility methods to be called in `ngOnInit` rather than on each render * replace `disabled` with `readonly`
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { NgIf } from "@angular/common";
|
||||
import { Component, Input, OnInit } from "@angular/core";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import {
|
||||
CardComponent,
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
SectionComponent,
|
||||
SectionHeaderComponent,
|
||||
TypographyModule,
|
||||
} from "@bitwarden/components";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "app-view-identity-sections",
|
||||
templateUrl: "./view-identity-sections.component.html",
|
||||
imports: [
|
||||
NgIf,
|
||||
JslibModule,
|
||||
CardComponent,
|
||||
SectionComponent,
|
||||
SectionHeaderComponent,
|
||||
TypographyModule,
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
],
|
||||
})
|
||||
export class ViewIdentitySectionsComponent implements OnInit {
|
||||
@Input() cipher: CipherView;
|
||||
|
||||
showPersonalDetails: boolean;
|
||||
showIdentificationDetails: boolean;
|
||||
showContactDetails: boolean;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.showPersonalDetails = this.hasPersonalDetails();
|
||||
this.showIdentificationDetails = this.hasIdentificationDetails();
|
||||
this.showContactDetails = this.hasContactDetails();
|
||||
}
|
||||
|
||||
/** Returns all populated address fields */
|
||||
get addressFields(): string {
|
||||
const { address1, address2, address3, fullAddressPart2, country } = this.cipher.identity;
|
||||
return [address1, address2, address3, fullAddressPart2, country].filter(Boolean).join("\n");
|
||||
}
|
||||
|
||||
/** Returns the number of "rows" that should be assigned to the address textarea */
|
||||
get addressRows(): number {
|
||||
return this.addressFields.split("\n").length;
|
||||
}
|
||||
|
||||
/** Returns true when any of the "personal detail" attributes are populated */
|
||||
private hasPersonalDetails(): boolean {
|
||||
const { username, company, fullName } = this.cipher.identity;
|
||||
return Boolean(fullName || username || company);
|
||||
}
|
||||
|
||||
/** Returns true when any of the "identification detail" attributes are populated */
|
||||
private hasIdentificationDetails(): boolean {
|
||||
const { ssn, passportNumber, licenseNumber } = this.cipher.identity;
|
||||
return Boolean(ssn || passportNumber || licenseNumber);
|
||||
}
|
||||
|
||||
/** Returns true when any of the "contact detail" attributes are populated */
|
||||
private hasContactDetails(): boolean {
|
||||
const { email, phone } = this.cipher.identity;
|
||||
|
||||
return Boolean(email || phone || this.addressFields);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user