1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

[SM-288] Rename models to follow naming convention (#3795)

This commit is contained in:
Oscar Hinton
2022-10-14 18:25:50 +02:00
committed by GitHub
parent 1fd8d316a1
commit e941f06bac
445 changed files with 939 additions and 938 deletions

View File

@@ -0,0 +1,52 @@
import { FieldType } from "../../enums/fieldType";
import { LinkedIdType } from "../../enums/linkedIdType";
import { EncString } from "../domain/enc-string";
import { Field as FieldDomain } from "../domain/field";
import { FieldView } from "../view/field.view";
export class FieldExport {
static template(): FieldExport {
const req = new FieldExport();
req.name = "Field name";
req.value = "Some value";
req.type = FieldType.Text;
return req;
}
static toView(req: FieldExport, view = new FieldView()) {
view.type = req.type;
view.value = req.value;
view.name = req.name;
view.linkedId = req.linkedId;
return view;
}
static toDomain(req: FieldExport, domain = new FieldDomain()) {
domain.type = req.type;
domain.value = req.value != null ? new EncString(req.value) : null;
domain.name = req.name != null ? new EncString(req.name) : null;
domain.linkedId = req.linkedId;
return domain;
}
name: string;
value: string;
type: FieldType;
linkedId: LinkedIdType;
constructor(o?: FieldView | FieldDomain) {
if (o == null) {
return;
}
if (o instanceof FieldView) {
this.name = o.name;
this.value = o.value;
} else {
this.name = o.name?.encryptedString;
this.value = o.value?.encryptedString;
}
this.type = o.type;
this.linkedId = o.linkedId;
}
}