From 56f861dcec1443c84af2f3bd98c4422ccdf82e1c Mon Sep 17 00:00:00 2001 From: madelinegr Date: Mon, 25 Feb 2019 20:00:43 -0500 Subject: pin and remove doc --- src/client/documents/Documents.ts | 9 +++++++++ src/client/views/Main.tsx | 2 ++ src/client/views/PresentationView.tsx | 37 ++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 15ecfbfe6..376f27192 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -11,6 +11,7 @@ import { CollectionView, CollectionViewType } from "../views/collections/Collect import { FieldView } from "../views/nodes/FieldView"; import { HtmlField } from "../../fields/HtmlField"; import { WebView } from "../views/nodes/WebView"; +import { PresentationView } from "../views/PresentationView"; export interface DocumentOptions { x?: number; @@ -190,4 +191,12 @@ export namespace Documents { export function DockDocument(config: string, options: DocumentOptions, id?: string) { return CollectionDocument(config, CollectionViewType.Docking, options, id) } + + export function PresentationDocument(documents: Array, options: DocumentOptions, id?: string) { + let doc = GetCollectionPrototype().MakeDelegate(id); + setupOptions(doc, options); + doc.SetData(KeyStore.Data, documents, ListField); + doc.SetNumber(KeyStore.ViewType, CollectionViewType); + return doc; + } } \ No newline at end of file diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 17dda899d..be6fe304a 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -18,6 +18,7 @@ import { CollectionDockingView } from './collections/CollectionDockingView'; import { FieldWaiting } from '../../fields/Field'; import { UndoManager } from '../util/UndoManager'; import { DragManager } from '../util/DragManager'; +import { PresentationView } from './PresentationView'; configure({ @@ -131,6 +132,7 @@ Documents.initProtos(() => { ContainingCollectionView={undefined} /> +
diff --git a/src/client/views/PresentationView.tsx b/src/client/views/PresentationView.tsx index bbd3bf71a..0a9183023 100644 --- a/src/client/views/PresentationView.tsx +++ b/src/client/views/PresentationView.tsx @@ -5,6 +5,8 @@ import { ListField } from "../../fields/ListField"; import React = require("react") import { TextField } from "../../fields/TextField"; import { observable, action } from "mobx"; +import { Field } from "../../fields/Field"; +import { Documents } from '../documents/Documents'; export interface PresViewProps { Document: Document; @@ -60,8 +62,41 @@ export class PresentationView extends React.Component { * Adds a document to the presentation view **/ @action - public PinDoc(document: Document) { + public PinDoc(doc: Document) { + //add this new doc to props.Document + if (this.props.Document.Get(KeyStore.Data) instanceof Field) { + const value = this.props.Document.GetData(KeyStore.Data, ListField, new Array()) + value.push(doc); + } else { + this.props.Document.SetData(KeyStore.Data, [doc], ListField); + } + + //TODO: open presentation view if not already open + Documents.PresentationView([], { width: 200, height: 200, title: "a feeform collection" }) + } + + /** + * Removes a document from the presentation view + **/ + @action + public RemoveDoc(doc: Document) { + const value = this.props.Document.GetData(KeyStore.Data, ListField, new Array()) + let index = -1; + for (let i = 0; i < value.length; i++) { + if (value[i].Id == doc.Id) { + index = i; + break; + } + } + if (index !== -1) { + value.splice(index, 1) + //TODO: do i need below lines?? + // SelectionManager.DeselectAll() + // ContextMenu.Instance.clearItems() + return true; + } + return false } render() { -- cgit v1.2.3-70-g09d2