No commit activity in last 3 years
No release in over 3 years
test description
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.16
~> 10.0
 Project Readme

ActiveAdmin Sortable Tree¶ ↑

This gem adds a tree and a list view to your ActiveAdmin resource index, both sortable via drag’n’drop.

Installation¶ ↑

  • Gemfile:

    gem "activeadmin-sortable-tree", :github => "nebirhos/activeadmin-sortable-tree", :branch => "master"
    

WARNING! Not compatible with neo/activeadmin-sortable

Usage (Tree)¶ ↑

  • Admin (eg. app/admin/page.rb):

    ActiveAdmin.register Page do
      sortable tree: true
    
      index :as => :sortable do
        label :title # item content
        default_actions
      end
    end
    
  • Model: activeadmin-sortable-tree is agnostic to the tree implementation. All you have to do is expose a sorting attribute and a few tree methods (:parent, :children and :roots). Let’s say you use Ancestry:

    class Page < ActiveRecord::Base
      attr_accessible :title, :body, :position
      has_ancestry :orphan_strategy => :rootify
    end
    

    You can configure these methods if you need:

    ActiveAdmin.register Page do
      sortable tree: true,
               max_levels: 0, # infinite indent levels
               protect_root: false, # allow root items to be dragged
               sorting_attribute: :position,
               parent_method: :parent,
               children_method: :children,
               roots_method: :roots
      ...
    end

Usage (List)¶ ↑

  • Admin (eg. app/admin/page.rb):

    ActiveAdmin.register Page do
      sortable
    
      index :as => :sortable do
        label :title # item content
        default_actions
      end
    end
    
  • Model: Sortable list assumes you have a :position field in your resource. Of course it’s configurable:

    ActiveAdmin.register Page do
      sortable tree: false, # default
               sorting_attribute: :my_position_field
      ...
    end

Usage (generic ActiveAdmin index)¶ ↑

Currently supports only IndexAsBlock, more to come!

  • Admin (eg. app/admin/page.rb):

    ActiveAdmin.register Page do
      sortable
    
      index :as => :block do |page|
        # item content
      end
    end
    
  • Model: Same as list view (see above)

Usage ()¶ ↑

To implement "Add Subcategory" in the index view,
   STEP 1:Create the below method in the resource file
       ActiveAdmin.register ResourceModel do
               ...
       member_action :new_child do
           //Code to display Add New [Child Resource] form
           //params[:id] is the parent object id
           //Create the corresponding form in app/views/admin/...
       end
               ...
   end

   STEP 2:Add Label to Locales en.yml
       add_subcategory: "Add Subcategory [Text or html entity]"

Copyright © 2013 Francesco Disperati, Cantiere Creativo. See the file MIT-LICENSE for details.