1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-10 00:21:27 +01:00

[Linked fields] Add Linked Field as custom field type (#1206)

* Add linked fields

* Update to use Field.linkedId

* Update jslib
This commit is contained in:
Thomas Rittson 2021-11-04 07:41:04 +10:00 committed by GitHub
parent cf5823fe71
commit 8b60d50050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

2
jslib

@ -1 +1 @@
Subproject commit e90cc40f68f2605e76a93c4e854d885ac93d955c Subproject commit 2db9e1ce0d7a702f07f20ecb916dd8191ff617e1

View File

@ -16,6 +16,7 @@
<div class="col-7 form-group"> <div class="col-7 form-group">
<label for="fieldValue{{i}}">{{'value' | i18n}}</label> <label for="fieldValue{{i}}">{{'value' | i18n}}</label>
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<!-- Text -->
<div class="input-group" *ngIf="f.type === fieldType.Text"> <div class="input-group" *ngIf="f.type === fieldType.Text">
<input id="fieldValue{{i}}" class="form-control" type="text" name="Field.Value{{i}}" <input id="fieldValue{{i}}" class="form-control" type="text" name="Field.Value{{i}}"
[(ngModel)]="f.value" appInputVerbatim [(ngModel)]="f.value" appInputVerbatim
@ -28,6 +29,7 @@
</button> </button>
</div> </div>
</div> </div>
<!-- Hidden -->
<div class="input-group" *ngIf="f.type === fieldType.Hidden"> <div class="input-group" *ngIf="f.type === fieldType.Hidden">
<input id="fieldValue{{i}}" type="{{f.showValue ? 'text' : 'password'}}" <input id="fieldValue{{i}}" type="{{f.showValue ? 'text' : 'password'}}"
name="Field.Value{{i}}" [(ngModel)]="f.value" name="Field.Value{{i}}" [(ngModel)]="f.value"
@ -49,7 +51,16 @@
</button> </button>
</div> </div>
</div> </div>
<!-- Linked -->
<div class="input-group" *ngIf="f.type === fieldType.Linked">
<select id="fieldValue{{i}}" name="Field.Value{{i}}" class="form-control" [(ngModel)]="f.linkedId"
*ngIf="f.type === fieldType.Linked && cipher.linkedFieldOptions != null"
[disabled]="cipher.isDeleted || viewOnly">
<option *ngFor="let o of linkedFieldOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
</div>
<div class="flex-fill"> <div class="flex-fill">
<!-- Boolean -->
<input id="fieldValue{{i}}" name="Field.Value{{i}}" type="checkbox" <input id="fieldValue{{i}}" name="Field.Value{{i}}" type="checkbox"
[(ngModel)]="f.value" *ngIf="f.type === fieldType.Boolean" appTrueFalseValue [(ngModel)]="f.value" *ngIf="f.type === fieldType.Boolean" appTrueFalseValue
trueValue="true" falseValue="false" [disabled]="cipher.isDeleted || viewOnly"> trueValue="true" falseValue="false" [disabled]="cipher.isDeleted || viewOnly">
@ -66,6 +77,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Add new custom field -->
<a href="#" appStopClick (click)="addField()" class="d-inline-block mb-2" <a href="#" appStopClick (click)="addField()" class="d-inline-block mb-2"
*ngIf="!cipher.isDeleted && !viewOnly"> *ngIf="!cipher.isDeleted && !viewOnly">
<i class="fa fa-plus-circle fa-fw" aria-hidden="true"></i> {{'newCustomField' | i18n}} <i class="fa fa-plus-circle fa-fw" aria-hidden="true"></i> {{'newCustomField' | i18n}}
@ -75,6 +87,9 @@
<label for="addFieldType" class="sr-only">{{'type' | i18n}}</label> <label for="addFieldType" class="sr-only">{{'type' | i18n}}</label>
<select id="addFieldType" class="form-control" name="AddFieldType" [(ngModel)]="addFieldType"> <select id="addFieldType" class="form-control" name="AddFieldType" [(ngModel)]="addFieldType">
<option *ngFor="let o of addFieldTypeOptions" [ngValue]="o.value">{{o.name}}</option> <option *ngFor="let o of addFieldTypeOptions" [ngValue]="o.value">{{o.name}}</option>
<option *ngIf="cipher.linkedFieldOptions != null" [ngValue]="addFieldLinkedTypeOption.value">
{{addFieldLinkedTypeOption.name}}
</option>
</select> </select>
</div> </div>
</div> </div>

View File

@ -388,8 +388,8 @@
<textarea id="notes" name="Notes" rows="6" [(ngModel)]="cipher.notes" <textarea id="notes" name="Notes" rows="6" [(ngModel)]="cipher.notes"
[disabled]="cipher.isDeleted || viewOnly" class="form-control"></textarea> [disabled]="cipher.isDeleted || viewOnly" class="form-control"></textarea>
</div> </div>
<app-vault-add-edit-custom-fields [cipher]="cipher" [viewOnly]="viewOnly" [copy]="copy.bind(this)"> <app-vault-add-edit-custom-fields [cipher]="cipher" [thisCipherType]="cipher.type" [viewOnly]="viewOnly"
</app-vault-add-edit-custom-fields> [copy]="copy.bind(this)"></app-vault-add-edit-custom-fields>
<ng-container *ngIf="allowOwnershipAssignment()"> <ng-container *ngIf="allowOwnershipAssignment()">
<h3 class="mt-4">{{'ownership' | i18n}}</h3> <h3 class="mt-4">{{'ownership' | i18n}}</h3>
<div class="row"> <div class="row">

View File

@ -166,6 +166,10 @@
"cfTypeBoolean": { "cfTypeBoolean": {
"message": "Boolean" "message": "Boolean"
}, },
"cfTypeLinked": {
"message": "Linked",
"description": "This describes a field that is 'linked' (related) to another field."
},
"remove": { "remove": {
"message": "Remove" "message": "Remove"
}, },
@ -311,6 +315,9 @@
"lastName": { "lastName": {
"message": "Last Name" "message": "Last Name"
}, },
"fullName": {
"message": "Full Name"
},
"address1": { "address1": {
"message": "Address 1" "message": "Address 1"
}, },