From 23387df535e9ab87a08196aab19de6f937ae9bba Mon Sep 17 00:00:00 2001 From: madelinegr Date: Thu, 28 Feb 2019 00:20:14 -0500 Subject: finished kvp --- src/client/documents/Documents.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/client/documents/Documents.ts') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index ba13cc31b..41f1c9b3f 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -13,6 +13,8 @@ import { CollectionView, CollectionViewType } from "../views/collections/Collect import { HtmlField } from "../../fields/HtmlField"; import { Key } from "../../fields/Key" import { Field } from "../../fields/Field"; +import { KeyValuePane } from "../views/nodes/KeyValuePane" +import { KVPField } from "../../fields/KVPField"; export interface DocumentOptions { x?: number; @@ -35,10 +37,12 @@ export namespace Documents { let imageProto: Document; let webProto: Document; let collProto: Document; + let kvpProto: Document; const textProtoId = "textProto"; const imageProtoId = "imageProto"; const webProtoId = "webProto"; const collProtoId = "collectionProto"; + const kvpProtoId = "kvpProto"; export function initProtos(mainDocId: string, callback: (mainDoc?: Document) => void) { Server.GetFields([collProtoId, textProtoId, imageProtoId, mainDocId], (fields) => { @@ -46,6 +50,7 @@ export namespace Documents { imageProto = fields[imageProtoId] as Document; textProto = fields[textProtoId] as Document; webProto = fields[webProtoId] as Document; + kvpProto = fields[kvpProtoId] as Document; callback(fields[mainDocId] as Document) }); } @@ -98,6 +103,12 @@ export namespace Documents { { panx: 0, pany: 0, scale: 1, layoutKeys: [KeyStore.Data] }); } + function GetKVPPrototype(): Document { + return kvpProto ? kvpProto : + kvpProto = setupPrototypeOptions(kvpProtoId, "KVP_PROTO", KeyValuePane.LayoutString(), + { x: 0, y: 0, width: 300, height: 150, layoutKeys: [KeyStore.Data] }) + } + export function ImageDocument(url: string, options: DocumentOptions = {}) { let doc = SetInstanceOptions(GetImagePrototype(), { ...options, layoutKeys: [KeyStore.Data, KeyStore.Annotations, KeyStore.Caption] }, new URL(url), ImageField); @@ -124,6 +135,11 @@ export namespace Documents { export function DockDocument(config: string, options: DocumentOptions, id?: string) { return SetInstanceOptions(GetCollectionPrototype(), { ...options, viewType: CollectionViewType.Docking }, config, TextField, id) } + export function KVPDocument(document: Document, options: DocumentOptions = {}, id?: string) { + var deleg = GetKVPPrototype().MakeDelegate(id); + deleg.Set(KeyStore.Data, document); + return assignOptions(deleg, options); + } -- cgit v1.2.3-70-g09d2 From 4a42946b5c8ec86e66a89fec2e66971a242e3dbb Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Thu, 28 Feb 2019 09:19:53 -0500 Subject: added css --- .vscode/launch.json | 4 - src/client/documents/Documents.ts | 4 +- .../views/collections/CollectionFreeFormView.tsx | 5 +- src/client/views/nodes/DocumentView.tsx | 4 +- src/client/views/nodes/FieldView.tsx | 2 - src/client/views/nodes/KeyValueBox.scss | 24 ++++++ src/client/views/nodes/KeyValueBox.tsx | 89 ++++++++++++++++++++ src/client/views/nodes/KeyValuePair.tsx | 6 +- src/client/views/nodes/KeyValuePane.scss | 0 src/client/views/nodes/KeyValuePane.tsx | 96 ---------------------- tsconfig.json | 6 +- 11 files changed, 124 insertions(+), 116 deletions(-) create mode 100644 src/client/views/nodes/KeyValueBox.scss create mode 100644 src/client/views/nodes/KeyValueBox.tsx delete mode 100644 src/client/views/nodes/KeyValuePane.scss delete mode 100644 src/client/views/nodes/KeyValuePane.tsx (limited to 'src/client/documents/Documents.ts') diff --git a/.vscode/launch.json b/.vscode/launch.json index 8aa197fa5..074f9ddf0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,10 +12,6 @@ "breakOnLoad": true, "url": "http://localhost:1050", "webRoot": "${workspaceFolder}", - "skipFiles": [ - "${workspaceRoot}/node_modules/**/*.js", - "${workspaceRoot}/node_modules/**/*.ts", - ] }, { "type": "node", diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 41f1c9b3f..1d24ff7d2 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -13,7 +13,7 @@ import { CollectionView, CollectionViewType } from "../views/collections/Collect import { HtmlField } from "../../fields/HtmlField"; import { Key } from "../../fields/Key" import { Field } from "../../fields/Field"; -import { KeyValuePane } from "../views/nodes/KeyValuePane" +import { KeyValueBox } from "../views/nodes/KeyValueBox" import { KVPField } from "../../fields/KVPField"; export interface DocumentOptions { @@ -105,7 +105,7 @@ export namespace Documents { function GetKVPPrototype(): Document { return kvpProto ? kvpProto : - kvpProto = setupPrototypeOptions(kvpProtoId, "KVP_PROTO", KeyValuePane.LayoutString(), + kvpProto = setupPrototypeOptions(kvpProtoId, "KVP_PROTO", KeyValueBox.LayoutString(), { x: 0, y: 0, width: 300, height: 150, layoutKeys: [KeyStore.Data] }) } diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index 137bcf706..96b6d1477 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -16,6 +16,7 @@ import { DocumentView } from "../nodes/DocumentView"; import { FormattedTextBox } from "../nodes/FormattedTextBox"; import { ImageBox } from "../nodes/ImageBox"; import { WebBox } from "../nodes/WebBox"; +import { KeyValueBox } from "../nodes/KeyValueBox" import "./CollectionFreeFormView.scss"; import { COLLECTION_BORDER_WIDTH } from "./CollectionView"; import { CollectionViewBase } from "./CollectionViewBase"; @@ -230,7 +231,7 @@ export class CollectionFreeFormView extends CollectionViewBase { get backgroundView() { return !this.backgroundLayout ? (null) : ( { @computed get mainContent() { return { + + public static LayoutString(fieldStr: string = "DataKey") { return FieldView.LayoutString(KeyValueBox, fieldStr) } + private _ref: React.RefObject; + private _editorView: Opt; + private _reactionDisposer: Opt; + + + constructor(props: FieldViewProps) { + super(props); + + this._ref = React.createRef(); + } + + + + shouldComponentUpdate() { + return false; + } + + + onPointerDown = (e: React.PointerEvent): void => { + if (e.buttons === 1 && this.props.isSelected()) { + e.stopPropagation(); + } + } + onPointerWheel = (e: React.WheelEvent): void => { + e.stopPropagation(); + } + + createTable = () => { + let table: Array = [] + let ret = "waiting" + let doc = this.props.doc.GetT(KeyStore.Data, Document); + if (!doc || doc == "") { + return Loading... + } + let realDoc = doc; + + let ids: { [key: string]: string } = {}; + let protos = doc.GetAllPrototypes(); + for (const proto of protos) { + proto._proxies.forEach((val, key) => { + if (!(key in ids)) { + ids[key] = key; + } + }) + } + + let rows: JSX.Element[] = []; + let i = 0; + for (let key in ids) { + if (i++ % 2 == 0) + rows.push() + else rows.push() + } + return rows; + } + + + render() { + + return (
+ + + + + + + {this.createTable()} + +
KeyFields
+
) + } +} \ No newline at end of file diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx index b8a0cca48..ecdd47a1e 100644 --- a/src/client/views/nodes/KeyValuePair.tsx +++ b/src/client/views/nodes/KeyValuePair.tsx @@ -1,5 +1,5 @@ import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app -import "./KeyValuePane.scss"; +import "./KeyValueBox.scss"; import React = require("react") import { FieldViewProps, FieldView } from './FieldView'; import { Opt, Field } from '../../../fields/Field'; @@ -12,6 +12,7 @@ import { Server } from "../../Server" // Represents one row in a key value plane export interface KeyValuePairProps { + rowStyle: string; fieldId: string; doc: Document; } @@ -33,7 +34,6 @@ export class KeyValuePair extends React.Component { } - render() { if (!this.key) { return error @@ -49,7 +49,7 @@ export class KeyValuePair extends React.Component { selectOnLoad: false, } return ( - {this.key.Name} + {this.key.Name} ) } } \ No newline at end of file diff --git a/src/client/views/nodes/KeyValuePane.scss b/src/client/views/nodes/KeyValuePane.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/client/views/nodes/KeyValuePane.tsx b/src/client/views/nodes/KeyValuePane.tsx deleted file mode 100644 index 90f5b653c..000000000 --- a/src/client/views/nodes/KeyValuePane.tsx +++ /dev/null @@ -1,96 +0,0 @@ - -import Lightbox from 'react-image-lightbox'; -import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app -import "./KeyValuePane.scss"; -import React = require("react") -import { FieldViewProps, FieldView } from './FieldView'; -import { FieldWaiting, Opt, Field } from '../../../fields/Field'; -import { observer } from "mobx-react" -import { observable, action, IReactionDisposer, reaction, ObservableMap } from 'mobx'; -import { KeyStore } from '../../../fields/KeyStore'; -import { RichTextField } from "../../../fields/RichTextField"; -import { element } from 'prop-types'; -import { props } from 'bluebird'; -import { EditorView } from 'prosemirror-view'; -import { Transaction, EditorState } from 'prosemirror-state'; -import { schema } from 'prosemirror-schema-basic'; -import { keymap } from 'prosemirror-keymap'; -import { undo, redo } from 'prosemirror-history'; -import { baseKeymap } from 'prosemirror-commands'; -import { KVPField } from '../../../fields/KVPField'; -import { Document } from '../../../fields/Document'; -import { Key } from '../../../fields/Key'; -import { JSXElement } from 'babel-types'; -import { KeyValuePair } from "./KeyValuePair" - -@observer -export class KeyValuePane extends React.Component { - - public static LayoutString(fieldStr: string = "DataKey") { return FieldView.LayoutString(KeyValuePane, fieldStr) } - private _ref: React.RefObject; - private _editorView: Opt; - private _reactionDisposer: Opt; - - - constructor(props: FieldViewProps) { - super(props); - - this._ref = React.createRef(); - } - - - - shouldComponentUpdate() { - return false; - } - - - onPointerDown = (e: React.PointerEvent): void => { - if (e.buttons === 1 && this.props.isSelected()) { - e.stopPropagation(); - } - } - onPointerWheel = (e: React.WheelEvent): void => { - e.stopPropagation(); - } - - createTable = () => { - let table: Array = [] - let ret = "waiting" - let doc = this.props.doc.GetT(KeyStore.Data, Document); - if (!doc || doc == "") { - return Loading... - } - let realDoc = doc; - - let ids: { [key: string]: string } = {}; - let protos = doc.GetAllPrototypes(); - for (const proto of protos) { - proto._proxies.forEach((val, key) => { - if (!(key in ids)) { - ids[key] = key; - } - }) - } - - let rows: JSX.Element[] = []; - for (let key in ids) { - rows.push() - } - return rows; - } - - - render() { - - return ( - - - - - - {this.createTable()} - -
KeyFields
) - } -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 823fc2732..e2538bc39 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,9 +11,5 @@ "dom", "es2015" ] - }, - "exclude": [ - "node_modules", - "static" - ] + } } \ No newline at end of file -- cgit v1.2.3-70-g09d2