diff options
author | madelinegr <laura_wilson@brown.edu> | 2019-02-18 19:38:08 -0500 |
---|---|---|
committer | madelinegr <laura_wilson@brown.edu> | 2019-02-18 19:38:08 -0500 |
commit | 6fd2cec91efd6672a70e15a786954f92c1d23416 (patch) | |
tree | 0cbf4c1dd399bd041e05eb4c911a642547f673f9 /src/fields/Key.ts | |
parent | 41ba832136aef2b7e6a5034486757aa4b3047cf9 (diff) | |
parent | 70a8b4ab8075af4d06efb04c083b3bf11636373e (diff) |
Merge remote-tracking branch 'origin/server_database_merge' into authentication
Diffstat (limited to 'src/fields/Key.ts')
-rw-r--r-- | src/fields/Key.ts | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/fields/Key.ts b/src/fields/Key.ts index 7120c6e3e..d3958df2d 100644 --- a/src/fields/Key.ts +++ b/src/fields/Key.ts @@ -3,6 +3,7 @@ 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; @@ -11,10 +12,17 @@ export class Key extends Field { return this.name; } - constructor(name: string, id?: string) { + 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 { @@ -33,34 +41,11 @@ export class Key extends Field { return name; } - ToJson(): { type: Types, data: string, _id: String } { + ToJson(): { type: Types, data: string, _id: string } { return { type: Types.Key, data: this.name, _id: this.Id } } -} - -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"); - - export function Get(name: string): Key { - return new Key(name) - } }
\ No newline at end of file |