blazor-dragdrop icon indicating copy to clipboard operation
blazor-dragdrop copied to clipboard

Nested draggables

Open americanslon opened this issue 5 years ago • 19 comments

I have a list of dragable modules that each have a list of dragable questions. So nested draggables would be sweet.

I tried it and it resulted in all kinds of fuckery so I am guessing it's not supported yet? Any plans to add that?

Thanks!

americanslon avatar Feb 26 '20 18:02 americanslon

Hi @americanslon - thank you for taking the time to contact me.

You are right, nested draggables are not supported. I agree that this is a useful feature. However, not sure when I will go about it, since it requires major changes.

Postlagerkarte avatar Feb 27 '20 08:02 Postlagerkarte

I too need nested ul/li drag/drop ability. I look forward to seeing it!

<ul>
   <li>
      <ul>
         <li>
         </li>
      <\u>
   </li>
<\u>

VR-Architect avatar Apr 12 '20 19:04 VR-Architect

I also vote for this feature. I built a tree component that uses two components (the tree and the branch) whereby nested method calls build out the branches. Even being able to put the Dropzone at the top level (tree component) and then use draggables for everything else (branch component) would be great.

argentini avatar May 05 '20 18:05 argentini

Hi @americanslon - thank you for taking the time to contact me.

You are right, nested draggables are not supported. I agree that this is a useful feature. However, not sure when I will go about it, since it requires major changes.

Postlagerkarte,

As a quick hack, I have achieved a simple nested effect by taking a copy of the core library and duplicating relevant classes/defining a second service etc. This has allowed me to keep both draggable instances separate whilst achieving a nice nested effect through your library as all collections of draggables remain distinct. Obviously this wouldn't be sufficient for n nests but it might be an interesting starting place to properly implement such a feature. Awesome library by the way, thanks so much for your contributions!

If you can imagine below, the two layers of dragables are the templates (blue) which house their own collections of dropzones and the standard draggables (green) which can be moved between blue areas. In case it's not clear, the blue areas are also movable. image

image

samBiggs32 avatar May 27 '20 16:05 samBiggs32

I, too, would like to see this become a feature. My program would require n nests, so duplicating the library isn't a viable alternative. If at all possible, could you tell me what changes you foresee being made in order for this to be feasible? I might take a crack at this myself.

Twuill avatar Jul 22 '20 21:07 Twuill

I, too, would like to see this become a feature. My program would require n nests, so duplicating the library isn't a viable alternative. If at all possible, could you tell me what changes you foresee being made in order for this to be feasible? I might take a crack at this myself.

The predominant issue that you face is making sure that you can trigger a rerender on drag events from the parent in each child draggable, and that the singleton service needs to treat these as separate groups of components. You should be able to achieve that by subscribing to the rerender event in the service dragdrop service and making nested collections of components like drop ones to mimic the UI. I think if you can do that, then you should be able to do draggables no problem as you'll have two-n instances of the nested dragdrop components i.e. Dropzone, draggable items etc. and a structure that represents it. Basically because the service is a singleton it needs to be treated with more care

samBiggs32 avatar Jul 23 '20 00:07 samBiggs32

I was thinking about moving the item handling into the dropzone. This should get rid of the manual need for rerendering in most cases.

<Dropzone>
@foreach(var item in MyList) 
{
	<li>@item.Foo</li>
}
</Dropzone>

would become

<Dropzone Items="MyList">
	<li>@context.CurrentItem.Foo</li>
</Dropzone>

What are your thoughts about this?

Postlagerkarte avatar Jul 23 '20 08:07 Postlagerkarte

I think that makes sense to do, although you'll have to make sure that the rerenders I mentioned still play nicely by subscribing this to the event on the state container

samBiggs32 avatar Jul 23 '20 11:07 samBiggs32

Hi! I would like to have nested dropzones too!

bazarniy avatar Sep 04 '20 19:09 bazarniy

I 15th this nomination. I need to go 3 levels deep ASAP. I would be willing to pay money for this right now.

kinetiq avatar Sep 14 '20 18:09 kinetiq

I 15th this nomination. I need to go 3 levels deep ASAP. I would be willing to pay money for this right now.

How much? https://1drv.ms/v/s!Ai3CKy1cqYPdgYQNcueCpgxHT_lGMg?e=4AJ5ls

Fyi: I will not write an entire application for you. Just 2 components and their models and 1 page demoing how you do it. Any other stuff is with you.

mertoral avatar Sep 20 '20 16:09 mertoral

@mertoral Thanks for the reply - I found another way to get this working, but I could not do it with this lib.

kinetiq avatar Sep 21 '20 02:09 kinetiq

et this working, bu

Made me "almost" as happy as making money out of you. Congrats for being an "engineer" rather than a developer.

mertoral avatar Sep 21 '20 09:09 mertoral

@mertoral I am both, and also a CTO with more work than my team can handle as well as a fair bit of time pressure. I would have absolutely paid for a working component a week ago, especially if it became a contribution to this project that everyone could benefit from. I almost wish it had gone that way. :/ Anyway, good luck out there.

kinetiq avatar Sep 21 '20 12:09 kinetiq

I see a nested demo on the demo site, but not in the source code? Can someone please point me to the nested demo code? Thanks!

VR-Architect avatar Sep 29 '20 15:09 VR-Architect

I found the nested demo in the code waiting to be committed. Awesome work. Any guess on when that version will be committed and ready in nuget? Thanks

VR-Architect avatar Sep 29 '20 15:09 VR-Architect

@VR-Architect FYI, I ended up using a different project for this... It is a wrapper around SortableJS, which is very mature, I think it will be a bit before someone in the Blazorverse solves the problem to this level. This other project is poorly maintained and not being native blazor is a bummer, but it does work today. Details: https://github.com/jbomhold3/BlazorSortableJS/issues/9

kinetiq avatar Sep 29 '20 18:09 kinetiq

g a different project for this... It is a wra

No... It won't :))))))) https://1drv.ms/u/s!Ai3CKy1cqYPdgYQUjMKuJmm7xyBK_A?e=K1ZUid

I cannot share the code unfortunately, but do not give up on this library.. This works with both server-side rendering and wasm

mertoral avatar Sep 30 '20 13:09 mertoral

v1 I guess, this is pre-nested examples on demo...

Just stating the obvious here, the more you nest, the more the performance impact on rendering. Performance is a lot better when rendered server side.

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, 30 Sep 2020 at 14:32, Postlagerkarte [email protected] wrote:

Looks great! Are you using v1 or v2?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Postlagerkarte/blazor-dragdrop/issues/8#issuecomment-701392778, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGDLAB44I6SVSHHVYBGL43SIMXNRANCNFSM4K4LX3CQ .

mertoral avatar Sep 30 '20 14:09 mertoral