-
Notifications
You must be signed in to change notification settings - Fork 438
feat(sortable): allow extra element before/after ng-repeat #344
Conversation
Fixes angular-ui#41, Fixed angular-ui#177, Fixed angular-ui#98 and Fixes angular-ui#207
@tepez ty for your effort 👍 |
my pleasure @thgreasi |
it('should update model when order changes', function() { | ||
inject(function($compile, $rootScope) { | ||
var element; | ||
element = $compile('<ul ui-sortable ng-model="items"><div class="dummy"></div><li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li><div class="dummy"></div></ul>')($rootScope); |
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.
How about changing the "dummy" elements to be li
's?
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.
Sure @thgreasi . Maybe we should wrap all the specs in sortable.e2e.spec.js
in a function, e.g. function runTests(beforeElement, afterElement)
that will run all the specs, with beforeElement
added before the ul
element and afterElement
after it.
We could than avoid the current duplication of code by doing
runTests(); // run the tests with no added elements
runTests('<li></li>', '<li></li>'); // run the tests with added elements
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.
👍 but I also like the fact that the extra element tests is currently in a separate file.
Feel free to proceed as you wish.
Sorry this takes so long. I will try to review&merge during this weekend. |
…xtra element before/after ng-repeat
No problem @thgreasi. I'm not in a hurry for this. |
It looks like that drag&revert breaks the angular comments order, in the case that:
|
I created a new branch with a commit that fixes your test cases. BUT, this is still not ready to go since it fails when I add an extra test-case with conneted sortables
Please merge this back in your branch so we can continue collaborate on this. |
I think that we should introduce a |
Moreover, we should also find a good way to document the facts that:
All the above + the fact that in most use cases I have seen do far (including my first attempt using this repo), the extra elements will semantically look odd. That made me mark the related issues an a wontfix. (What does a button want next to my shopping list items.) |
@thgreasi I will try to go over it this weekend. |
Cool @tepez . Any feedback on the |
@thgreasi I actually think the current implementation handles custom The reason I think it works is we always use Does this makes sense? |
@tepez Yea, I'm really sorry about that.... I'm really sorry for the inconvenience. I think that this is in good shape to be merged as soon as the tests pass. I have made some commits that fixes the failing tests cases (wanted to keep track of all this in one PR). Lastly, an option like |
This fix allows to have extra elements before/after ng-repeat (only if they are not ng-repeat themselves).
See demonstration at: http://codepen.io/anon/pen/VYgOLv
It passes all the original tests. To test that it works with added items, I duplicated
sortable.e2e.spec.js
intosortable.e2e.extraElements.spec.js
and added a dummydiv
before and after theng-repeat
in every test.Fixes #41, Fixed #177, Fixed #98 and Fixes #207