Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enabled to actions to allow enabling/disabling links #1765

Closed
sepastian opened this issue Sep 26, 2013 · 6 comments
Closed

Add enabled to actions to allow enabling/disabling links #1765

sepastian opened this issue Sep 26, 2013 · 6 comments
Milestone

Comments

@sepastian
Copy link

Currently, the visible options allows controlling which (member) actions should be shown. When making a member action invisible, the positions of subsequent links to other member actions change. This is not good from a UI perspective, because a user might click the wrong button after it has moved away from where it normally would appear.

An image says more than 1000 words. So, I added a custom action publish!, which should be available for unpublished objects only. Currently, when hiding my action for already published objects, the buttons after publish! change position:

rails_admin_actions

What I am suggesting is a new option called enabled, which will always render an icon for an action. However, if enabled is false, the button would be rendered in gray and no link would be rendered. In config/initializers/rails_admin.rb, the enabled option would be set for individual members.

# config/initializers/rails_admin.rb
config.actions do
  publish do
    enabled do
      not bindings[:object].published?
    end
  end
end

And the final result would look like so:

rails_admin_actions_2

This way, all buttons will always stay at the same position.

This would require small changes in the RailsAdmin application_helper.rb, namely in menu_for. Links should only be rendered if the enabled option returns true for a member.

What do you think?

@sepastian
Copy link
Author

(And, yes, I would be willing to provide a pull request, if others think this is useful.)

@dalpo
Copy link
Contributor

dalpo commented Oct 5, 2013

👍

1 similar comment
@ideadapt
Copy link
Contributor

👍

@mshibuya
Copy link
Member

Already implemented by 10655cb, forcing visible true and switching enabled will do the job.

@mshibuya
Copy link
Member

I lied, not implemented yet 🙇

@mshibuya mshibuya reopened this Aug 26, 2015
@ideadapt
Copy link
Contributor

Hello!

New message, please read http://thomascart.com/girl.php?ooy

kunz@ideadapt.net

@mshibuya mshibuya added this to the 3.0.0 milestone Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants