You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My use case is that I would like a tree structure, but to have each level always sorted by name. I'd like to have the tree editor still work for easily setting parent/child relationships.
Currently I have to override the "sort" controller action so that it does not update the "position" field (which I have set to 'name'), or else all my objects get their name changed to numbers:
# Override the one provided by ActiveAdminSortable, since we want it to ignore updates to the sort ordercollection_action:sort,:method=>:postdoresource_name=ActiveAdmin::SortableTree::Compatibility.normalized_resource_name(active_admin_config.resource_name)records=[]params[resource_name].each_pairdo |resource,parent_resource|
parent_resource=resource_class.find(parent_resource)rescuenilrecords << [resource_class.find(resource),parent_resource]enderrors=[]ActiveRecord::Base.transactiondorecords.each_with_indexdo |(record,parent_record),position|
# record.send "#{options[:sorting_attribute]}=", positionifoptions[:tree]record.send"parent=",parent_recordenderrors << {record.id=>record.errors}if !record.saveendendiferrors.empty?head200elserenderjson: errors,status: 422endend
Could we have a config option that allows us to disable the record.send "#{options[:sorting_attribute]}=", position ?
The text was updated successfully, but these errors were encountered:
I'm revisiting this because I thought about it while trying to clean up some code. The problem with your suggestion is that the :sorting_attribute is used as the sort order in index_as_sortable.rb:
My use case is that I would like a tree structure, but to have each level always sorted by name. I'd like to have the tree editor still work for easily setting parent/child relationships.
Currently I have to override the "sort" controller action so that it does not update the "position" field (which I have set to 'name'), or else all my objects get their name changed to numbers:
Could we have a config option that allows us to disable the
record.send "#{options[:sorting_attribute]}=", position
?The text was updated successfully, but these errors were encountered: