Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added pjax? option to Actions::Base #1295

Merged
merged 1 commit into from

6 participants

@stympy

Some actions, like logging in as another user, should be rendered
in the app, not via pjax. This change allows an action to indicate
how it should be rendered.

@stympy stympy Added a configurable option for pjax
Some actions, like logging in as another user, should be rendered
in the app, not via pjax.  This change allows an action to indicate
how it should be rendered.
115f20c
@travisbot

This pull request passes (merged 115f20c into 3c83b27).

@mshibuya
Collaborator

This is cool, but we need tests for this before merging in.
Can you handle it?

@stympy

Well, if I could actually run the tests... :) After bundling and running rake, I get this error: git://github.com/meskyanichi/mongoid-paperclip.git (at develop) is not checked out. Please run bundle install

@mshibuya
Collaborator

You could try either:

$ bundle install
$ bundle exec rake

or

$ bundle install
$ bundle exec rspec
@mshibuya mshibuya was assigned
@axsuul

Hoping this gets merged in soon!

@bbenezech bbenezech merged commit ed8d18c into from
@coveralls

Coverage Status

Changes Unknown when pulling 115f20c on stympy:master into ** on sferik:master**.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 25, 2012
  1. @stympy

    Added a configurable option for pjax

    stympy authored
    Some actions, like logging in as another user, should be rendered
    in the app, not via pjax.  This change allows an action to indicate
    how it should be rendered.
This page is out of date. Refresh to see the latest.
View
2  app/helpers/rails_admin/application_helper.rb
@@ -114,7 +114,7 @@ def menu_for(parent, abstract_model = nil, object = nil, only_icon = false) # pe
wording = wording_for(:menu, action)
%{
<li title="#{wording if only_icon}" rel="#{'tooltip' if only_icon}" class="icon #{action.key}_#{parent}_link #{'active' if current_action?(action)}">
- <a class="#{action.key == :show_in_app ? '' : 'pjax'}" href="#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => (object.try(:persisted?) && object.try(:id) || nil) })}">
+ <a class="#{action.pjax? ? 'pjax' : ''}" href="#{url_for({ :action => action.action_name, :controller => 'rails_admin/main', :model_name => abstract_model.try(:to_param), :id => (object.try(:persisted?) && object.try(:id) || nil) })}">
<i class="#{action.link_icon}"></i>
<span#{only_icon ? " style='display:none'" : ""}>#{wording}</span>
</a>
View
5 lib/rails_admin/config/actions/base.rb
@@ -39,6 +39,11 @@ class Base
false
end
+ # Render via pjax?
+ register_instance_option :pjax? do
+ true
+ end
+
# This block is evaluated in the context of the controller when action is called
# You can access:
# - @objects if you're on a model scope
View
4 lib/rails_admin/config/actions/show_in_app.rb
@@ -21,6 +21,10 @@ class ShowInApp < RailsAdmin::Config::Actions::Base
register_instance_option :link_icon do
'icon-eye-open'
end
+
+ register_instance_option :pjax? do
+ false
+ end
end
end
end
Something went wrong with that request. Please try again.