aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-06-25 20:44:34 -0400
committerFawn <fangrui_tong@brown.edu>2019-06-25 20:44:34 -0400
commitca8a78de9957ad27d345ad51fdaee9dae3f096bd (patch)
tree8bc5de93d82034ce488dda85760e0043a1d1e895 /src
parent2d300b0cd3d02c900865c61eacd539efed5289e6 (diff)
can't link to containing collection
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts7
-rw-r--r--src/client/util/DragManager.ts16
-rw-r--r--src/client/views/nodes/LinkEditor.tsx5
-rw-r--r--src/new_fields/Doc.ts3
4 files changed, 9 insertions, 22 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 547687921..b11b5fdf2 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -35,6 +35,7 @@ import { DateField } from "../../new_fields/DateField";
import { UndoManager } from "../util/UndoManager";
import { RouteStore } from "../../server/RouteStore";
import { LinkManager } from "../util/LinkManager";
+import { DocumentManager } from "../util/DocumentManager";
var requestImageSize = require('../util/request-image-size');
var path = require('path');
@@ -87,9 +88,9 @@ export namespace DocUtils {
// let protoSrc = source.proto ? source.proto : source;
// let protoTarg = target.proto ? target.proto : target;
export function MakeLink(source: Doc, target: Doc, targetContext?: Doc, title: string = "", description: string = "", tags: string = "Default") {
- if (LinkManager.Instance.doesLinkExist(source, target)) {
- return;
- }
+ if (LinkManager.Instance.doesLinkExist(source, target)) return;
+ let sv = DocumentManager.Instance.getDocumentView(source);
+ if (sv && sv.props.ContainingCollectionView && sv.props.ContainingCollectionView.props.Document === target) return;
UndoManager.RunInBatch(() => {
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 4be3d82d3..55d8c570f 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -63,8 +63,6 @@ export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: n
let srcTarg = sourceDoc.proto;
let draggedDocs: Doc[] = [];
- // TODO: if not in same context then don't drag
-
if (srcTarg) {
let linkDocs = LinkManager.Instance.getAllRelatedLinks(srcTarg);
if (linkDocs) {
@@ -232,25 +230,20 @@ export namespace DragManager {
(dropData: { [id: string]: any }) => {
dropData.droppedDocuments = dragData.draggedDocuments.map(d => {
let dv = DocumentManager.Instance.getDocumentView(d);
- // console.log("DRAG", StrCast(d.title));
if (dv) {
if (dv.props.ContainingCollectionView === SelectionManager.SelectedDocuments()[0].props.ContainingCollectionView) {
return d;
} else {
- // return d;
let r = Doc.MakeAlias(d);
- // DocUtils.MakeLink(sourceDoc, r);
+ // DocUtils.MakeLink(r, sourceDoc);
return r;
}
} else {
- // return d;
let r = Doc.MakeAlias(d);
- // DocUtils.MakeLink(sourceDoc, r);
+ // DocUtils.MakeLink(r, sourceDoc);
return r;
}
- // return (dv && dv.props.ContainingCollectionView !== SelectionManager.SelectedDocuments()[0].props.ContainingCollectionView) || !dv ?
- // Doc.MakeAlias(d) : d;
});
});
@@ -290,11 +283,6 @@ export namespace DragManager {
StartDrag([ele], dragData, downX, downY, options);
}
- // export function StartLinkProxyDrag(ele: HTMLElement, dragData: DocumentDragData, downX: number, downY: number, options?: DragOptions) {
- // runInAction(() => StartDragFunctions.map(func => func()));
- // StartDrag([ele], dragData, downX, downY, options);
- // }
-
export let AbortDrag: () => void = emptyFunction;
function StartDrag(eles: HTMLElement[], dragData: { [id: string]: any }, downX: number, downY: number, options?: DragOptions, finishDrag?: (dropData: { [id: string]: any }) => void) {
diff --git a/src/client/views/nodes/LinkEditor.tsx b/src/client/views/nodes/LinkEditor.tsx
index eed34b21f..232331204 100644
--- a/src/client/views/nodes/LinkEditor.tsx
+++ b/src/client/views/nodes/LinkEditor.tsx
@@ -133,8 +133,8 @@ class LinkMetadataEditor extends React.Component<LinkMetadataEditorProps> {
render() {
return (
<div className="linkEditor-metadata-row">
- <input className={this._keyError ? "linkEditor-error" : ""} type="text" value={this._key} placeholder="key" onChange={e => this.setMetadataKey(e.target.value)}></input>:
- <input type="text" value={this._value === "new key" ? "" : this._value} placeholder="value" onChange={e => this.setMetadataValue(e.target.value)}></input>
+ <input className={this._keyError ? "linkEditor-error" : ""} type="text" value={this._key === "new key" ? "" : this._key} placeholder="key" onChange={e => this.setMetadataKey(e.target.value)}></input>:
+ <input type="text" value={this._value} placeholder="value" onChange={e => this.setMetadataValue(e.target.value)}></input>
<button onClick={() => this.removeMetadata()}><FontAwesomeIcon icon="times" size="sm" /></button>
</div>
);
@@ -221,6 +221,7 @@ export class LinkGroupEditor extends React.Component<LinkGroupEditorProps> {
groupMdKeys.forEach((key) => {
let val = StrCast(mdDoc[key]);
+ console.log(key, val);
metadata.push(
<LinkMetadataEditor key={"mded-" + this._metadataIds.get(key)} id={this._metadataIds.get(key)!} groupType={groupType} mdDoc={mdDoc} mdKey={key} mdValue={val} changeMdIdKey={this.changeMdIdKey} />
);
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index f6fd44d61..d7411e63e 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -260,13 +260,10 @@ export namespace Doc {
}
} else {
if (field instanceof RefField) {
- console.log("equals field, ref", key);
copy[key] = field;
} else if (field instanceof ObjectField) {
- console.log("copy field, object", key);
copy[key] = ObjectField.MakeCopy(field);
} else {
- console.log("equals field", key);
copy[key] = field;
}
}