holyketzer / activeadmin-async_panel

AJAX-powered async panels for ActiveAdmin
MIT License
29 stars 5 forks source link

activeadmin-async_panel silently fails without error #16

Open HashtagONUD opened 4 years ago

HashtagONUD commented 4 years ago

I'm running rails 6 and activeadmin (2.8.0) with activeadmin-async_panel (0.2.5). Trying to follow the installation instructions but having problems.

I didn't have an active_admin.js.coffee in my project, so I created one inside app/assets/javascripts alongside the active_admin.js file that was already there:

app/assets/javascripts/active_admin.js.coffee: #= require activeadmin-async_panel

app/assets/javascripts/active_admin.js has one line in it: //= require active_admin/base

app/assets/stylesheets/active_admin.scss is this:

// Sass variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;

// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";

// Overriding any non-variable Sass must be done after the fact.
// For example, to change the default status-tag color:
//
//   .status_tag { background: #6090DB; }
@import "activeadmin-async_panel";

In my AA page, I made a sample panel and member_action:

  member_action :timecall do # /admin/animals/1/timecall
    @count = Animal.count
    render layout: false, locals: { count: @count }
  end

  panel 'Async test', class: 'async-panel', 'data-url' => '/admin/animals/1/timecall', 'data-period' => 1.second

Finally, my template is at app/views/admin/animals/timecall.html.erb: embedded ruby file, animal name is <%= count %>

When I load the page, the panel appears, but the data-url is not accessed:

<div class="async-panel panel" data-url="/admin/animals/1/timecall" data-period="1">
                  <h3>Async test</h3>
                  <div class="panel_contents"></div>
</div>

Not sure what I'm doing wrong, as I followed the instructions in the README pretty closely.

holyketzer commented 4 years ago

Hm, I'm not sure how Rails handles two active_admin.js files inside assets folder. If you already have active_admin.js you can put this code inside it in a way (and please do not forget to remove active_admin.js.coffee):

//= require activeadmin-async_panel

Looks like I need to update readme due to CoffeeScript is pretty outdated now.

holyketzer commented 1 year ago

Try this version it works with Rails 7 https://rubygems.org/gems/activeadmin-async_panel/versions/0.3.0