mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
Move custom fields to separate components (#489)
* Move add-edit custom fields to own component * Fix linting * Fix change handling if cipherType changes * Removed linked fields work * Move view custom fields to own component * Remove unnecessary imports * Remove old logic from component
This commit is contained in:
35
angular/src/components/view-custom-fields.component.ts
Normal file
35
angular/src/components/view-custom-fields.component.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
Directive,
|
||||
Input,
|
||||
} from '@angular/core';
|
||||
|
||||
import { EventType } from 'jslib-common/enums/eventType';
|
||||
import { FieldType } from 'jslib-common/enums/fieldType';
|
||||
|
||||
import { EventService } from 'jslib-common/abstractions/event.service';
|
||||
|
||||
import { CipherView } from 'jslib-common/models/view/cipherView';
|
||||
import { FieldView } from 'jslib-common/models/view/fieldView';
|
||||
|
||||
@Directive()
|
||||
export class ViewCustomFieldsComponent {
|
||||
@Input() cipher: CipherView;
|
||||
@Input() promptPassword: () => Promise<boolean>;
|
||||
@Input() copy: (value: string, typeI18nKey: string, aType: string) => void;
|
||||
|
||||
fieldType = FieldType;
|
||||
|
||||
constructor(private eventService: EventService) { }
|
||||
|
||||
async toggleFieldValue(field: FieldView) {
|
||||
if (!await this.promptPassword()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const f = (field as any);
|
||||
f.showValue = !f.showValue;
|
||||
if (f.showValue) {
|
||||
this.eventService.collect(EventType.Cipher_ClientToggledHiddenFieldVisible, this.cipher.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user