From d12625a3a3e241d80ce3fe8e577ba8a41320b189 Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Fri, 1 Feb 2019 01:05:31 -0500 Subject: Changed formatting setting, added very basic generic FieldView, and added Schema view --- src/documents/Documents.ts | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/documents') diff --git a/src/documents/Documents.ts b/src/documents/Documents.ts index 318a6d7a3..73cf483ef 100644 --- a/src/documents/Documents.ts +++ b/src/documents/Documents.ts @@ -5,6 +5,7 @@ import { NumberField } from "../fields/NumberField"; import { ListField } from "../fields/ListField"; import { FieldTextBox } from "../views/nodes/FieldTextBox"; import { CollectionDockingView } from "../views/collections/CollectionDockingView"; +import { CollectionSchemaView } from "../views/collections/CollectionSchemaView"; interface DocumentOptions { x?: number; @@ -45,7 +46,7 @@ export namespace Documents { textProto.SetField(KeyStore.Width, new NumberField(300)); textProto.SetField(KeyStore.Height, new NumberField(150)); textProto.SetField(KeyStore.Layout, new TextField(FieldTextBox.LayoutString())); - textProto.SetField(KeyStore.LayoutKeys, new ListField([ KeyStore.Data ])); + textProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data])); } return textProto; } @@ -57,6 +58,27 @@ export namespace Documents { return doc; } + let schemaProto: Document; + function GetSchemaPrototype(): Document { + if (!schemaProto) { + schemaProto = new Document(); + schemaProto.SetField(KeyStore.X, new NumberField(0)); + schemaProto.SetField(KeyStore.Y, new NumberField(0)); + schemaProto.SetField(KeyStore.Width, new NumberField(300)); + schemaProto.SetField(KeyStore.Height, new NumberField(150)); + schemaProto.SetField(KeyStore.Layout, new TextField(CollectionSchemaView.LayoutString())); + schemaProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data])); + } + return schemaProto; + } + + export function SchemaDocument(documents: Array, options: DocumentOptions = {}): Document { + let doc = GetSchemaPrototype().MakeDelegate(); + setupOptions(doc, options); + doc.SetField(KeyStore.Data, new ListField(documents)); + return doc; + } + let dockProto: Document; function GetDockPrototype(): Document { @@ -67,7 +89,7 @@ export namespace Documents { dockProto.SetField(KeyStore.Width, new NumberField(300)); dockProto.SetField(KeyStore.Height, new NumberField(150)); dockProto.SetField(KeyStore.Layout, new TextField(CollectionDockingView.LayoutString())); - dockProto.SetField(KeyStore.LayoutKeys, new ListField([ KeyStore.Data ])); + dockProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data])); } return dockProto; } @@ -90,7 +112,7 @@ export namespace Documents { imageProto.SetField(KeyStore.Height, new NumberField(300)); imageProto.SetField(KeyStore.Layout, new TextField('Image not found')); // imageProto.SetField(KeyStore.Layout, new TextField('
')); - imageProto.SetField(KeyStore.LayoutFields, new ListField([ KeyStore.Data ])); + imageProto.SetField(KeyStore.LayoutFields, new ListField([KeyStore.Data])); } return imageProto; } @@ -114,7 +136,7 @@ export namespace Documents { collectionProto.SetField(KeyStore.Width, new NumberField(300)); collectionProto.SetField(KeyStore.Height, new NumberField(300)); collectionProto.SetField(KeyStore.Layout, new TextField('')); - collectionProto.SetField(KeyStore.LayoutKeys, new ListField([ KeyStore.Data ])); + collectionProto.SetField(KeyStore.LayoutKeys, new ListField([KeyStore.Data])); } return collectionProto; } -- cgit v1.2.3-70-g09d2