aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormadelinegr <mgriswold99@gmail.com>2019-02-25 20:00:43 -0500
committermadelinegr <mgriswold99@gmail.com>2019-02-25 20:00:43 -0500
commit56f861dcec1443c84af2f3bd98c4422ccdf82e1c (patch)
tree5b22f656a531a3e09a2f5fc929590240cbfbdf89 /src
parent9ce2b722ec0fce077a595d3d7bb01f735f1d2c81 (diff)
pin and remove doc
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts9
-rw-r--r--src/client/views/Main.tsx2
-rw-r--r--src/client/views/PresentationView.tsx37
3 files changed, 47 insertions, 1 deletions
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<Document>, 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} />
<DocumentDecorations />
<ContextMenu />
+ <PresentationView Document={PresentationView.Instance} />
<div style={{ position: 'absolute', bottom: '0px', left: '0px', width: '150px' }} ref={imgRef} >
<button onPointerDown={onRowDown(addImageNode, imgRef)} onClick={addClick(addImageNode)}>Add Image</button></div>
<div style={{ position: 'absolute', bottom: '25px', left: '0px', width: '150px' }} ref={textRef}>
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<PresViewProps> {
* 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<Document>())
+ 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<Document>())
+ 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() {