Inconstancies with no/multiple selection API on Collection Views #173

Closed
jribar opened this Issue Feb 3, 2011 · 3 comments

Comments

Projects
None yet
5 participants
@jribar
Contributor

jribar commented Feb 3, 2011

CollectionView is expecting to find allowsMultipleSelection set on the content object (which assumes that SelectionSupport is mixed in) rather then as a property on the CollectionView itself.

However ColectionView ignores the allowsEmptySelection property from the SelectionSupport mixin. This feature is available by setting the completely undocumented allowDeselectAll property on the CollectionView.

This API should be cleaned up so that for collections where you can select 0 or more items, you do not have to define one property on the content object/controller and the other on the CollectionView.

@ghost ghost assigned ColinCampbell Apr 14, 2011

@publickeating

This comment has been minimized.

Show comment
Hide comment
@publickeating

publickeating Jun 19, 2012

Member

I'm just going through old tickets attempting to clear out the large backlog.

There is definitely an inconsistency here, but I'm not sure what the solution is yet. If you bind up the selection to an object that has SelectionSupport (like ArrayController), then the selection is prevented from being incorrect by the configuration of that object. If you used a delegate, you could control the behaviour also. However, the way that CollectionView determines this is weird as you noted above.

I'm going to see if I can't just mix SelectionSupport into CollectionView and simplify it and SC.CollectionViewDelegate at the same time, so that the result would be that you could set allowsMultipleSelection & allowsEmptySelection on the view or on the content/delegate.

Member

publickeating commented Jun 19, 2012

I'm just going through old tickets attempting to clear out the large backlog.

There is definitely an inconsistency here, but I'm not sure what the solution is yet. If you bind up the selection to an object that has SelectionSupport (like ArrayController), then the selection is prevented from being incorrect by the configuration of that object. If you used a delegate, you could control the behaviour also. However, the way that CollectionView determines this is weird as you noted above.

I'm going to see if I can't just mix SelectionSupport into CollectionView and simplify it and SC.CollectionViewDelegate at the same time, so that the result would be that you could set allowsMultipleSelection & allowsEmptySelection on the view or on the content/delegate.

@dcporter

This comment has been minimized.

Show comment
Hide comment
@dcporter

dcporter Dec 23, 2013

Member

In theory, each object should be deciding for itself what kind of selection it supports, with some kind of lowest common denominator settled on in bound situation. Maybe SelectionSupport can actively enforce its flags by turning selection into a read/write calculated property? Then mix it into both sides. That should just magically work.

Member

dcporter commented Dec 23, 2013

In theory, each object should be deciding for itself what kind of selection it supports, with some kind of lowest common denominator settled on in bound situation. Maybe SelectionSupport can actively enforce its flags by turning selection into a read/write calculated property? Then mix it into both sides. That should just magically work.

@nicolasbadia

This comment has been minimized.

Show comment
Hide comment
@nicolasbadia

nicolasbadia Feb 22, 2018

Member

I believe this two commits 3f563bc and 2fcf3c4 solve this issue.
They define allowsEmptySelection and allowsMultipleSelection as computed properties on SC.Collection. This way, if you don't want to set theses properties on the delegate/content, you can directly override them on the collection.

Member

nicolasbadia commented Feb 22, 2018

I believe this two commits 3f563bc and 2fcf3c4 solve this issue.
They define allowsEmptySelection and allowsMultipleSelection as computed properties on SC.Collection. This way, if you don't want to set theses properties on the delegate/content, you can directly override them on the collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment