GithubHelp home page GithubHelp logo

grahamlyus / activeadmin-sortable-tree Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zorab47/active_admin-sortable_tree

0.0 2.0 0.0 121 KB

Show ActiveAdmin index as a nested tree with drag'n'drop

License: MIT License

Ruby 85.72% CoffeeScript 14.28%

activeadmin-sortable-tree's Introduction

ActiveAdmin Sortable Tree

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

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

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

activeadmin-sortable-tree's People

Contributors

grahamlyus avatar nebirhos avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.