Giter Site home page Giter Site logo

fundthrough / activeadmin_reorderable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dkniffin/activeadmin_reorderable

0.0 5.0 0.0 18 KB

Adds drag and drop reordering to your ActiveAdmin tables

License: MIT License

Ruby 57.37% JavaScript 40.94% CSS 1.69%

activeadmin_reorderable's Introduction

ActiveAdmin Reorderable

Drag and drop to reorder your ActiveAdmin tables.

Drag and drop reordering

Requirements

Your resource classes must respond to insert_at ala the acts_as_list API. You don't need to use acts_as_list, but if you don't, make sure to define insert_at.

Installation

  • Add gem 'activeadmin_reorderable' to Gemfile
  • Add #= require activeadmin_reorderable to app/assets/javascripts/active_admin.js.coffee
  • Add @import "activeadmin_reorderable"; as the last @import statement in app/assets/stylesheets/active_admin.css.scss

Use

parts.rb

ActiveAdmin.register Part do
  reorderable # Necessary to support reordering in a subtable within Widget below
end

widgets.rb

ActiveAdmin.register Widget do
  config.sort_order = 'position_asc' # assuming Widget.insert_at modifies the `position` attribute
  config.paginate   = false

  reorderable

  actions :index, :show

  # Reorderable Index Table
  index as: :reorderable_table do
    column :id
    column :name
  end

  show do |widget|
    attributes_table do
      row :id
      row :name
    end

    # Reorderable Subtable
    # Note: you must include `reorderable` in the ActiveAdmin configuration for the resource
    # being sorted. See the `Part` example above this code block.
    reorderable_table_for widget.parts do
      column :name
      column :cost
    end
  end
end

Code At Viget

Visit code.viget.com to see more projects from Viget.

activeadmin_reorderable's People

Contributors

zporter avatar nhunzaker avatar ahmdrefat avatar yaychris avatar zharikovpro avatar

Watchers

Matt Belanger avatar Karim El-Husseiny avatar James Cloos avatar  avatar Deepak Ramachandran 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.