mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
[PM-9630] custom field linked fields update browser v2 (#10236)
This commit is contained in:
@@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
<!-- CUSTOM FIELDS -->
|
<!-- CUSTOM FIELDS -->
|
||||||
<ng-container *ngIf="cipher.fields">
|
<ng-container *ngIf="cipher.fields">
|
||||||
<app-custom-fields-v2 [fields]="cipher.fields"> </app-custom-fields-v2>
|
<app-custom-fields-v2 [fields]="cipher.fields" [cipherType]="cipher.type">
|
||||||
|
</app-custom-fields-v2>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- ATTACHMENTS SECTION -->
|
<!-- ATTACHMENTS SECTION -->
|
||||||
|
|||||||
@@ -65,14 +65,6 @@
|
|||||||
[value]="getLinkedType(field.linkedId)"
|
[value]="getLinkedType(field.linkedId)"
|
||||||
aria-readonly="true"
|
aria-readonly="true"
|
||||||
/>
|
/>
|
||||||
<button
|
|
||||||
bitIconButton="bwi-clone"
|
|
||||||
bitSuffix
|
|
||||||
type="button"
|
|
||||||
[appCopyClick]="field.name"
|
|
||||||
showToast
|
|
||||||
[appA11yTitle]="'copyValue' | i18n"
|
|
||||||
></button>
|
|
||||||
</bit-form-field>
|
</bit-form-field>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input } from "@angular/core";
|
import { Component, Input, OnInit } from "@angular/core";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { FieldType, LinkedIdType, LoginLinkedId } from "@bitwarden/common/vault/enums";
|
import { CipherType, FieldType, LinkedIdType } from "@bitwarden/common/vault/enums";
|
||||||
|
import { CardView } from "@bitwarden/common/vault/models/view/card.view";
|
||||||
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
|
||||||
|
import { IdentityView } from "@bitwarden/common/vault/models/view/identity.view";
|
||||||
|
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||||
import {
|
import {
|
||||||
CardComponent,
|
CardComponent,
|
||||||
IconButtonModule,
|
IconButtonModule,
|
||||||
@@ -33,19 +36,33 @@ import {
|
|||||||
CheckboxModule,
|
CheckboxModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CustomFieldV2Component {
|
export class CustomFieldV2Component implements OnInit {
|
||||||
@Input() fields: FieldView[];
|
@Input() fields: FieldView[];
|
||||||
|
@Input() cipherType: CipherType;
|
||||||
fieldType = FieldType;
|
fieldType = FieldType;
|
||||||
|
fieldOptions: any;
|
||||||
|
|
||||||
constructor(private i18nService: I18nService) {}
|
constructor(private i18nService: I18nService) {}
|
||||||
|
|
||||||
getLinkedType(linkedId: LinkedIdType) {
|
ngOnInit(): void {
|
||||||
if (linkedId === LoginLinkedId.Username) {
|
this.fieldOptions = this.getLinkedFieldsOptionsForCipher();
|
||||||
return this.i18nService.t("username");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linkedId === LoginLinkedId.Password) {
|
getLinkedType(linkedId: LinkedIdType) {
|
||||||
return this.i18nService.t("password");
|
const linkedType = this.fieldOptions.get(linkedId);
|
||||||
|
return this.i18nService.t(linkedType.i18nKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getLinkedFieldsOptionsForCipher() {
|
||||||
|
switch (this.cipherType) {
|
||||||
|
case CipherType.Login:
|
||||||
|
return LoginView.prototype.linkedFieldOptions;
|
||||||
|
case CipherType.Card:
|
||||||
|
return CardView.prototype.linkedFieldOptions;
|
||||||
|
case CipherType.Identity:
|
||||||
|
return IdentityView.prototype.linkedFieldOptions;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user