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/views/nodes/DocumentView.tsx | 15 ++++++++------- src/views/nodes/FieldView.tsx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 src/views/nodes/FieldView.tsx (limited to 'src/views/nodes') diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx index 1e4cc1cca..20dc6540b 100644 --- a/src/views/nodes/DocumentView.tsx +++ b/src/views/nodes/DocumentView.tsx @@ -9,6 +9,7 @@ import { FieldTextBox } from "../nodes/FieldTextBox" import { Document } from "../../fields/Document"; import { CollectionFreeFormView } from "../collections/CollectionFreeFormView" import { CollectionDockingView } from "../collections/CollectionDockingView" +import { CollectionSchemaView } from "../collections/CollectionSchemaView" import "./NodeView.scss" import { SelectionManager } from "../../util/SelectionManager"; import { ContextMenu } from "../ContextMenu"; @@ -64,16 +65,16 @@ class DocumentContents extends React.Component { let doc = this.props.Document; let bindings = { ...this.props } as any; for (const key of this.layoutKeys) { - bindings[ key.Name + "Key" ] = key; + bindings[key.Name + "Key"] = key; } for (const key of this.layoutFields) { let field = doc.GetField(key); if (field) { - bindings[ key.Name ] = field.GetValue(); + bindings[key.Name] = field.GetValue(); } } return { if (this._mainCont.current != null && this.props.ContainingCollectionView != null) { this._contextMenuCanOpen = false; const rect = this.screenRect; - let dragData: { [ id: string ]: any } = {}; - dragData[ "document" ] = this; - dragData[ "xOffset" ] = e.x - rect.left; - dragData[ "yOffset" ] = e.y - rect.top; + let dragData: { [id: string]: any } = {}; + dragData["document"] = this; + dragData["xOffset"] = e.x - rect.left; + dragData["yOffset"] = e.y - rect.top; DragManager.StartDrag(this._mainCont.current, dragData, { handlers: { dragComplete: this.dragComplete, diff --git a/src/views/nodes/FieldView.tsx b/src/views/nodes/FieldView.tsx new file mode 100644 index 000000000..1c4164089 --- /dev/null +++ b/src/views/nodes/FieldView.tsx @@ -0,0 +1,31 @@ +import React = require("react") +import { DocumentFieldViewProps } from "./DocumentView"; +import { observer } from "mobx-react"; +import { computed } from "mobx"; +import { Field, Opt } from "../../fields/Field"; +import { TextField } from "../../fields/TextField"; +import { NumberField } from "../../fields/NumberField"; + +@observer +export class FieldView extends React.Component { + @computed + get field(): Opt { + const { doc, fieldKey } = this.props; + return doc.GetField(fieldKey); + } + render() { + const field = this.field; + if (!field) { + return

{''}

+ } + if (field instanceof TextField) { + return

{field.Data}

+ } + else if (field instanceof NumberField) { + return

{field.Data}

+ } else { + return

{field.GetValue}

+ } + } + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2