[PM-9630] custom field linked fields update browser v2 (#10236)
This commit is contained in:
parent
fc55082148
commit
037d3ae91a
|
@ -15,7 +15,8 @@
|
|||
|
||||
<!-- CUSTOM 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>
|
||||
|
||||
<!-- ATTACHMENTS SECTION -->
|
||||
|
|
|
@ -65,14 +65,6 @@
|
|||
[value]="getLinkedType(field.linkedId)"
|
||||
aria-readonly="true"
|
||||
/>
|
||||
<button
|
||||
bitIconButton="bwi-clone"
|
||||
bitSuffix
|
||||
type="button"
|
||||
[appCopyClick]="field.name"
|
||||
showToast
|
||||
[appA11yTitle]="'copyValue' | i18n"
|
||||
></button>
|
||||
</bit-form-field>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
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 { 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 { IdentityView } from "@bitwarden/common/vault/models/view/identity.view";
|
||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||
import {
|
||||
CardComponent,
|
||||
IconButtonModule,
|
||||
|
@ -33,19 +36,33 @@ import {
|
|||
CheckboxModule,
|
||||
],
|
||||
})
|
||||
export class CustomFieldV2Component {
|
||||
export class CustomFieldV2Component implements OnInit {
|
||||
@Input() fields: FieldView[];
|
||||
@Input() cipherType: CipherType;
|
||||
fieldType = FieldType;
|
||||
fieldOptions: any;
|
||||
|
||||
constructor(private i18nService: I18nService) {}
|
||||
|
||||
getLinkedType(linkedId: LinkedIdType) {
|
||||
if (linkedId === LoginLinkedId.Username) {
|
||||
return this.i18nService.t("username");
|
||||
ngOnInit(): void {
|
||||
this.fieldOptions = this.getLinkedFieldsOptionsForCipher();
|
||||
}
|
||||
|
||||
if (linkedId === LoginLinkedId.Password) {
|
||||
return this.i18nService.t("password");
|
||||
getLinkedType(linkedId: LinkedIdType) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue