bitwarden-estensione-browser/libs/common/src/models/view/fieldView.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1002 B
TypeScript
Raw Normal View History

import { FieldType } from "../../enums/fieldType";
import { LinkedIdType } from "../../enums/linkedIdType";
2022-02-22 15:39:11 +01:00
import { Field } from "../domain/field";
2018-01-24 17:33:15 +01:00
import { View } from "./view";
export class FieldView implements View {
2019-01-25 15:30:21 +01:00
name: string = null;
value: string = null;
type: FieldType = null;
2022-02-22 15:39:11 +01:00
newField = false; // Marks if the field is new and hasn't been saved
showValue = false;
showCount = false;
linkedId: LinkedIdType = null;
2018-01-24 17:33:15 +01:00
2018-01-26 04:59:53 +01:00
constructor(f?: Field) {
if (!f) {
return;
2018-01-24 17:33:15 +01:00
}
2018-01-25 20:26:09 +01:00
2018-01-24 17:33:15 +01:00
this.type = f.type;
this.linkedId = f.linkedId;
2021-12-16 13:36:21 +01:00
}
2018-01-25 20:26:09 +01:00
get maskedValue(): string {
2018-03-06 14:17:39 +01:00
return this.value != null ? "••••••••" : null;
2018-01-25 20:26:09 +01:00
}
2022-06-24 02:38:55 +02:00
2022-06-29 06:00:05 +02:00
static fromJSON(obj: Partial<FieldView>): FieldView {
2022-06-29 02:23:01 +02:00
const view = new FieldView();
view.name = obj.name;
view.value = obj.value;
view.type = obj.type;
view.newField = obj.newField;
view.showValue = obj.showValue;
view.showCount = obj.showCount;
view.linkedId = obj.linkedId;
return view;
2022-06-24 02:38:55 +02:00
}
2018-01-24 17:33:15 +01:00
}