Radhika
Radhika

Reputation: 2561

Active Admin filters and scopes

In my Active Admin code, I have the following:

scope :all
  scope :in_progress
  scope :completed, default: true
  scope :processed

  filter :order_number, label: "by order number", collection: Order.all.map(&:order_number)
  filter :order_date, label: "orders placed between", collection: Order.all.map(&:order_date)

Filters display results under individual tabs. So now when the user filters results I want to see all the results under all the tabs(i.e the user is redirected to the 'all' scope tab). I am unable to find a way to achieve this. Thanks in advance :)

Upvotes: 3

Views: 2795

Answers (2)

Sampat Badhe
Sampat Badhe

Reputation: 9075

you can make use of the Hidden Field of Active Admin Filter.

you can implement in js like this :- (I've written this code in coffeescript)

  $('.index.admin_orders.active_admin .filter_form').submit ->
    scope = $(@).find('#hidden_active_admin_scope').value
    if(scope)
      $(@).find('#hidden_active_admin_scope').value = 'all'
    else
      $(@).find('div.buttons').append('<input id="hidden_active_admin_scope" name="scope" type="hidden" value="all">')

Upvotes: 1

Peter Bratton
Peter Bratton

Reputation: 6408

ActiveAdmin doesn't support removing filtering options from scopes. You could always convert those scopes into a filter (e.g. order_status), that may get you where you want to be.

Upvotes: 1

Related Questions