-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(drag-drop): add directive to connect drop lists automatically #13754
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
Conversation
|
||
ngOnInit() { | ||
this._dragDropRegistry.registerDropContainer(this); | ||
|
||
if (this._group) { | ||
this._group._items.add(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was debating whether this should live in the CdkDropRegistry
. I decided not to do it, because it was adding a fair bit of code for no real benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/cdk/drag-drop/drag-drop.md
Outdated
@@ -39,6 +39,19 @@ referencing the `id` of another drop container: | |||
<div cdkDropList id="list-two" [cdkDropListConnectedTo]="['list-one']"></div> | |||
``` | |||
|
|||
If you have an unknown amount of connected drop lists, you can use the `cdkDropListGroup` directive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"amount" -> "number"
4515121
to
554c727
Compare
Hi @crisbeto! This PR has merge conflicts due to recent upstream merges. |
554c727
to
10d06f7
Compare
This is fantastic and immensely useful! Much appreciated, @crisbeto |
Doesn't this approach for grouping drop lists require the lists to be in the same template? Before seeing this PR I was thinking about an API for a drop list group mechanism like this:
|
Having cdkDropLists connected with an identifier or something similar would be gold! |
10d06f7
to
3715fa6
Compare
Currently the only way to connect drop lists is via the `cdkDropListConnectedTo` input which works if the consumer knows the amount of drop lists that they're going to have. For dynamic lists they can pass a list of ids, however that can be a little boilerplate-y. These changes introduce the `cdkDropListGroup` directive which can be used to connect a dynamic list of drop containers automatically. Fixes angular#13750.
@sroettering at that point it would be better to generate some kind of identifier for each item and then connect them through @philmtd You can already connect lists by their string |
Yes but then I'd need to know how many lists there are and which IDs they have. When I have lists generated by an *ngFor and additionally other lists that are static it would probably be easier to connect them by a group id. |
@philmtd while I agree with the idea, you are describing a different use case more appropriate for a separate pull request extending the functionality of |
@lightheaded sure this would be another pull request, but that functionality would make this pull request obsolete. So maybe it should be discussed a little more. |
These changes haven't been released yet. |
…13754) Currently the only way to connect drop lists is via the `cdkDropListConnectedTo` input which works if the consumer knows the amount of drop lists that they're going to have. For dynamic lists they can pass a list of ids, however that can be a little boilerplate-y. These changes introduce the `cdkDropListGroup` directive which can be used to connect a dynamic list of drop containers automatically. Fixes #13750.
Besides having a grouped functionality I needed a list who can act as a template. Drags can be transfered/copied from the template to any list. I wrapped the cdkDropList in a component, which registers/unregisters itself to a dragging service, specifiying the group and if it is a template. [cdkDropListConnectedTo] queries with group and isTemplate the dragging service. Having a register/unregister callback would be nice, and also keeps the strategy wanted part of the application. |
Adds an example that was being embedded in the readme, but isn't in the docs. It seems like it was missed in angular#13754 where a reference to it was introduced.
Adds an example that was being embedded in the readme, but isn't in the docs. It seems like it was missed in #13754 where a reference to it was introduced.
Adds an example that was being embedded in the readme, but isn't in the docs. It seems like it was missed in angular#13754 where a reference to it was introduced.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently the only way to connect drop lists is via the
cdkDropListConnectedTo
input which works if the consumer knows the amount of drop lists that they're going to have. For dynamic lists they can pass a list of ids, however that can be a little boilerplate-y. These changes introduce thecdkDropListGroup
directive which can be used to connect a dynamic list of drop containers automatically.Fixes #13750.