diff options
Diffstat (limited to 'src/fields')
-rw-r--r-- | src/fields/Document.ts | 9 | ||||
-rw-r--r-- | src/fields/Key.ts | 28 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts index 0551a74b0..5c0a9caf0 100644 --- a/src/fields/Document.ts +++ b/src/fields/Document.ts @@ -3,6 +3,7 @@ import { Key, KeyStore } from "./Key" import { NumberField } from "./NumberField"; import { ObservableMap, computed } from "mobx"; import { TextField } from "./TextField"; +import { ListField } from "./ListField"; export class Document extends Field { private fields: ObservableMap<Key, Field> = new ObservableMap(); @@ -51,14 +52,18 @@ export class Document extends Field { return vval; } - GetNumberValue(key: Key, defaultVal: number): number { + GetNumberField(key: Key, defaultVal: number): number { return this.GetFieldValue(key, NumberField, defaultVal); } - GetTextValue(key: Key, defaultVal: string): string { + GetTextField(key: Key, defaultVal: string): string { return this.GetFieldValue(key, TextField, defaultVal); } + GetListField<T extends Field>(key: Key, defaultVal: T[]): T[] { + return this.GetFieldValue<T[], ListField<T>>(key, ListField, defaultVal) + } + SetField(key: Key, field: Field | undefined): void { if (field) { this.fields.set(key, field); diff --git a/src/fields/Key.ts b/src/fields/Key.ts index 61b3cdd37..4da800fac 100644 --- a/src/fields/Key.ts +++ b/src/fields/Key.ts @@ -31,17 +31,19 @@ export class Key extends Field { } export namespace KeyStore { - export let Prototype = new Key("Prototype"); - export let X = new Key("X"); - export let Y = new Key("Y"); - export let Title = new Key("Title"); - export let PanX = new Key("PanX"); - export let PanY = new Key("PanY"); - export let Scale = new Key("Scale"); - export let Width = new Key("Width"); - export let Height = new Key("Height"); - export let Data = new Key("Data"); - export let Layout = new Key("Layout"); - export let LayoutKeys = new Key("LayoutKeys"); - export let LayoutFields = new Key("LayoutFields"); + 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 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"); }
\ No newline at end of file |