-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Sortable has-many forms: Revive PR #881 #2117
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
The result should be pretty much the same as @michaek's branch at this point, but this is brought up to date with master. I saw that his branch was about a year out of date, so I did the rebase myself and adjusted tests as necessary (since the |
Yeah no I understand, and thanks for taking this on 💚 |
}); | ||
}); | ||
|
||
}); |
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.
So first, that very last parenthesis shouldn't be there.
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.
Here's a considerably more readable version, though I haven't yet tried it out.
# app/assets/javascripts/active_admin/components/has_many_sortable.js.coffee
reindexSort = ($context, inputName)->
$sortInputs = $("input[name$='#{inputName}']", $context)
$sortInputs.each (index)->
$(@).val(index)
$('.has_many.sortable').each ->
$hasMany = $(@)
inputName = $hasMany.attr('data-sortable-input')
$("li[id$='#{inputName}']", $hasMany).hide()
reindexSort($hasMany, inputName)
$(@).sortable
items: 'fieldset',
update: (event, ui)->
reindexSort($hasMany, inputName)
Still going to work on this @shekibobo? |
I've got a little together, but I can't get anything to work in the test app. I'm not sure what I'm missing, but even after generating a new app, the generated (I think) I just pushed up some of the stuff I've been working with, including your coffeescript rewrite, though as I said, I haven't been able to successfully test it manually. I did update this to the latest master branch, just to keep it in sync. |
Why would anything be in Active Admin's javascript is included in your application implicitly when from you have this: # in my case, app/assets/javascripts/active_admin.js.coffee
#= require active_admin/base
$ ->
$(".foo").bar() // though the default is active_admin.js
//= require active_admin/base
$( function(){
$(".foo").bar();
}); It's specifically that |
Ping :) |
Unfortunately have not had a lot of time to work on this, but I've just rebased it on to the latest master to try to keep it up to date. |
(ping) |
Yeah, I know. 🐢 Javascript is not my strong suit, but I might be getting a better hang of the codebase these days. One of the big issues I had with this was trying to render out some kind of handle within the |
I'm going to close this in favor of #2656. |
This is a feature, I'd love to see get brought in, but #881 hasn't seen any activity in months. I've rebased the effective changes with the current master as a starting point on fleshing out this feature. I haven't tested this in any real projects yet, but might tackle it this morning. If anyone has any thoughts on implementation/styling/whatever, feel free to let me know.