aboutsummaryrefslogtreecommitdiff
path: root/src/fields/KVPField.ts
diff options
context:
space:
mode:
authormadelinegr <laura_wilson@brown.edu>2019-03-02 16:33:42 -0500
committermadelinegr <laura_wilson@brown.edu>2019-03-02 16:33:42 -0500
commit043f40fec06da86732aeb6534d50edc56d4b8fad (patch)
treefe8ba1113ad87cfd41d4641120ce78b9553c8239 /src/fields/KVPField.ts
parent33809739a0a24a256d6a1b30bf237fc8bd749db3 (diff)
parentbde8aabad7e5745b4797e73b564e4efb19faeca9 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into treeview
Diffstat (limited to 'src/fields/KVPField.ts')
-rw-r--r--src/fields/KVPField.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/fields/KVPField.ts b/src/fields/KVPField.ts
new file mode 100644
index 000000000..a7ecc0768
--- /dev/null
+++ b/src/fields/KVPField.ts
@@ -0,0 +1,30 @@
+import { BasicField } from "./BasicField"
+import { FieldId } from "./Field";
+import { Types } from "../server/Message";
+import { Document } from "./Document"
+
+export class KVPField extends BasicField<Document> {
+ constructor(data: Document | undefined = undefined, id?: FieldId, save: boolean = true) {
+ super(data == undefined ? new Document() : data, save, id);
+ }
+
+ toString(): string {
+ return this.Data.Title;
+ }
+
+ ToScriptString(): string {
+ return `new KVPField("${this.Data}")`;
+ }
+
+ Copy() {
+ return new KVPField(this.Data);
+ }
+
+ ToJson(): { type: Types, data: Document, _id: string } {
+ return {
+ type: Types.Text,
+ data: this.Data,
+ _id: this.Id
+ }
+ }
+} \ No newline at end of file