Skip to content
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

Improved sortable behavior #359

Merged
merged 9 commits into from Aug 22, 2012
Merged

Conversation

rozwell
Copy link
Contributor

@rozwell rozwell commented May 11, 2012

Changes:

  • added native moving between scopes when scope value was changed and rank not (if rank was changed - we assume superior change)
  • regular saving objects with empty/null scope was setting correct rank but methods like insertAtBottom() didn't allow inserting in null scope (lack of consistency?)
    It is now possible to use those methods in null scope (why not?).
    See: native sorting in sfPropelORMPlugin admin generator
  • removeFromList() was clearing both, scope and rank column and breaking good structure in null scope.
    Now it moves object to the end of null scope
  • swapWith() can now fully operate between scopes - previously it would only exchange ranks, which was fine for the same scope, but would break the structure in both scopes (no exception was thrown)

There are some other issues like when scope column is a FK and onDelete="setnull", removing related/scope object will only clean the scope value leaving ranks untouched.

@travisbot
Copy link

This pull request fails (merged 07ff600 into 82372dd).

@rozwell
Copy link
Contributor Author

rozwell commented May 11, 2012

@travisbot You're right, I will have to adjust and add tests too.
But lets wait for someone to comment if this is a good way to go or shall we change something else?

Edit: Why does removeFromList() sets rank to null but there is no "AND SORTABLE_RANK IS NOT NULL" condition in any query?
Especially in non-scope tables where this could be expected(?)

This behavior needs more solid concept.
For now I'm confused.

@travisbot
Copy link

This pull request fails (merged 9df7198 into 82372dd).

@willdurand
Copy link
Contributor

@rozwell travisbot is... a bot :p

Your work seems ok, but I don't really know this behavior so.. let's see other comments, and try to fix the test suite.

@rozwell
Copy link
Contributor Author

rozwell commented May 12, 2012

@willdurand I know ;)
Unit tests are easy to fix (just 2 failed) and I will add a few more too if these changes are ok.

@willdurand
Copy link
Contributor

It looks fine to me, but as I said, I'm not expert on this. Maybe we should try to expose what the behavior should do, and how before to change everything. What do you think?

@rozwell
Copy link
Contributor Author

rozwell commented May 12, 2012

I took one more look at this behavior and after my modifications we actually need to talk about those 2 things only:

  1. removeFromList() - I'd suggest to remove this method since we can just change the scope to null or if scope isn't used it seems better to add other column to manage visibility like is_visible so there is no need for adding NOT NULL condition mentioned above.
    I've got in mind admin generator so this may affect my judgment since I also see how to manage null ranks.
  2. onDelete="setnull" - removing related object will only clean the scope value leaving ranks untouched and since we sort in null scope too, shouldn't they be moved at the end of it? (makes most sense)

@willdurand
Copy link
Contributor

I think you are changing the behavior of ... this behavior :)

  1. I mean, a null scope should not mean objects are not in a list. The "null" scope is actually a scope, like a "global" scope, or a "default" one I guess. So the removeFromList() makes sense. But I agree with the is_visible, it could a nice option.
  2. You're right!

Sorry for the delay, I tried to learn this behavior a bit more.

@travisbot
Copy link

This pull request fails (merged fb30d63 into 8b02639).

@travisbot
Copy link

This pull request fails (merged 5b06917 into 8b02639).

@travisbot
Copy link

This pull request fails (merged cce76e3d into 8b02639).

@travisbot
Copy link

This pull request fails (merged 957b90a into 8b02639).

@travisbot
Copy link

This pull request fails (merged 7e169b3 into 8b02639).

@rozwell
Copy link
Contributor Author

rozwell commented Aug 12, 2012

@willdurand is there any reason to have boolean _use_scope_ parameter for scope, when you have to set _scope_column_ anyway?
Isn't setting _scope_column_ enough?

@willdurand
Copy link
Contributor

well, I think you can enable/disable the use of scopes easily.

@fzaninotto
Copy link
Member

This PR needs unit tests that fail if the builder is not modified and passes otherwise - this will reveal the interest of tour modification.

@rozwell
Copy link
Contributor Author

rozwell commented Aug 16, 2012

@fzaninotto can you explain with more details?

…in SortableBehaviorObjectBuilderModifierWithScopeTest::testInsertAtRank())
@travisbot
Copy link

This pull request passes (merged 3af6a72 into 441f969).

@rozwell
Copy link
Contributor Author

rozwell commented Aug 16, 2012

Little summary of changes:

  • added native moving between scopes when scope value was changed and rank not (if rank was changed - we assume superior change)
  • methods like insertAtBottom() now works with null scope
  • removeFromList() now moves object to the end of null scope (if scope is used)
  • swapWith() can now fully operate between scopes

TODO:
When scope column is a FK and onDelete="setnull", removing related object should move all objects to null scope (maybe trigger
_removeFromList()_ ?) - is there a proper way to do so?

@rozwell
Copy link
Contributor Author

rozwell commented Aug 19, 2012

Seems ready to be merged.
Any thoughts?

@willdurand
Copy link
Contributor

So null is a scope then?

@fzaninotto
Copy link
Member

ok, I'm +1. Good patch.

@rozwell
Copy link
Contributor Author

rozwell commented Aug 22, 2012

@willdurand yes sir.

willdurand added a commit that referenced this pull request Aug 22, 2012
@willdurand willdurand merged commit 19dc671 into propelorm:master Aug 22, 2012
@willdurand
Copy link
Contributor

Great, merged! Thank you so much.

@willdurand
Copy link
Contributor

Can you port this PR on Propel2? :)

@rozwell
Copy link
Contributor Author

rozwell commented Aug 22, 2012

Sure, but after I fix onDelete="setnull" issue.

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.

None yet

4 participants