From faf0cc17a47aacaef48b4fe18c2f52af0a360805 Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 11 Mar 2019 15:47:15 -0400 Subject: cleaned up linkmenu. --- .../views/collections/CollectionFreeFormView.tsx | 14 +++--- src/client/views/nodes/LinkBox.tsx | 5 +- src/client/views/nodes/LinkMenu.scss | 6 +-- src/client/views/nodes/LinkMenu.tsx | 58 ++++++++-------------- 4 files changed, 37 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index ab6b9d533..cd5f92623 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -62,12 +62,14 @@ export class CollectionFreeFormView extends CollectionViewBase { super.drop(e, de); const docView: DocumentView = de.data["documentView"]; let doc: Document = docView ? docView.props.Document : de.data["document"]; - let screenX = de.x - (de.data["xOffset"] as number || 0); - let screenY = de.y - (de.data["yOffset"] as number || 0); - const [x, y] = this.getTransform().transformPoint(screenX, screenY); - doc.SetNumber(KeyStore.X, x); - doc.SetNumber(KeyStore.Y, y); - this.bringToFront(doc); + if (doc) { + let screenX = de.x - (de.data["xOffset"] as number || 0); + let screenY = de.y - (de.data["yOffset"] as number || 0); + const [x, y] = this.getTransform().transformPoint(screenX, screenY); + doc.SetNumber(KeyStore.X, x); + doc.SetNumber(KeyStore.Y, y); + this.bringToFront(doc); + } } @observable diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx index c7911f554..69df676ff 100644 --- a/src/client/views/nodes/LinkBox.tsx +++ b/src/client/views/nodes/LinkBox.tsx @@ -10,6 +10,7 @@ import { Document } from "../../../fields/Document"; import { ListField } from "../../../fields/ListField"; import { DocumentManager } from "../../util/DocumentManager"; import { LinkEditor } from "./LinkEditor"; +import { CollectionDockingView } from "../collections/CollectionDockingView"; interface Props { linkDoc: Document; @@ -28,6 +29,8 @@ export class LinkBox extends React.Component { let docView = DocumentManager.Instance.getDocumentView(this.props.pairedDoc); if (docView) { docView.props.focus(this.props.pairedDoc); + } else { + CollectionDockingView.Instance.AddRightSplit(this.props.pairedDoc) } } @@ -66,7 +69,7 @@ export class LinkBox extends React.Component { return ( //
-
+

{this.props.linkName}

diff --git a/src/client/views/nodes/LinkMenu.scss b/src/client/views/nodes/LinkMenu.scss index af5b84ec6..a120ab2a7 100644 --- a/src/client/views/nodes/LinkMenu.scss +++ b/src/client/views/nodes/LinkMenu.scss @@ -1,18 +1,18 @@ -#menu-container { +#linkMenu-container { width: 100%; height: auto; display: flex; flex-direction: column; } -#search-bar { +#linkMenu-searchBar { width: 100%; padding: 5px; margin-bottom: 10px; font-size: 12px; } -#link-list { +#linkMenu-list { margin-top: 5px; width: 100%; height: 100px; diff --git a/src/client/views/nodes/LinkMenu.tsx b/src/client/views/nodes/LinkMenu.tsx index 9a95a4f09..5c6b06d00 100644 --- a/src/client/views/nodes/LinkMenu.tsx +++ b/src/client/views/nodes/LinkMenu.tsx @@ -1,17 +1,15 @@ -import { observable, computed, action } from "mobx"; -import React = require("react"); -import { SelectionManager } from "../../util/SelectionManager"; +import { action, observable } from "mobx"; import { observer } from "mobx-react"; -import './LinkMenu.scss' -import { KeyStore } from '../../../fields/KeyStore' -import { props } from "bluebird"; -import { DocumentView } from "./DocumentView"; -import { LinkBox } from "./LinkBox" import { Document } from "../../../fields/Document"; -import { ListField } from "../../../fields/ListField"; -import { TextField } from "../../../fields/TextField"; import { FieldWaiting } from "../../../fields/Field"; +import { Key } from "../../../fields/Key"; +import { KeyStore } from '../../../fields/KeyStore'; +import { ListField } from "../../../fields/ListField"; +import { DocumentView } from "./DocumentView"; +import { LinkBox } from "./LinkBox"; import { LinkEditor } from "./LinkEditor"; +import './LinkMenu.scss'; +import React = require("react"); interface Props { docView: DocumentView; @@ -23,39 +21,27 @@ export class LinkMenu extends React.Component { @observable private _editingLink?: Document; + renderLinkItems(links: Document[], key: Key, type: string) { + return links.map(link => { + let doc = link.GetT(key, Document); + if (doc && doc != FieldWaiting) { + return this._editingLink = link)} type={type} /> + } + }) + } + render() { //get list of links from document let linkFrom: Document[] = this.props.docView.props.Document.GetData(KeyStore.LinkedFromDocs, ListField, []); let linkTo: Document[] = this.props.docView.props.Document.GetData(KeyStore.LinkedToDocs, ListField, []); if (this._editingLink === undefined) { return ( - -