aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-04-12 13:51:07 -0400
committerbobzel <zzzman@gmail.com>2024-04-12 13:51:07 -0400
commita6577f0c085d206db11e491bd4a1e4bae70e0ee6 (patch)
tree4f66a45b8c434a8f2a0c5eb604cf6b77b4f9be69
parent53fbe74037f03456a678d592d0ae5660c2f0d55e (diff)
fixed auto play for trails. fixed presbox to allow drag and drop in addition to pin button. fixed tree view to not 'move' items that have a 'copy' drop action. fixed dragPreDrop functions in tree and stacking views to use source drag action over target drop action.
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx2
-rw-r--r--src/client/views/collections/CollectionStackingViewFieldColumn.tsx21
-rw-r--r--src/client/views/collections/CollectionSubView.tsx19
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx14
-rw-r--r--src/client/views/collections/TreeView.tsx4
-rw-r--r--src/client/views/nodes/trails/PresBox.tsx7
-rw-r--r--src/client/views/nodes/trails/PresElementBox.tsx2
7 files changed, 44 insertions, 25 deletions
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 3a62a53d7..bf0393883 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -316,7 +316,7 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
<DocumentView
ref={action((r: DocumentView) => r?.ContentDiv && this.docRefs.set(doc, r))}
Document={doc}
- TemplateDataDocument={dataDoc ?? (Doc.AreProtosEqual(doc[DocData], doc) ? undefined : doc[DocData])}
+ TemplateDataDocument={dataDoc}
renderDepth={this._props.renderDepth + 1}
PanelWidth={panelWidth}
PanelHeight={panelHeight}
diff --git a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
index 641e01b81..c5292f880 100644
--- a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
+++ b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
@@ -12,7 +12,7 @@ import { TraceMobx } from '../../../fields/util';
import { DivHeight, DivWidth, emptyFunction, returnEmptyString, setupMoveUpEvents } from '../../../Utils';
import { Docs, DocUtils } from '../../documents/Documents';
import { DocumentType } from '../../documents/DocumentTypes';
-import { DragManager } from '../../util/DragManager';
+import { DragManager, dropActionType } from '../../util/DragManager';
import { SnappingManager } from '../../util/SnappingManager';
import { Transform } from '../../util/Transform';
import { undoBatch } from '../../util/UndoManager';
@@ -66,11 +66,26 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent<
_ele: HTMLElement | null = null;
+ protected onInternalPreDrop = (e: Event, de: DragManager.DropEvent, targetDropAction: dropActionType) => {
+ const dragData = de.complete.docDragData;
+ if (dragData) {
+ const sourceDragAction = dragData.dropAction;
+ const sameCollection = !dragData.draggedDocuments.some(d => !this._props.docList.includes(d));
+ dragData.dropAction = !sameCollection // if doc from another tree
+ ? sourceDragAction || targetDropAction // then use the source's dragAction otherwise the target's
+ : sourceDragAction === dropActionType.inPlace // if source drag is inPlace
+ ? sourceDragAction // keep the doc in place
+ : dropActionType.same; // otherwise use same tree semantics to move within tree
+
+ e.stopPropagation();
+ }
+ };
+
// This is likely similar to what we will be doing. Why do we need to make these refs?
// is that the only way to have drop targets?
createColumnDropRef = (ele: HTMLDivElement | null) => {
this.dropDisposer?.();
- if (ele) this.dropDisposer = DragManager.MakeDropTarget(ele, this.columnDrop.bind(this), this._props.Document);
+ if (ele) this.dropDisposer = DragManager.MakeDropTarget(ele, this.columnDrop.bind(this), this._props.Document, this.onInternalPreDrop.bind(this));
else if (this._ele) this.props.refList.splice(this.props.refList.indexOf(this._ele), 1);
this._ele = ele;
};
@@ -345,7 +360,7 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent<
<div>
<div
key={`${heading}-stack`}
- className={`collectionStackingView-masonrySingle`}
+ className="collectionStackingView-masonrySingle"
style={{
padding: `${columnYMargin}px ${0}px ${this._props.yMargin}px ${0}px`,
margin: 'auto',
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index ecc2aea31..32198e3a2 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -4,7 +4,7 @@ import * as rp from 'request-promise';
import { Utils, returnFalse } from '../../../Utils';
import CursorField from '../../../fields/CursorField';
import { Doc, DocListCast, Field, Opt, StrListCast } from '../../../fields/Doc';
-import { AclPrivate } from '../../../fields/DocSymbols';
+import { AclPrivate, DocData } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
@@ -196,13 +196,16 @@ export function CollectionSubView<X>(moreProps?: X) {
@undoBatch
protected onGesture(e: Event, ge: GestureUtils.GestureEvent) {}
- protected onInternalPreDrop(e: Event, de: DragManager.DropEvent, dropAction: dropActionType) {
- if (de.complete.docDragData) {
- // if the dropEvent's dragAction is, say 'embed', but we're just dragging within a collection, we may not actually want to make an embedding.
- // so we check if our collection has a dropAction set on it and if so, we use that instead.
- if (dropAction && !de.complete.docDragData.draggedDocuments.some(d => d.embedContainer === this.Document && this.childDocs.includes(d))) {
- de.complete.docDragData.dropAction = dropAction;
- }
+ protected onInternalPreDrop(e: Event, de: DragManager.DropEvent, targetDropAction: dropActionType) {
+ const dragData = de.complete.docDragData;
+ if (dragData) {
+ const sourceDragAction = dragData.dropAction;
+ const sameCollection = !dragData.draggedDocuments.some(d => d.embedContainer !== this._props.Document);
+ dragData.dropAction = !sameCollection // if doc from another tree
+ ? sourceDragAction || targetDropAction // then use the source's dragAction otherwise the target's
+ : sourceDragAction === dropActionType.inPlace // if source drag is inPlace
+ ? sourceDragAction // keep the doc in place
+ : dropActionType.same; // otherwise use same tree semantics to move within tree
e.stopPropagation();
}
}
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 293c79119..5741fc29b 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -157,14 +157,12 @@ export class CollectionTreeView extends CollectionSubView<Partial<collectionTree
const dragData = de.complete.docDragData;
if (dragData) {
const sourceDragAction = dragData.dropAction;
- const sameTree = () => Doc.AreProtosEqual(dragData.treeViewDoc, this.Document);
- const isAlreadyInTree = () => sameTree || dragData.draggedDocuments.some(d => d.embedContainer === this.Document && this.childDocs.includes(d));
- dragData.dropAction =
- targetDropAction && !isAlreadyInTree() // if dropped document is not in the tree
- ? targetDropAction // then use the target's drop action if it's specified
- : !sameTree() || sourceDragAction === dropActionType.inPlace // if doc from another tree, or a non inPlace source drag action is specified
- ? sourceDragAction // use the source dragAction
- : dropActionType.same; // otherwise use same tree semantics to move within tree
+ const sameTree = dragData.treeViewDoc?.[DocData] === this.dataDoc;
+ dragData.dropAction = !sameTree // if doc from another tree
+ ? sourceDragAction || targetDropAction // then use the source's dragAction otherwise the target's
+ : sourceDragAction === dropActionType.inPlace // if source drag is inPlace
+ ? sourceDragAction // keep the doc in place
+ : dropActionType.same; // otherwise use same tree semantics to move within tree
e.stopPropagation();
}
};
diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx
index 8c29c3ada..4fd49f8fe 100644
--- a/src/client/views/collections/TreeView.tsx
+++ b/src/client/views/collections/TreeView.tsx
@@ -449,7 +449,9 @@ export class TreeView extends ObservableReactComponent<TreeViewProps> {
const addDoc = inside ? this.localAdd : parentAddDoc;
const canAdd = !StrCast((inside ? this.Document : this._props.treeViewParent)?.treeView_FreezeChildren).includes('add') || forceAdd;
if (canAdd && (dropAction !== dropActionType.inPlace || droppedDocuments.every(d => d.embedContainer === this._props.parentTreeView?.Document))) {
- const move = (!dropAction || canEmbed || dropAction === dropActionType.proto || dropAction === dropActionType.move || dropAction === dropActionType.same || dropAction === dropActionType.inPlace) && moveDocument;
+ const move =
+ (!dropAction || (canEmbed && dropAction !== dropActionType.copy) || dropAction === dropActionType.proto || dropAction === dropActionType.move || dropAction === dropActionType.same || dropAction === dropActionType.inPlace) &&
+ moveDocument;
this._props.parentTreeView instanceof TreeView && (this._props.parentTreeView.dropping = true);
const res = droppedDocuments.reduce((added, d) => (move ? move(d, undefined, addDoc) || (dropAction === dropActionType.proto ? addDoc(d) : false) : addDoc(d)) || added, false);
this._props.parentTreeView instanceof TreeView && (this._props.parentTreeView.dropping = false);
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index cd9fec839..91fdb90fc 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -324,8 +324,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// Case 2: Last slide and presLoop is toggled ON or it is in Edit mode
this.nextSlide(0);
progressiveReveal(true); // shows first progressive document, but without a transition effect
+ return 0;
}
- return 0;
+ return false;
}
return this.itemIndex;
};
@@ -963,7 +964,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const func = () => {
const delay = NumCast(this.activeItem.presentation_duration, this.activeItem.type === DocumentType.SCRIPTING ? 0 : 2500) + NumCast(this.activeItem.presentation_transition);
this._presTimer = setTimeout(() => {
- if (!this.next()) this.layoutDoc.presentation_status = this._exitTrail?.() ?? PresStatus.Manual;
+ if (this.next() === false) this.layoutDoc.presentation_status = this._exitTrail?.() ?? PresStatus.Manual;
this.layoutDoc.presentation_status === PresStatus.Autoplay && func();
}, delay);
};
@@ -1065,7 +1066,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
} else if (doc.type !== DocumentType.PRES) {
if (!doc.presentation_targetDoc) doc.title = doc.title + ' - Slide';
- doc.presentation_targetDoc = doc.createdFrom; // dropped document will be a new embedding of an embedded document somewhere else.
+ doc.presentation_targetDoc = doc.createdFrom ?? doc; // dropped document will be a new embedding of an embedded document somewhere else.
doc.presentation_movement = PresMovement.Zoom;
if (this._expandBoolean) doc.presentation_expandInlineButton = true;
}
diff --git a/src/client/views/nodes/trails/PresElementBox.tsx b/src/client/views/nodes/trails/PresElementBox.tsx
index 5b2aa1cde..28139eb14 100644
--- a/src/client/views/nodes/trails/PresElementBox.tsx
+++ b/src/client/views/nodes/trails/PresElementBox.tsx
@@ -61,7 +61,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps>() {
// Since this node is being rendered with a template, this method retrieves
// the actual slide being rendered from the auto-generated rendering template
@computed get slideDoc() {
- return this._props.TemplateDataDocument ?? this.Document;
+ return DocCast(this.Document.rootDocument, this.Document);
}
// this is the document in the workspaces that is targeted by the slide