zorab47 / active_admin-sortable_tree

Show ActiveAdmin index as a nested tree with drag'n'drop
MIT License
163 stars 127 forks source link

Sort ignores :class #54

Closed Ewg777 closed 8 years ago

Ewg777 commented 8 years ago
ActiveAdmin.register MyItem, :class => Item do

the lib trying to update positions for MyItem.

zorab47 commented 8 years ago

Should that be configured instead like the following?

ActiveAdmin.register Item, :as => "MyItem" do
  # ...
end

Digging through the various methods used in registering a resource I'm unable to find where the :class option would be used:

zorab47 commented 8 years ago

Any update here @Ewg777 ?

Ewg777 commented 8 years ago

By the way, @zorab47 does this lib support nodes instanced of different classes?

zorab47 commented 8 years ago

What do you mean? In the case of models using single table inheritance it should work properly. But I'm not sure of other cases.

Ewg777 commented 8 years ago
ActiveAdmin.register MyItem do
sortable :tree => true,
           :sortable => true,
           :children_method => :make_children,
...
class MyItem < ActiveRecord::Base
  def make_children
     SomeOtherClass.all
  end
...

Saving in this case doesn't work properly

zorab47 commented 8 years ago

Correct. That would not work because the Resource's sort action assumes it is sorting nodes of the same type as the Resource.

Using something like Global ID may be an option to properly find each node in the hierarchy.