Skip to content

enable multi root DnD#45428

Merged
isidorn merged 4 commits intomasterfrom
isidorn/multiRootDnD
Mar 13, 2018
Merged

enable multi root DnD#45428
isidorn merged 4 commits intomasterfrom
isidorn/multiRootDnD

Conversation

@isidorn
Copy link
Collaborator

@isidorn isidorn commented Mar 9, 2018

fixes #44554

Not the nicest code but gets the job done for multi select root DnD.
@bpasero please review and let me know if you know how to simplify this. Thanks!

@isidorn isidorn added this to the March 2018 milestone Mar 9, 2018
@bpasero
Copy link
Member

bpasero commented Mar 9, 2018

@isidorn thanks will do


if (source.isRoot && (sources.length > 1 || target instanceof FileStat && !target.isRoot)) {
if (source.isRoot && target instanceof FileStat && !target.isRoot) {
return true; // Root folder can not be moved to a non root file stat. Do not allow root folder move when multi selection drag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment needs an update too I think

uri: folders[index].uri
});
}
private doHandleRootDrop(roots: FileStat[], target: FileStat | Model): TPromise<void> {
Copy link
Member

@bpasero bpasero Mar 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be much easier here to do something like:

  • fill an array of roots that includes everything except the roots that are being dragged
  • find the index where to drop to (if target is model, the index is the length of the array)
  • add the roots that are being dragged into the array at the correct location
  • call workspace editing service with that array

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. This simplifies a bit. This was tackled via 5564db9

for (let index = 0; index < folders.length; index++) {
const data = {
name: folders[index].name,
uri: folders[index].uri
Copy link
Member

@bpasero bpasero Mar 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isidorn also careful here, you are introducing a name property that previously might not have been there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpasero how can I check if the name was there previously?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isidorn you don't need to, just leave name empty

@isidorn
Copy link
Collaborator Author

isidorn commented Mar 13, 2018

Great, thanks for feedback. I feel like I have addressed all the issues -> merging

@isidorn isidorn merged commit 1e129fd into master Mar 13, 2018
@isidorn isidorn deleted the isidorn/multiRootDnD branch March 13, 2018 11:32
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to DND multiple root-folders

2 participants