aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/DocumentManager.tsx283
-rw-r--r--src/client/views/Main.tsx2
-rw-r--r--src/client/views/TempTreeView.scss13
-rw-r--r--src/client/views/TempTreeView.tsx41
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx2
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx8
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx4
-rw-r--r--src/client/views/nodes/DocumentView.tsx37
8 files changed, 8 insertions, 382 deletions
diff --git a/src/client/views/DocumentManager.tsx b/src/client/views/DocumentManager.tsx
deleted file mode 100644
index a53ed4a91..000000000
--- a/src/client/views/DocumentManager.tsx
+++ /dev/null
@@ -1,283 +0,0 @@
-import React = require('react')
-import { observer } from 'mobx-react';
-import { observable, action } from 'mobx';
-import { DocumentView } from './nodes/DocumentView';
-import { Document } from "../../fields/Document"
-import { CollectionFreeFormView } from './collections/CollectionFreeFormView';
-import { KeyStore } from '../../fields/KeyStore';
-import { CollectionViewBase } from './collections/CollectionViewBase';
-import { CollectionViewType, CollectionView } from './collections/CollectionView';
-
-
-export class DocumentManager {
-
- //global holds all of the nodes (regardless of which collection they're in)
- @observable
- public DocumentViews: DocumentView[] = [];
-
- // singleton instance
- private static _instance: DocumentManager;
-
- // create one and only one instance of NodeManager
- public static get Instance(): DocumentManager {
- return this._instance || (this._instance = new this());
- }
-
- //private constructor so no other class can create a nodemanager
- private constructor() {
- // this.DocumentViews = new Array<DocumentView>();
- }
-
- public getDocumentView(toFind: Document): DocumentView | null {
-
- let toReturn: DocumentView | null;
- toReturn = null;
-
- //gets document view that is in a freeform canvas collection
- DocumentManager.Instance.DocumentViews.map(view => {
- let doc = view.props.Document;
- // if (view.props.ContainingCollectionView instanceof CollectionFreeFormView) {
- // if (Object.is(doc, toFind)) {
- // toReturn = view;
- // return;
- // }
- // }
-
- if (Object.is(doc, toFind)) {
- toReturn = view;
- return;
- }
-
- })
-
- return (toReturn);
- }
-
- // public getDocumentViewFreeform2(toFind: Document): DocumentView | null {
-
- // let toReturn: DocumentView | null;
- // toReturn = null;
-
- // //gets document view that is in a freeform canvas collection
- // DocumentManager.Instance.DocumentViews.map(view => {
- // let doc = view.props.Document;
- // if (view.props.ContainingCollectionView && view.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
- // if (Object.is(doc, toFind)) {
- // console.log("finding view")
- // toReturn = view;
- // return;
- // }
- // }
- // })
-
- // return (toReturn);
- // }
-
- public getCollectionView(toFind: Document): DocumentView | null {
-
- let toReturn: DocumentView | null;
- toReturn = null;
-
- //gets document view that is in a freeform canvas collection
- DocumentManager.Instance.DocumentViews.map(view => {
- let doc = view.props.Document;
- if (view instanceof CollectionView) {
- console.log("finding view")
- if (Object.is(doc, toFind)) {
- toReturn = view;
- return;
- }
- }
- })
-
- return (toReturn);
- }
-
- // @action
- // public centerNode2(doc: Document | DocumentView): any {
- // //console.log(doc.Title)
- // //gets document view that is in freeform collection
-
- // let docView: DocumentView | null;
-
- // if (doc instanceof Document) {
- // docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
- // }
- // else {
- // docView = doc
- // }
-
- // let scale: number;
- // let XView: number;
- // let YView: number;
-
- // //if the view exists in a freeform collection
- // if (docView) {
- // let { width, height } = docView.size();
-
- // //base case: parent of parent does not exist
- // if (!docView.props.ContainingCollectionView) {
- // scale = docView.props.ScreenToLocalTransform().Scale
- // let doc = docView.props.Document;
- // console.log("hello")
- // XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2)
- // YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2)
- // //set x and y view of parent
- // if (docView instanceof CollectionView) {
- // console.log("here")
- // DocumentManager.Instance.setViewportXY(docView, XView, YView)
- // }
- // }
- // //parent is not main, parent is centered and calls itself
- // else {
- // if (true) {
- // //view of parent
- // let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
- // let doc = docView.props.Document
-
- // //TODO: make sure to test if the parent view is a freeform view. if not, just skip to the next level
- // if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
- // //scale of parent
- // console.log("scale: " + scale)
- // XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2);
- // YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2);
- // // //node.Parent.setViewportXY(XView, YView);
- // DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
- // return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document)
- // }
- // else { return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document) }
- // }
- // else {
- // // return DocumentManager.Instance.centerNode2(docView.props.ContainingCollectionView.props.Document)
- // }
- // }
- // }
- // }
-
- // @action
- // public centerNode4(doc: Document | DocumentView): any {
- // //console.log(doc.Title)
- // //gets document view that is in freeform collection
-
- // console.log("things are happening")
-
- // let docView: DocumentView | null;
-
- // if (doc instanceof Document) {
- // console.log(doc.Title)
- // docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
- // }
- // else {
- // docView = doc
- // console.log(docView.props.Document.Title)
- // }
-
- // let scale: number;
- // let XView: number;
- // let YView: number;
-
- // //if the view exists in a freeform collection
- // if (docView) {
- // let { width, height } = docView.size();
-
- // if (docView.props.ContainingCollectionView) {
- // //view of parent
- // let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
- // let doc = docView.props.Document
-
- // if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
- // //scale of parent
- // XView = (-doc.GetNumber(KeyStore.X, 0) * scale) - (width * scale / 2);
- // YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) - (height * scale / 2);
- // DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
- // return DocumentManager.Instance.centerNode4(docView.props.ContainingCollectionView.props.Document)
- // }
- // else { return DocumentManager.Instance.centerNode4(docView.props.ContainingCollectionView.props.Document) }
- // }
- // }
- // }
-
- @action
- public centerNode(doc: Document | DocumentView, collection: Document): void {
- //console.log(doc.Title)
- //gets document view that is in freeform collection
- let docView: DocumentView | null;
-
- if (doc instanceof Document) {
- console.log(doc.Title)
- docView = DocumentManager.Instance.getDocumentView(doc)
- }
- else {
- docView = doc
- console.log(docView.props.Document.Title)
- }
-
- let scale: number;
- let XView: number;
- let YView: number;
-
- if (docView) {
- let { width, height } = docView.size();
- let scale = docView.props.Document.GetNumber(KeyStore.Scale, 1);
- let doc = docView.props.Document;
- let x = doc.GetNumber(KeyStore.X, 0);
- let y = doc.GetNumber(KeyStore.X, 0);
-
- if (x && y) {
- XView = (-x * scale) - (width * scale / 2);
- YView = (-y * scale) - (height * scale / 2);
- DocumentManager.Instance.setViewportXY(collection, XView, YView)
- }
-
- }
- }
-
- // @action
- // public centerNode3(doc: Document | DocumentView): any {
- // //console.log(doc.Title)
- // //gets document view that is in freeform collection
-
- // let docView: DocumentView | null;
-
- // if (doc instanceof Document) {
- // docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
- // }
- // else {
- // docView = doc
- // }
-
- // let scale: number;
- // let XView: number;
- // let YView: number;
-
- // //if the view exists in a freeform collection
- // if (docView) {
- // let { width, height } = docView.size();
-
- // //parent is not main, parent is centered and calls itself
- // if (docView.props.ContainingCollectionView) {
- // //view of parent
- // let scale = docView.props.ContainingCollectionView.props.Document.GetNumber(KeyStore.Scale, 1)
- // let doc = docView.props.Document
-
- // if (docView.props.ContainingCollectionView.collectionViewType == CollectionViewType.Freeform) {
- // //scale of parent
- // XView = doc.GetNumber(KeyStore.X, 0) - width / 2
- // YView = doc.GetNumber(KeyStore.Y, 0) - height / 2
- // // console.log("X location: " + XView)
- // // console.log("Y location: " + YView)
- // DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
- // return DocumentManager.Instance.centerNode3(docView.props.ContainingCollectionView.props.Document)
- // }
- // else { return DocumentManager.Instance.centerNode3(docView.props.ContainingCollectionView.props.Document) }
- // }
- // }
- // }
-
-
- @action
- private setViewportXY(collection: Document, x: number, y: number) {
- collection.SetNumber(KeyStore.PanX, x);
- collection.SetNumber(KeyStore.PanY, y);
- }
-} \ No newline at end of file
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 2e1deebd1..ce23d9ffb 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -5,7 +5,6 @@ import * as ReactDOM from 'react-dom';
import { Document } from '../../fields/Document';
import { KeyStore } from '../../fields/KeyStore';
import "./Main.scss";
-import { TempTreeView } from './../views/TempTreeView';
import { MessageStore } from '../../server/Message';
import { Utils } from '../../Utils';
import { Documents } from '../documents/Documents';
@@ -81,7 +80,6 @@ Documents.initProtos(mainDocId, (res?: Document) => {
focus={() => { }}
ContainingCollectionView={undefined} />
<DocumentDecorations />
- <TempTreeView />
<ContextMenu />
<div className="main-buttonDiv" style={{ bottom: '0px' }} ref={imgRef} >
<button onPointerDown={setupDrag(imgRef, addImageNode)} onClick={addClick(addImageNode)}>Add Image</button></div>
diff --git a/src/client/views/TempTreeView.scss b/src/client/views/TempTreeView.scss
deleted file mode 100644
index 0a6342ca6..000000000
--- a/src/client/views/TempTreeView.scss
+++ /dev/null
@@ -1,13 +0,0 @@
-.temptree {
- background: #ADD8E6;
- width: 300px;
- height: 200px;
- z-index: 100;
- position: fixed;
- bottom: 0px;
- right: 0px;
- .list {
- padding: 5px;
- color: #1e5162;
- }
-} \ No newline at end of file
diff --git a/src/client/views/TempTreeView.tsx b/src/client/views/TempTreeView.tsx
deleted file mode 100644
index bd73ef887..000000000
--- a/src/client/views/TempTreeView.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { action, observable, computed } from "mobx";
-import React = require("react");
-import { observer } from "mobx-react";
-import { Document } from "../../fields/Document";
-import { ListField } from "../../fields/ListField";
-import "./TempTreeView.scss"
-import { DocumentManager } from "./DocumentManager";
-import { KeyStore } from "../../fields/KeyStore";
-
-
-@observer
-export class TempTreeView extends React.Component {
-
- @action
- onClick(doc: Document) {
-
- let view = DocumentManager.Instance.getDocumentView(doc);
- if (view != null) {
- // DocumentManager.Instance.centerNode(view);
- doc = view.props.Document
- view.props.focus(doc, doc.GetNumber(KeyStore.X, 0), doc.GetNumber(KeyStore.Y, 0))
- }
- }
-
- render() {
- return (
- <div className="tempTree">
- <div className="list">
- {DocumentManager.Instance.DocumentViews.map(doc => {
- return (
- <div key={doc.Id} onClick={() => { this.onClick(doc.props.Document) }}>
- {doc.props.Document.Title}
- </div>
- )
- }
- )}
- </div>
- </div>
- );
- }
-} \ No newline at end of file
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index d5b888e28..6b7c2a191 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -272,7 +272,7 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
ScreenToLocalTransform={this.ScreenToLocalTransform}
isTopMost={true}
SelectOnLoad={false}
- focus={(doc: Document, x: number, y: number) => { }}
+ focus={(doc: Document) => { }}
ContainingCollectionView={undefined} />
</div>
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index fc6021a6e..1b39dcae5 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -22,7 +22,6 @@ import { COLLECTION_BORDER_WIDTH } from "./CollectionView";
import { CollectionViewBase } from "./CollectionViewBase";
import { Documents } from "../../documents/Documents";
import React = require("react");
-import { DocumentManager } from "../DocumentManager";
const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this?
@observer
@@ -224,7 +223,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
const lvalue = this.props.Document.GetT<ListField<Document>>(this.props.fieldKey, ListField);
if (lvalue && lvalue != FieldWaiting) {
return lvalue.Data.map(doc => {
- return (<CollectionFreeFormDocumentView key={doc.Id} Document={doc} ref={focus}//tfs: why are we setting ref={focus}?
+ return (<CollectionFreeFormDocumentView key={doc.Id} Document={doc}
AddDocument={this.props.addDocument}
RemoveDocument={this.props.removeDocument}
ScreenToLocalTransform={this.getTransform}
@@ -270,7 +269,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
//when focus is lost, this will remove the preview cursor
@action
- onBlur = (e: React.FocusEvent<HTMLInputElement>): void => {
+ onBlur = (e: React.FocusEvent<HTMLDivElement>): void => {
this._previewCursorVisible = false;
}
@@ -288,9 +287,6 @@ export class CollectionFreeFormView extends CollectionViewBase {
const panx: number = -this.props.Document.GetNumber(KeyStore.PanX, 0);
const pany: number = -this.props.Document.GetNumber(KeyStore.PanY, 0);
- // const panx: number = this.props.Document.GetNumber(KeyStore.PanX, 0) + this.centeringShiftX;
- // const pany: number = this.props.Document.GetNumber(KeyStore.PanY, 0) + this.centeringShiftY;
- console.log("center:", this.getLocalTransform().transformPoint(this.centeringShiftX, this.centeringShiftY));
return (
<div className="collectionfreeformview-container"
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index cdbd472b9..bf06dd5e9 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -175,6 +175,8 @@ export class CollectionSchemaView extends CollectionViewBase {
return this.props.ScreenToLocalTransform().translate(- COLLECTION_BORDER_WIDTH - this.DIVIDER_WIDTH - this._dividerX, - COLLECTION_BORDER_WIDTH).scale(1 / this._contentScaling);
}
+ focusDocument = (doc: Document) => { }
+
render() {
const columns = this.props.Document.GetList(KeyStore.ColumnsKey, [KeyStore.Title, KeyStore.Data, KeyStore.Author])
const children = this.props.Document.GetList<Document>(this.props.fieldKey, []);
@@ -192,7 +194,7 @@ export class CollectionSchemaView extends CollectionViewBase {
PanelWidth={this.getPanelWidth}
PanelHeight={this.getPanelHeight}
ContainingCollectionView={this.props.CollectionView}
- focus={(doc) => this.props.focus(this.props.Document)}
+ focus={this.focusDocument}
/>
</div>
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index a624c1d7f..9244ca08d 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -21,7 +21,6 @@ import { KeyValueBox } from "./KeyValueBox"
import { WebBox } from "../nodes/WebBox";
import "./DocumentView.scss";
import React = require("react");
-import { DocumentManager } from "../DocumentManager";
import { TextField } from "../../../fields/TextField";
import { Utils } from "../../../Utils";
import { CollectionViewProps } from "../collections/CollectionViewBase";
@@ -40,7 +39,7 @@ export interface DocumentViewProps {
ContentScaling: () => number;
PanelWidth: () => number;
PanelHeight: () => number;
- focus: (doc: Document, x: number, y: number) => void;
+ focus: (doc: Document) => void;
SelectOnLoad: boolean;
}
export interface JsxArgs extends DocumentViewProps {
@@ -191,12 +190,6 @@ export class DocumentView extends React.Component<DocumentViewProps> {
ContextMenu.Instance.displayMenu(e.pageX - 15, e.pageY - 15)
}
- //TODO Monika
- @action
- Center = (e: React.MouseEvent): void => {
- this.props.focus(this.props.Document, this.props.Document.GetNumber(KeyStore.X, 0), this.props.Document.GetNumber(KeyStore.Y, 0))
- }
-
@action
onContextMenu = (e: React.MouseEvent): void => {
e.stopPropagation();
@@ -209,20 +202,11 @@ export class DocumentView extends React.Component<DocumentViewProps> {
ContextMenu.Instance.addItem({ description: "Full Screen", event: this.fullScreenClicked })
ContextMenu.Instance.addItem({ description: "Fields", event: this.fieldsClicked })
- ContextMenu.Instance.addItem({ description: "Center", event: this.Center })
+ ContextMenu.Instance.addItem({ description: "Center", event: () => this.props.focus(this.props.Document) })
ContextMenu.Instance.addItem({ description: "Open Right", event: () => CollectionDockingView.Instance.AddRightSplit(this.props.Document) })
ContextMenu.Instance.addItem({ description: "Freeform", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Freeform) })
ContextMenu.Instance.addItem({ description: "Schema", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Schema) })
ContextMenu.Instance.addItem({ description: "Treeview", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Tree) })
- ContextMenu.Instance.addItem({
- description: "center", event: () => {
- if (this.props.ContainingCollectionView) {
- let doc = this.props.ContainingCollectionView.props.Document;
- doc.SetNumber(KeyStore.PanX, this.props.Document.GetNumber(KeyStore.X, 0) + (this.props.Document.GetNumber(KeyStore.Width, 0) / 2))
- doc.SetNumber(KeyStore.PanY, this.props.Document.GetNumber(KeyStore.Y, 0) + (this.props.Document.GetNumber(KeyStore.Height, 0) / 2))
- }
- }
- })
//ContextMenu.Instance.addItem({ description: "Docking", event: () => this.props.Document.SetNumber(KeyStore.ViewType, CollectionViewType.Docking) })
ContextMenu.Instance.displayMenu(e.pageX - 15, e.pageY - 15)
if (!this.topMost) {
@@ -245,23 +229,6 @@ export class DocumentView extends React.Component<DocumentViewProps> {
/>
}
- //adds doc to global list
- componentDidMount: () => void = () => {
- runInAction(() => {
- DocumentManager.Instance.DocumentViews.push(this);
- })
- }
-
- //removes doc from global list
- componentWillUnmount: () => void = () => {
- runInAction(() => {
- for (let node of DocumentManager.Instance.DocumentViews) {
- if (Object.is(node, this)) {
- DocumentManager.Instance.DocumentViews.splice(DocumentManager.Instance.DocumentViews.indexOf(this), 1);
- }
- }
- })
- }
isSelected = () => {
return SelectionManager.IsSelected(this);
}