aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Key.ts
diff options
context:
space:
mode:
authorAndrew Kim <andrewdkim@users.noreply.github.com>2019-03-05 18:51:20 -0500
committerAndrew Kim <andrewdkim@users.noreply.github.com>2019-03-05 18:51:20 -0500
commit7f93e6639e8fee3e3760d13c69d65b343875091a (patch)
treed29b45310f92a53935177d969ce3c1bee9920c32 /src/fields/Key.ts
parent9b839a93b98b850aa77087218d4862b97fb24d15 (diff)
parent2cc5eb6ff512dc6128d25903bcb852f25bcadcca (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into PDFNode
Diffstat (limited to 'src/fields/Key.ts')
-rw-r--r--src/fields/Key.ts44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/fields/Key.ts b/src/fields/Key.ts
index 5cd43f55e..00d78d516 100644
--- a/src/fields/Key.ts
+++ b/src/fields/Key.ts
@@ -1,6 +1,8 @@
-import { Field } from "./Field"
+import { Field, FieldId } from "./Field"
import { Utils } from "../Utils";
import { observable } from "mobx";
+import { Types } from "../server/Message";
+import { Server } from "../client/Server";
export class Key extends Field {
private name: string;
@@ -9,10 +11,17 @@ export class Key extends Field {
return this.name;
}
- constructor(name: string) {
- super(Utils.GenerateDeterministicGuid(name));
+ constructor(name: string, id?: string, save: boolean = true) {
+ super(id || Utils.GenerateDeterministicGuid(name));
this.name = name;
+ if (save) {
+ Server.UpdateField(this)
+ }
+ }
+
+ UpdateFromServer(data: string) {
+ this.name = data;
}
TrySetValue(value: any): boolean {
@@ -27,24 +36,15 @@ export class Key extends Field {
return this;
}
+ ToScriptString(): string {
+ return name;
+ }
-}
-
-export namespace KeyStore {
- export const Prototype = new Key("Prototype");
- export const X = new Key("X");
- export const Y = new Key("Y");
- export const Title = new Key("Title");
- export const Author = new Key("Author");
- export const PanX = new Key("PanX");
- export const PanY = new Key("PanY");
- export const Scale = new Key("Scale");
- export const Width = new Key("Width");
- export const Height = new Key("Height");
- export const ZIndex = new Key("ZIndex");
- export const Data = new Key("Data");
- export const Layout = new Key("Layout");
- export const LayoutKeys = new Key("LayoutKeys");
- export const LayoutFields = new Key("LayoutFields");
- export const ColumnsKey = new Key("SchemaColumns");
+ ToJson(): { type: Types, data: string, _id: string } {
+ return {
+ type: Types.Key,
+ data: this.name,
+ _id: this.Id
+ }
+ }
} \ No newline at end of file