-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dragula within Dragula #868
Comments
Search the existing issues for ‘nested’. |
Thanks. that did bear some interesting results but nothing conclusive. I still am as far as can be from solving this. are you sure you understood that I'm not trying to drag from one bag to another? I'm trying to drag from one bag to the same then be able to drag children (from that element i just dragged) in between themselves. I have two bags a parent bag and a children bag and they should not mingle ('Client' is draggable but so are 'aadsd', 'zqds', and 'yghibv') Here's my code :
Typescript :
the only solution I've found for now is to use drag handles and remove all |
You’re doing a lot of things wrong. At minimum, without rewriting your code for you:
Maybe don’t leap to the conclusion there is a bug just yet. |
And yes, as I have mentioned in other related threads, I understand you cannot drag from one bag to another. That is actually the definition of a bag in this library: a grouping of Dragula-enabled containers, between which items may be dragged. |
okay. So it would work if I used arrays of arrays instead of arrays of strings? |
Oh, and you’ve done another classic blunder, which is putting the [dragula] and [dragulaModel] on every item enumerated by *ngFor. Put them on the parent. I would say that’s a documentation problem since so many people report their misuse as an issue, but I don’t know how the extremely simple example code could be more clear, and as a percentage of total users, it’s a small population. |
Well yes... at some point you’re going to have to have a data structure with an array of arrays, or at least an optimised approximation with dictionaries and IDs. You are building a Trello clone — how far are you really going to get with two arrays of strings called groupList and groups? Maybe try building something simpler and working up to more complicated arrangements. I know that this library is actually very difficult to use for anything except the basic demos. I am working on a replacement for the whole thing over at https://cormacrelf.github.io/angular-skyhook/ - but the ‘kanban board’ is not production ready. Or if you’re really early in your project, switch to react-beautiful-dnd. It does everything you’re trying to do already, and you could focus on the data model. |
about by moving the [dragula] and [dragulaModel] on every item enumerated by *ngFor to the parent fixed all bugs. I don't think the docs are at fault here rather ts-lint which screams at you for an unknown ref, and you're like "oh of course, what a dumbass I am, I put them on the parent, how will dragula even be able to know what I'm referencing? I'll just move it down at least to the same line and yep... syntax error gone" but indeed if I instead turn a blind eye to that error and follow what you said it works. I don't understand how or why ...well the why makes sense (you don't want to be checking the array on every single entry of the array, just where the whole array is). ...however the how is more mysterious. but ok, that's how it should be. |
What? Why would tslint complain about that? The things you’re referring to exist and are in context. |
Also Dragula works exclusively with parent elements. The upstream Dragula is used by telling it to work on a container div, and make all its direct children draggable. This is a barebones Angular wrapper. |
Also dragulaModel is not meant to refer to each element of an array. Like Dragula itself, you pass it the whole array that it will be manipulating. It is terrible. It is the source of like 90% of bug reports and misuse here. When I used ng2-dragula, I did not use dragulaModel. I said my alternative library’s kanban board example wasn’t production ready because of some display glitches in that specific example code... but it’s not dragulaModel bad. |
Today I Learned. but that still doesn't explain how the parent div can reference a name that hasn't been declared yet (at least to me, maybe I'm looking at this wrong |
You’re still looking at it wrong. You shouldn’t be passing elem to dragulaModel at all. You should pass exactly the same array that ngFor enumerated over. That is in scope. |
Ooohhh
aren't my hands bound in this? the array that i'll have will be of n groups (dynamic) I can't preemptively declare them. this is just mockup data so far. |
Do yourself a favour and don’t use dragulaModel. Find another way. Use events from the DragulaService, and pull data-attributes off the elements it gives you, and do your own array splicing. Or, do yourself another favour and don’t use ng2-dragula. |
Be free, my friend. Run away from this ridiculous library. It will only hurt you. |
okay. the thing is time is of the essence. I'm on my bosses leash and he keeps screaming "faster!" So for now I'll do re-impl of the multiple callbacks of this lib + my own data splicing (which I have experience with so that doesn't phase me). had I had more time I would have done the whole thing from scratch. I've used draggable in angular before. I just needed to use a lib to gain time. thanks you've been an excellent aid and great counsel |
Well, dragulaModel is fine for a fast mock-up. Please just follow some existing examples and model your solution on that. But — you could just steal the entire kanban board example verbatim right off https://cormacrelf.github.io/angular-skyhook/examples/index.html#/kanban . There’s so much documentation you could probably have it running in an hour if you copied that unreleased angular-skyhook-card-list package into your code. |
And no worries mate. Best of luck. |
hey thanks again
so far it's proving much more difficult than that. there's a lot of non-package code being referenced : I don't get what I'm supposed to do here. gonna go read some impl doc, see where I get |
Ok, this library is definitely as Angular 6 as it gets and I love that but I'm over 1h, I can't afford to delve deeper. maybe in a later sprint when I have more time. |
@tatsujb I mentioned that:
You'd have to change to a ./ relative path to reference it. Anyway. (Also: I'm rewriting the guts of it not to use flex ordering, and instead use a kind of double-buffered data update pattern. Like react-sortable-tree.) |
@cormacrelf btw I never updated you on this but I dropped ng-dragula following your advice right after your last comment. I didn't go the angular-skyhook route either, (though I plan to in future personal projects) but I went the native manual angular route, which turned out much easier then I'd anticipated. thanks again and happy coding! |
Hi @cormacrelf, @cormacrelf, do you think Skyhook could support my following use case? A user should be able to drag and drop objects into dnd containers. Each tree node nests one dnd container. Particular objects when dropped, may create new nodes (a branch) each new node having their own container. Dragging and dropping an object with children nodes, should 'move' the branch. Apologies if this is not the correct place to seek such advice, I don't usually post questions so i wasn't sure. Let me know if i should create a separate request>? Thank you. |
Yep. You could do that. It's always going to be hard though. I can't help you. |
Cool @cormacrelf I will crack on with Skyhook today. Your comment above is help enough. I wasn't sure what direction to go after 2 weeks of trying everything else. Thanks. |
I finally did it! Yes, you were right, it was very difficult. Managed to get it working in Dragula, but will update to Skyhook sometime in the new year. Thanks again. |
I've tried to stop click propagation but to no avail :
I get :
when I want to be able to distinguish between if I'm clicking inside of the inner bag or on the outer with inner bag boolean substracted.
this is possible right?
I just can't figure out how to do it.
The text was updated successfully, but these errors were encountered: