diff options
author | laurawilsonri <laura_wilson@brown.edu> | 2019-02-24 14:37:07 -0500 |
---|---|---|
committer | laurawilsonri <laura_wilson@brown.edu> | 2019-02-24 14:37:07 -0500 |
commit | f7b46167a7fd5d7ecf560dbd72e7d3295ba6c0c9 (patch) | |
tree | cc96c12c49e6c03c98b0f0e6f642e0902948283b /src/fields/Key.ts | |
parent | 3ad38f0445178bdfe025e4f6da60f68f03876f56 (diff) | |
parent | d9d55e422826da1fe87aa7973c92e54bc0c99f02 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into improveText
Diffstat (limited to 'src/fields/Key.ts')
-rw-r--r-- | src/fields/Key.ts | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/src/fields/Key.ts b/src/fields/Key.ts index eeda7be4e..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 { @@ -31,35 +40,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 NativeHeight = new Key("NativeHeight"); - 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 BackgroundLayout = new Key("BackgroundLayout"); - export const LayoutKeys = new Key("LayoutKeys"); - export const LayoutFields = new Key("LayoutFields"); - export const ColumnsKey = new Key("SchemaColumns"); - - //used for setting the text of a text document - export const Text = new Key("Text"); - //determines whether doc views will be selected when they are first loaded - //should be NumberField where 0 = false and 1 = true - //currently only implemented for FormattedTextView - export const SelectOnLoaded = new Key("SelectOnLoaded"); - + ToJson(): { type: Types, data: string, _id: string } { + return { + type: Types.Key, + data: this.name, + _id: this.Id + } + } }
\ No newline at end of file |