aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-03-20 18:29:32 -0400
committerbob <bcz@cs.brown.edu>2019-03-20 18:29:32 -0400
commitd888a56abfee2934e0426258c7b24cfff3ad1a77 (patch)
treec1698073f5093bdec424d08882980662786b35b8
parent9173f3d1c2c6f46e6fc8f197f0daf74c84d9f8c6 (diff)
switched to a tree view for performance and added dragging tree view items.
-rw-r--r--src/client/documents/Documents.ts3
-rw-r--r--src/client/views/Main.tsx10
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx13
3 files changed, 18 insertions, 8 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index b1e1f8c7b..cf6d7d503 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -212,6 +212,9 @@ export namespace Documents {
export function SchemaDocument(documents: Array<Document>, options: DocumentOptions, id?: string) {
return assignToDelegate(SetInstanceOptions(GetCollectionPrototype(), { ...options, viewType: CollectionViewType.Schema }, [documents, ListField], id), options)
}
+ export function TreeDocument(documents: Array<Document>, options: DocumentOptions, id?: string) {
+ return assignToDelegate(SetInstanceOptions(GetCollectionPrototype(), { ...options, viewType: CollectionViewType.Tree }, [documents, ListField], id), options)
+ }
export function DockDocument(config: string, options: DocumentOptions, id?: string) {
return assignToDelegate(SetInstanceOptions(GetCollectionPrototype(), { ...options, viewType: CollectionViewType.Docking }, [config, TextField], id), options)
}
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index b27f63e52..113132ae6 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -35,6 +35,7 @@ import { faRedoAlt } from '@fortawesome/free-solid-svg-icons';
import { faPenNib } from '@fortawesome/free-solid-svg-icons';
import { faFilm } from '@fortawesome/free-solid-svg-icons';
import { faMusic } from '@fortawesome/free-solid-svg-icons';
+import { faTree } from '@fortawesome/free-solid-svg-icons';
import Measure from 'react-measure';
import { DashUserModel } from '../../server/authentication/models/user_model';
import { ServerUtils } from '../../server/ServerUtil';
@@ -85,6 +86,7 @@ export class Main extends React.Component {
library.add(faPenNib);
library.add(faFilm);
library.add(faMusic);
+ library.add(faTree);
this.initEventListeners();
Documents.initProtos(() => this.initAuthenticationRouters());
@@ -280,7 +282,8 @@ export class Main extends React.Component {
let addTextNode = action(() => Documents.TextDocument({ width: 200, height: 200, title: "a text note" }))
let addColNode = action(() => Documents.FreeformDocument([], { width: 200, height: 200, title: "a freeform collection" }));
- let addSchemaNode = action(() => Documents.SchemaDocument(this.NorthstarCatalog, { width: 200, height: 200, title: "a schema collection" }));
+ let addSchemaNode = action(() => Documents.SchemaDocument([], { width: 200, height: 200, title: "a schema collection" }));
+ let addTreeNode = action(() => Documents.TreeDocument(this.NorthstarCatalog, { width: 200, height: 200, title: "a tree collection" }));
let addVideoNode = action(() => Documents.VideoDocument(videourl, { width: 200, height: 200, title: "video node" }));
let addPDFNode = action(() => Documents.PdfDocument(pdfurl, { width: 200, height: 200, title: "a schema collection" }));
let addImageNode = action(() => Documents.ImageDocument(imgurl, { width: 200, height: 200, title: "an image of a cat" }));
@@ -295,12 +298,11 @@ export class Main extends React.Component {
[React.createRef<HTMLDivElement>(), "music", "Add Audio", addAudioNode],
[React.createRef<HTMLDivElement>(), "globe-asia", "Add Web Clipping", addWebNode],
[React.createRef<HTMLDivElement>(), "object-group", "Add Collection", addColNode],
+ [React.createRef<HTMLDivElement>(), "tree", "Add Tree", addTreeNode],
[React.createRef<HTMLDivElement>(), "table", "Add Schema", addSchemaNode],
]
- let addClick = (creator: () => Document) => action(() => {
- this.mainfreeform!.GetList<Document>(KeyStore.Data, []).push(creator())
- });
+ let addClick = (creator: () => Document) => action(() => this.mainfreeform!.GetList<Document>(KeyStore.Data, []).push(creator()));
return < div id="add-nodes-menu" >
<input type="checkbox" id="add-menu-toggle" />
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index f9da759fd..d6998cd48 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -10,11 +10,12 @@ import "./CollectionTreeView.scss";
import { EditableView } from "../EditableView";
import { setupDrag } from "../../util/DragManager";
import { FieldWaiting } from "../../../fields/Field";
-import { COLLECTION_BORDER_WIDTH } from "./CollectionView";
+import { COLLECTION_BORDER_WIDTH, CollectionView } from "./CollectionView";
import { library } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTrashAlt, faCaretRight, faCaretDown } from '@fortawesome/free-solid-svg-icons';
+import { CollectionDockingView } from "./CollectionDockingView";
export interface TreeViewProps {
document: Document;
@@ -41,7 +42,8 @@ class TreeView extends React.Component<TreeViewProps> {
collapsed: boolean = false;
delete = () => {
- this.props.deleteDoc(this.props.document);
+ CollectionDockingView.Instance.AddRightSplit(this.props.document)
+ //this.props.deleteDoc(this.props.document);
}
@@ -55,10 +57,11 @@ class TreeView extends React.Component<TreeViewProps> {
renderBullet(type: BulletType) {
let onClicked = action(() => this.collapsed = !this.collapsed);
+ let onDoubleClick = action(() => CollectionDockingView.Instance.AddRightSplit(this.props.document));
switch (type) {
case BulletType.Collapsed:
- return <div className="bullet" onClick={onClicked}><FontAwesomeIcon icon="caret-right" /></div>
+ return <div className="bullet" onDoubleClick={onDoubleClick} onClick={onClicked}><FontAwesomeIcon icon="caret-right" /></div>
case BulletType.Collapsible:
return <div className="bullet" onClick={onClicked}><FontAwesomeIcon icon="caret-down" /></div>
case BulletType.List:
@@ -70,6 +73,8 @@ class TreeView extends React.Component<TreeViewProps> {
* Renders the EditableView title element for placement into the tree.
*/
renderTitle() {
+ let reference = React.createRef<HTMLDivElement>();
+ let onItemDown = setupDrag(reference, () => this.props.document, (containingCollection: CollectionView) => this.props.deleteDoc(this.props.document));
let title = this.props.document.GetT<TextField>(KeyStore.Title, TextField);
// if the title hasn't loaded, immediately return the div
@@ -77,7 +82,7 @@ class TreeView extends React.Component<TreeViewProps> {
return <div key={this.props.document.Id}></div>;
}
- return <div className="docContainer"> <EditableView
+ return <div className="docContainer" ref={reference} onPointerDown={onItemDown}> <EditableView
display={"inline"}
contents={title.Data}
height={36} GetValue={() => {