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.

47 lines
1014 B
TypeScript
Raw Normal View History

2022-06-24 02:38:55 +02:00
import { Utils } from "@bitwarden/common/misc/utils";
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
static fromJSON(obj: any): FieldView {
return Utils.copyToNewObject(
obj,
{
name: null,
value: null,
type: null,
newField: null,
showValue: null,
showCount: null,
linkedId: null,
},
FieldView
);
2022-06-24 02:38:55 +02:00
}
2018-01-24 17:33:15 +01:00
}