• Stars
    star
    104
  • Rank 329,068 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RailsAdmin drag & drop custom action sorting list and tree (using the Ancestry gem) 💎

Rails Admin Nestable

RailsAdmin Drag and drop tree view for Ancestry and mongoid-ancestry gem

Sample demo available at: https://github.com/dalpo/rails_admin_nestable_demo

Gem Version Code Climate

Installation

To enable rails_admin_nestable, add the following to your Gemfile:

gem 'rails_admin_nestable', '~> 0.3.2'

Add in your config/initializers/rails_admin.rb initializer the configuration:

RailsAdmin.config do |config|
  config.actions do
    # root actions
    dashboard                     # mandatory
    # collection actions
    index                         # mandatory
    new
    export
    history_index
    bulk_delete
    # member actions
    show
    edit
    delete
    history_show
    show_in_app

    # Add the nestable action for configured models
    nestable
  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 or Mongoid 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
  • enable_callback: (boolean) default => false
  • scope: (symbol | proc) default => nil
  • live_update: (boolean | :only) default => true (:only is for live updating only)

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
  • enable_callback: (boolean) default => false
  • scope: (symbol | proc) default => nil
  • live_update: (boolean | :only) default => true (:only is for live updating only)

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

Authorization with CanCan

Sample ability:

class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= User.new

    if user.admin?
      can :access, :rails_admin
      can :dashboard

      if user.role? :superadmin
        can :manage, :all
      end

      if user.role? :editor
        can :edit, :all
        can :nestable, :all
      end
    end
  end
end

Screenshot

Nestable view

Contributing

Submitting a Pull Request:

  1. Fork the repository.
  2. Create a topic branch.
  3. Implement your feature or bug fix.
  4. Add, commit, and push your changes.
  5. Submit a pull request.

Thanks

License

This project rocks and uses MIT-LICENSE.

Copyright 2015 Andrea Dal Ponte

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

rails_admin_clone

Simple RailsAdmin plugin to clone records 💎
Ruby
27
star
2

CakeAttachment

CakeAttachment is a plugin for CakePHP to improved easy file upload. The CakeAttachment upload Behavior intent was to keep setup as easy as possible and to treat files as a simple table column. It manages simple validations and can transform its assigned image into thumbnails if needed.
PHP
15
star
3

cakephp_imap_datasource

Cakephp Imap datasource that allows querying the Imap mailbox of a configured account.
PHP
12
star
4

carrierwave_globalize

Use Globalize to manage Carrierwave translated fields 💎
Ruby
10
star
5

seorel

Ruby on Rails SEO Metatags plugin for ActiveRecord models 💎
Ruby
9
star
6

jquery-countdown

Countdown that work with Internet Explorer!
JavaScript
7
star
7

cakephp_csv_datasource

Cakephp CSV files datasource
PHP
5
star
8

CakeBreadcrumbs

Simple Breadcrumbs utilities for CakePHP
PHP
4
star
9

shopping-cart-billing

Ruby
3
star
10

rails_admin_nestable_demo

rails_admin_nestable plugin demo
Ruby
3
star
11

ar_enum_i18n

ActiveRecord Enum internationalizations utils gem
Ruby
2
star
12

kangoo

Facebook Ads API SDK for Ruby
Ruby
2
star
13

ordered_list

CakePHP plugin that provides the basic capabilities for sorting and reordering records in a database table
PHP
2
star
14

jquery_jexp_accordion

jQuery jexp Accordion
1
star
15

recaptcha

Recaptcha plugin for CakePHP
PHP
1
star
16

jsuperzoom

1
star
17

JqoogleMap

Google Maps jQuery Plugin
1
star
18

PieTime

CakePHP simple date/time localization
PHP
1
star
19

CakeLocalize

CakePHP simple database internazionalization
PHP
1
star
20

jquery_zoomable

jquery imageNavigable lib
JavaScript
1
star
21

dockerfiles

Shell
1
star
22

cakephp_ms_access_odbc_datasource

Cakephp MS Access datasource via ODBC
PHP
1
star
23

dalpo.github.io

HTML
1
star
24

devbox

My development vagrant machine
Makefile
1
star