diff options
author | Jude <julie_wang1@brown.edu> | 2019-02-24 15:15:24 -0500 |
---|---|---|
committer | Jude <julie_wang1@brown.edu> | 2019-02-24 15:15:24 -0500 |
commit | 2eec7d883511107136d27683a309287c350f79b4 (patch) | |
tree | f57e99eda60a697836d9bf994bed337763b7bf20 /src/fields/Key.ts | |
parent | 6c6e5ebcfa80c04844a08ab23f6f7b66494b78d4 (diff) | |
parent | d9d55e422826da1fe87aa7973c92e54bc0c99f02 (diff) |
merge
Diffstat (limited to 'src/fields/Key.ts')
-rw-r--r-- | src/fields/Key.ts | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/src/fields/Key.ts b/src/fields/Key.ts index 67a5f86fb..c16a00878 100644 --- a/src/fields/Key.ts +++ b/src/fields/Key.ts @@ -1,6 +1,9 @@ -import { Field } from "./Field" +import { Field, FieldId } from "./Field" import { Utils } from "../Utils"; import { observable } from "mobx"; +import { Types } from "../server/Message"; +import { ObjectID } from "bson"; +import { Server } from "../client/Server"; export class Key extends Field { private name: string; @@ -9,10 +12,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 { @@ -31,26 +41,11 @@ export class Key extends Field { 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 NativeWidth = new Key("NativeWidth"); - 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 Annotations = new Key("Annotations"); - export const Layout = new Key("Layout"); - export const AnnotatedLayout = new Key("AnnotatedLayout"); - 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 |