Skip to content

Maxitems#260

Merged
lukasoppermann merged 4 commits intolukasoppermann:masterfrom
jamestwebber:maxitems
May 13, 2017
Merged

Maxitems#260
lukasoppermann merged 4 commits intolukasoppermann:masterfrom
jamestwebber:maxitems

Conversation

@jamestwebber
Copy link
Contributor

New PR to replace #257 because I borked the Git log

@jamestwebber
Copy link
Contributor Author

jamestwebber commented May 10, 2017

Still needs a test of a pair of connected sortables

if (!dragging || !_listsConnected(sortableElement, dragging.parentElement)) {
return
}
if (maxItems && _filter(_getChildren(sortableElement), _data(sortableElement, 'items')).length >= maxItems) {
Copy link
Owner

Choose a reason for hiding this comment

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

I get your point: #257 (you talking about "class" confused me, I think it means something else outside of js). The clean solution would be to add a new function which filters children differently to only include items with a sortable-item-id.

Until we have this working, can you please add the -1 thingy and a comment //TODO: remove -1 once placeholder items are not included when getting children.

Otherwise people will have a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would cause it's own bugs in other cases? If you have an element that's a child of your sortable but not supposed to be draggable. Maybe that's not a realistic use-case though.

Copy link
Owner

Choose a reason for hiding this comment

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

Hey I don't really understand how this would be a problem, can you explain it in more detail? I don't get what you mean. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to know how many items the sortable contains. If we just count the children of the sortable, we'll count the placeholder and anything else that's in there at the time—we don't know how many non-"items" are inside the sortable, so no constant offset will work in all cases.

If we filter the children by the items option we don't need an offset, but it only works if the user specified that option in a way that excludes the placeholder and anything else inside the sortable. This could be explicitly mentioned in the documentation.

I think your solution of filtering for sortable-item-id is the right thing to do, and lacking that change having no offset (and mentioning this in the doc) is second-best.

Copy link
Owner

Choose a reason for hiding this comment

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

Hey, I am fine with leaving it as long as we mention it in the docs. Could you add this to your PR? Thanks.

hoverClass: false,
debounce: 0
debounce: 0,
maxItems: null
Copy link
Owner

Choose a reason for hiding this comment

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

this should be 0 no null.

@lukasoppermann
Copy link
Owner

Hey @jamestwebber, looks great. Added some small comments.

Are you still looking into writing tests or would you rather we create deal with them later?

@jamestwebber
Copy link
Contributor Author

If you could write the tests that would be great, I don't think I can figure out the right structure while also removing jQuery usage.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 91.358% when pulling 782ef48 on jamestwebber:maxitems into 569970a on lukasoppermann:master.

@lukasoppermann
Copy link
Owner

Hey @jamestwebber, sure, once we have the -1 or not part figured out I'll merge it without tests. One of us can write the tests later on.

Maybe you find some more enhancements or bugs to fix were writing tests is easier (personally I find it really hard to write tests for UI elements where user interaction is required for the test).

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 91.437% when pulling d6533e8 on jamestwebber:maxitems into 569970a on lukasoppermann:master.

@lukasoppermann lukasoppermann merged commit acb562d into lukasoppermann:master May 13, 2017
@lukasoppermann
Copy link
Owner

Thanks @jamestwebber 👍

@jamestwebber jamestwebber deleted the maxitems branch May 13, 2017 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants