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

Allow Custom Action custom_key in I18N #3155

Open
locopati opened this issue Jun 14, 2019 · 0 comments
Open

Allow Custom Action custom_key in I18N #3155

locopati opened this issue Jun 14, 2019 · 0 comments

Comments

@locopati
Copy link

It's possible to give a custom action a parameter.

It's possible to have multiple version of the same custom action by overriding custom_key.

However, I don't see a way for the I18N label from rails_admin.en.yml to indicate which version of the same custom action is being used based on the parameter or the custom key.

Is there another way to accomplish the same idea?

Otherwise, you end up with multiple versions of the same action but they cannot be distinguished by hover text or in the bulk actions list.

For example

in rails_admin.rb

config.actions do
   update_status do
      new_status :good
    end
    update_status do
      new_status :bad
    end
    update_status do
      new_status :ugly
    end
end

in update_status_action.rb

  # store a parameter for the action
  register_instance_option :new_status do
      nil
  end

  # lets me have multiple versions of the same action based on parameter
  register_instance_option :custom_key do
      new_status
  end

  # i can even change the icon based on the parameter
  register_instance_option :link_icon do
      case new_status
          when :good
            "icon-thumbs-up"
          when :bad
            "icon-thumbs-down"
          when :ugly
            "icon-eye-open"
       end
  end

in rails_admin.en.yml

# i want to include the custom_key in these strings 
# so that each instance of the action has a different 
# hover label and bulk update label
update_status:
        menu: "Update status"
        bulk_link: "Update selected %{model_label_plural}"
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

1 participant