Rails Admin Nestable
Reorganise model data with a drag and drop tree/list structure.
Installation
To enable rails_admin_nestable, add the following to your Gemfile
:
gem "rails_admin_nestable", git: "git://github.com/dalpo/rails_admin_nestable.git"
Add in your config/initializers/rails_admin.rb
initializer the configuration:
RailsAdmin.config do |config|
config.actions do
dashboard
index
new
export
history_index
bulk_delete
show
edit
delete
history_show
show_in_app
nestable do
visible do
[NavNode, Product].include? bindings[:abstract_model].model
end
end
end
end
Configuration
You could choose between two different configurations for your model:
1. Nestable tree:
To use this configuration, you need to organize your tree model with Ancestry.
Otherwise your model have to respond to the parent
, arrange
and children
methods.
The nestable_tree
methods supports the following options:
position_field
: (symbol) default nil
max_depth
: (integer) default nil
In your config/initializers/rails_admin.rb
initializer:
RailsAdmin.config do |config|
config.actions do
...
end
config.model MyModel do
nestable_tree({ position_field: :position, max_depth: 3 })
end
end
2. Nestable list:
To use this configuration, you need a position field
The nestable_list
methods supports the following options:
position_field
: (symbol) default :position
In your config/initializers/rails_admin.rb
initializer:
RailsAdmin.config do |config|
config.actions do
...
end
config.model MyModel do
nestable_list true
end
end
Screenshot
Thanks
This project rocks and uses MIT-LICENSE.