Low commit activity in last 3 years
A long-lived project that still receives updates
Allows to define special attributes for ActiveAdmin panel to make it AJAX loadable and auto-updatable
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.4.3
~> 2.1.1
~> 2.1
~> 3.39
~> 12.3
~> 3.9, >= 3.3.0
~> 1.4
~> 3.3, >= 3.3.0

Runtime

 Project Readme

Gem Version Build Status Code Climate

ActiveAdmin::AsyncPanel

ActiveAdmin Async Panel control

This gem allows you to create ActiveAdmin panels with content loaded dynamically via AJAX requests.

Prerequisites

Minimum Ruby version 2.7 Rails 7

This extension assumes that you're using Active Admin

Installation

Add this line to your application's Gemfile:

gem 'activeadmin-async_panel'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activeadmin-async_panel

Usage

Include this line in your JavaScript code (active_admin.js)

//= require activeadmin-async_panel

Include this line in your CSS code (active_admin.scss)

@import "activeadmin-async_panel";

To use this stuff do next steps:

Step 1. Define async panel

panel 'Name', class: 'async-panel', 'data-url' => some_action_admin_resources_path, 'data-period' => 1.minute

If you setup data-period, panel will be periodically updated. If not, it will be loaded once right after page load

If you set data-clickable to a truthy value, the panel will not be loaded upon initial page load. Instead, the panel will load upon clicking the panel header. Upon page load, the panel header will have a label of 'Click to Load'. Example:

panel 'Name', class: 'async-panel', 'data-url' => some_action_admin_resources_path, 'data-clickable' => 1

Step 2. Define action

Define member_action or collection_action to handle request specified by path helper

collection_action :some_action do
  @resources = Resource.some_scope
  render layout: false # mandatory line, layout should be disaled to render template only
end

Step 3. Define view

Define you view template to render action above in file views/admin/resources/some_action.html.arbcan also be (slim, erb), for e.g. arb template:

table_for resources do
  column :value1
  column :value2
end

Note that in step 2 you can pass template variables with @, but inside arb template you should use them without @, and inside erb, slim with.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/holyketzer/activeadmin-async_panel. This project is intended to be a safe, welcoming space for collaboration.

License

The gem is available as open source under the terms of the MIT License.