aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-03-27 19:33:56 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-03-27 19:33:56 -0400
commit4704f088af92a8c04a148861c547afa54a276761 (patch)
tree2d3e8a06ea67626daf124408926e4585923ae836
parentfde267b5f11e7218216bc5a9de41208a0a74fad5 (diff)
fixed linking to work with delegates. fixed full screen option and tab dragging bugs.
-rw-r--r--src/client/util/DocumentManager.ts8
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx22
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx2
-rw-r--r--src/client/views/collections/PreviewCursor.tsx2
-rw-r--r--src/client/views/nodes/DocumentView.tsx21
-rw-r--r--src/client/views/nodes/LinkBox.tsx2
-rw-r--r--src/fields/Document.ts14
7 files changed, 47 insertions, 24 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 5b99b4ef8..03df11ad7 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -3,6 +3,8 @@ import { observer } from 'mobx-react';
import { observable, action } from 'mobx';
import { Document } from "../../fields/Document"
import { DocumentView } from '../views/nodes/DocumentView';
+import { KeyStore } from '../../fields/KeyStore';
+import { FieldWaiting } from '../../fields/Field';
export class DocumentManager {
@@ -39,11 +41,15 @@ export class DocumentManager {
// }
// }
+
if (Object.is(doc, toFind)) {
toReturn = view;
return;
}
-
+ let docSrc = doc.GetT(KeyStore.Prototype, Document);
+ if (docSrc && docSrc != FieldWaiting && Object.is(docSrc, toFind)) {
+ toReturn = view;
+ }
})
return (toReturn);
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index d4f510f5d..b77af8cd6 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -196,15 +196,16 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
e.preventDefault();
let docid = (e.target as any).DashDocId;
let tab = (e.target as any).parentElement as HTMLElement;
- Server.GetField(docid, action((f: Opt<Field>) =>
- DragManager.StartDocumentDrag(tab, new DragManager.DocumentDragData(f as Document),
- {
- handlers: {
- dragComplete: action(() => { }),
- },
- hideSource: false
- }))
- );
+ Server.GetField(docid, action((f: Opt<Field>) => {
+ if (f instanceof Document)
+ DragManager.StartDocumentDrag(tab, new DragManager.DocumentDragData(f as Document),
+ {
+ handlers: {
+ dragComplete: action(() => { }),
+ },
+ hideSource: false
+ })
+ }));
}
if (className == "lm_drag_handle" || className == "lm_close" || className == "lm_maximise" || className == "lm_minimise" || className == "lm_close_tab") {
this._flush = true;
@@ -224,7 +225,8 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
this.stateChanged();
}
tabCreated = (tab: any) => {
- tab.titleElement[0].DashDocId = tab.contentItem.config.props.documentId;
+ if (tab.hasOwnProperty("contentItem") && tab.contentItem.config.type != "stack")
+ tab.titleElement[0].DashDocId = tab.contentItem.config.props.documentId;
tab.closeElement.off('click') //unbind the current click handler
.click(function () {
tab.contentItem.remove();
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index adaf810ea..48adce4d8 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -133,7 +133,7 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
return undefined;
}
ctor = Documents.WebDocument;
- options = { height: options.width, ...options, };
+ options = { height: options.width, ...options, title: path };
}
return ctor ? ctor(path, options) : undefined;
}
diff --git a/src/client/views/collections/PreviewCursor.tsx b/src/client/views/collections/PreviewCursor.tsx
index 5d621f321..8ae59a83a 100644
--- a/src/client/views/collections/PreviewCursor.tsx
+++ b/src/client/views/collections/PreviewCursor.tsx
@@ -59,7 +59,7 @@ export class PreviewCursor extends React.Component<PreviewCursorProps> {
if (!e.ctrlKey && !e.altKey && !e.defaultPrevented && !(e as any).DASHFormattedTextBoxHandled) {
//make textbox and add it to this collection
let [x, y] = this.props.getTransform().transformPoint(this._lastX, this._lastY);
- let newBox = Documents.TextDocument({ width: 200, height: 100, x: x, y: y, title: "new" });
+ let newBox = Documents.TextDocument({ width: 200, height: 100, x: x, y: y, title: "typed text" });
this.props.addLiveTextDocument(newBox);
e.stopPropagation();
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 3873a6f89..c31e8b8c4 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -243,15 +243,20 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
let linkDoc: Document = new Document();
- linkDoc.Set(KeyStore.Title, new TextField("New Link"));
- linkDoc.Set(KeyStore.LinkDescription, new TextField(""));
- linkDoc.Set(KeyStore.LinkTags, new TextField("Default"));
-
- sourceDoc.GetOrCreateAsync(KeyStore.LinkedToDocs, ListField, field => { (field as ListField<Document>).Data.push(linkDoc) });
- linkDoc.Set(KeyStore.LinkedToDocs, destDoc);
- destDoc.GetOrCreateAsync(KeyStore.LinkedFromDocs, ListField, field => { (field as ListField<Document>).Data.push(linkDoc) });
- linkDoc.Set(KeyStore.LinkedFromDocs, sourceDoc);
+ destDoc.GetTAsync(KeyStore.Prototype, Document).then((protoDest) =>
+ sourceDoc.GetTAsync(KeyStore.Prototype, Document).then((protoSrc) => runInAction(() => {
+ let dstTarg = (protoDest ? protoDest : destDoc);
+ let srcTarg = (protoSrc ? protoSrc : sourceDoc);
+ linkDoc.Set(KeyStore.Title, new TextField("New Link"));
+ linkDoc.Set(KeyStore.LinkDescription, new TextField(""));
+ linkDoc.Set(KeyStore.LinkTags, new TextField("Default"));
+ linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
+ linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
+ dstTarg.GetOrCreateAsync(KeyStore.LinkedFromDocs, ListField, field => { (field as ListField<Document>).Data.push(linkDoc) })
+ srcTarg.GetOrCreateAsync(KeyStore.LinkedToDocs, ListField, field => { (field as ListField<Document>).Data.push(linkDoc) })
+ }))
+ )
e.stopPropagation();
}
}
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index 638d3b5a7..457fecee3 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -41,7 +41,7 @@ export class LinkBox extends React.Component<Props> {
e.stopPropagation();
let docView = DocumentManager.Instance.getDocumentView(this.props.pairedDoc);
if (docView) {
- docView.props.focus(this.props.pairedDoc);
+ docView.props.focus(docView.props.Document);
} else {
this.props.pairedDoc.GetAsync(KeyStore.AnnotationOn, (contextDoc: any) => {
if (!contextDoc) {
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index cd393d676..e9192f267 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -35,8 +35,18 @@ export class Document extends Field {
public Scale = () => { return this.GetNumber(KeyStore.Scale, 1) }
@computed
- public get Title() {
- return this.GetText(KeyStore.Title, "-untitled-");
+ public get Title(): string {
+ let title = this.Get(KeyStore.Title, true);
+ if (title)
+ if (title != FieldWaiting && title instanceof TextField)
+ return title.Data;
+ else return "<waiting>";
+ let parTitle = this.GetT(KeyStore.Title, TextField);
+ if (parTitle)
+ if (parTitle != FieldWaiting)
+ return parTitle.Data + ".alias";
+ else return "<waiting>.alias";
+ return "-untitled-";
}
@computed