aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Utils.ts2
-rw-r--r--src/client/util/DragManager.ts4
-rw-r--r--src/client/views/DocumentDecorations.tsx9
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx10
-rw-r--r--src/client/views/nodes/DocumentView.tsx43
5 files changed, 39 insertions, 29 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 98f75d3b9..8252ba011 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -6,6 +6,8 @@ import { Document } from './fields/Document';
export class Utils {
+ public static DRAG_THRESHOLD = 4;
+
public static GenerateGuid(): string {
return v4();
}
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 465b97981..91b3ce616 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -158,11 +158,13 @@ export namespace DragManager {
}
export class LinkDragData {
- constructor(linkSourceDoc: Document) {
+ constructor(linkSourceDoc: Document, blacklist: Document[] = []) {
this.linkSourceDocument = linkSourceDoc;
+ this.blacklist = blacklist;
}
droppedDocuments: Document[] = [];
linkSourceDocument: Document;
+ blacklist: Document[];
[id: string]: any;
}
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 539f19707..5c57a829a 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -19,6 +19,7 @@ import { CompileScript } from "../util/Scripting";
import { IconBox } from "./nodes/IconBox";
import { FieldValue, Field } from "../../fields/Field";
import { Documents } from "../documents/Documents";
+import { Utils } from "../northstar/utils/Utils";
const higflyout = require("@hig/flyout");
export const { anchorPoints } = higflyout;
export const Flyout = higflyout.default;
@@ -207,8 +208,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
@action
onMinimizeMove = (e: PointerEvent): void => {
e.stopPropagation();
- let moved = Math.abs(e.pageX - this._downX) > 4 || Math.abs(e.pageY - this._downY) > 4;
- if (moved) {
+ if (Math.abs(e.pageX - this._downX) > Utils.DRAG_THRESHOLD ||
+ Math.abs(e.pageY - this._downY) > Utils.DRAG_THRESHOLD) {
let selDoc = SelectionManager.SelectedDocuments()[0];
let selDocPos = selDoc.props.ScreenToLocalTransform().scale(selDoc.props.ContentScaling()).inverse().transformPoint(0, 0);
let snapped = Math.abs(e.pageX - selDocPos[0]) < 20 && Math.abs(e.pageY - selDocPos[1]) < 20;
@@ -316,7 +317,9 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
if (this._linkerButton.current !== null) {
document.removeEventListener("pointermove", this.onLinkerButtonMoved);
document.removeEventListener("pointerup", this.onLinkerButtonUp);
- let dragData = new DragManager.LinkDragData(SelectionManager.SelectedDocuments()[0].props.Document);
+ let selDoc = SelectionManager.SelectedDocuments()[0];
+ let container = selDoc.props.ContainingCollectionView ? selDoc.props.ContainingCollectionView.props.Document.GetPrototype() : undefined;
+ let dragData = new DragManager.LinkDragData(selDoc.props.Document, container ? [container] : []);
DragManager.StartLinkDrag(this._linkerButton.current, dragData, e.pageX, e.pageY, {
handlers: {
dragComplete: action(emptyFunction),
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 06e8a9fc6..39b42dac9 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -13,6 +13,7 @@ import { PreviewCursor } from "../../PreviewCursor";
import { CollectionFreeFormView } from "./CollectionFreeFormView";
import "./MarqueeView.scss";
import React = require("react");
+import { Utils } from "../../../../Utils";
interface MarqueeViewProps {
getContainerTransform: () => Transform;
@@ -33,7 +34,6 @@ export class MarqueeView extends React.Component<MarqueeViewProps>
@observable _downX: number = 0;
@observable _downY: number = 0;
@observable _visible: boolean = false;
- static DRAG_THRESHOLD = 4;
@action
cleanupInteractions = (all: boolean = false) => {
@@ -74,8 +74,8 @@ export class MarqueeView extends React.Component<MarqueeViewProps>
this._lastX = e.pageX;
this._lastY = e.pageY;
if (!e.cancelBubble) {
- if (Math.abs(this._lastX - this._downX) > MarqueeView.DRAG_THRESHOLD ||
- Math.abs(this._lastY - this._downY) > MarqueeView.DRAG_THRESHOLD) {
+ if (Math.abs(this._lastX - this._downX) > Utils.DRAG_THRESHOLD ||
+ Math.abs(this._lastY - this._downY) > Utils.DRAG_THRESHOLD) {
this._visible = true;
e.stopPropagation();
e.preventDefault();
@@ -101,8 +101,8 @@ export class MarqueeView extends React.Component<MarqueeViewProps>
@action
onClick = (e: React.MouseEvent): void => {
- if (Math.abs(e.clientX - this._downX) < MarqueeView.DRAG_THRESHOLD &&
- Math.abs(e.clientY - this._downY) < MarqueeView.DRAG_THRESHOLD) {
+ if (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD &&
+ Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD) {
PreviewCursor.Show(e.clientX, e.clientY, this.onKeyPress);
// let the DocumentView stopPropagation of this event when it selects this document
} else { // why do we get a click event when the cursor have moved a big distance?
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index b3b9f6e51..252f4d039 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -148,7 +148,8 @@ export class DocumentView extends React.Component<DocumentViewProps> {
onClick = (e: React.MouseEvent): void => {
if (CurrentUserUtils.MainDocId != this.props.Document.Id &&
- (Math.abs(e.clientX - this._downX) < MarqueeView.DRAG_THRESHOLD && Math.abs(e.clientY - this._downY) < MarqueeView.DRAG_THRESHOLD)) {
+ (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD &&
+ Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
SelectionManager.SelectDoc(this, e.ctrlKey);
}
e.stopPropagation();
@@ -230,25 +231,27 @@ export class DocumentView extends React.Component<DocumentViewProps> {
let dstTarg = protoDest ? protoDest : destDoc;
let srcTarg = protoSrc ? protoSrc : sourceDoc;
- linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
- linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
- const prom1 = new Promise(resolve => dstTarg.GetOrCreateAsync(
- KeyStore.LinkedFromDocs,
- ListField,
- field => {
- (field as ListField<Document>).Data.push(linkDoc);
- resolve();
- }
- ));
- const prom2 = new Promise(resolve => srcTarg.GetOrCreateAsync(
- KeyStore.LinkedToDocs,
- ListField,
- field => {
- (field as ListField<Document>).Data.push(linkDoc);
- resolve();
- }
- ));
- Promise.all([prom1, prom2]).finally(() => batch.end());
+ if ((de.data as DragManager.LinkDragData).blacklist.indexOf(dstTarg) === -1) {
+ linkDoc.Set(KeyStore.LinkedToDocs, dstTarg);
+ linkDoc.Set(KeyStore.LinkedFromDocs, srcTarg);
+ const prom1 = new Promise(resolve => dstTarg.GetOrCreateAsync(
+ KeyStore.LinkedFromDocs,
+ ListField,
+ field => {
+ (field as ListField<Document>).Data.push(linkDoc);
+ resolve();
+ }
+ ));
+ const prom2 = new Promise(resolve => srcTarg.GetOrCreateAsync(
+ KeyStore.LinkedToDocs,
+ ListField,
+ field => {
+ (field as ListField<Document>).Data.push(linkDoc);
+ resolve();
+ }
+ ));
+ Promise.all([prom1, prom2]).finally(() => batch.end());
+ }
})
)
);