feat: Moving documents via drag and drop in sidebar (#1717)

* wip: added some basic drag and drop UI for combining items

* refactor: pathToDocument to accept only id

* fix: Multiple drop backends error
fix: Incorrect styling dragging over active collection
fix: Stay in disabled state until save is complete

* Improving display while moving doc

* fix: update by user should be changed when moving a doc

* add move guard to drag

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Nan Yu
2020-12-15 19:07:29 -08:00
committed by GitHub
parent 3469b82beb
commit 051ecab0fc
12 changed files with 285 additions and 166 deletions

View File

@@ -79,12 +79,12 @@ export default class Collection extends BaseModel {
return result;
}
pathToDocument(document: Document) {
pathToDocument(documentId: string) {
let path;
const traveler = (nodes, previousPath) => {
nodes.forEach((childNode) => {
const newPath = [...previousPath, childNode];
if (childNode.id === document.id) {
if (childNode.id === documentId) {
path = newPath;
return;
}

View File

@@ -268,7 +268,7 @@ export default class Document extends BaseModel {
};
move = (collectionId: string, parentDocumentId: ?string) => {
return this.store.move(this, collectionId, parentDocumentId);
return this.store.move(this.id, collectionId, parentDocumentId);
};
duplicate = () => {