-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adding actions to dashboard #222
Comments
@gjackson12 this has been on my wishlist for a long time now. 😄 At the moment, you need to do it all from scratch - run I have a few ideas in mind for how we could improve this process, but I'd love to hear your thoughts - what API would you want for this? |
One other question. Let's say I added an action called "send_notification" to the Users resource. Do I need to create that route manually? (thinking of some suggestions for the API) |
@gjackson12 yep - you'd need to create the route yourself to match your controller action. |
(that's how it works at the moment) |
So I added the following route:
I also put the following in my controller:
Finally, I have the following in the view:
I keep getting the following error:
Any help would be appreciated. |
hm... I think you might need to include a |
@gjackson12 are you defining that in the |
@gjackson12 ping. Any updates here? |
Just change the order of the link_to attributes to <td><%= link_to(
t("administrate.actions.send_notification"),
[Administrate::NAMESPACE, : send_notification, resource],
method: :post
) %></td> This will generate your link route correctly. In my routes.rb I added a 'clone' action by adding namespace :admin do
DashboardManifest::DASHBOARDS.each do |dashboard_resource|
resources dashboard_resource
end
post 'palladio_styles/:id/clone', to: "palladio_styles#clone", as: 'clone_palladio_style'
root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
end This gives me the additional route I need: |
@gjackson12, this is my slightly different approach: namespace :admin do
DashboardManifest::DASHBOARDS.each do |dashboard_resource|
resources dashboard_resource do
if dashboard_resource == :palladio_styles
member do
post :clone
end
end
end
end
root controller: DashboardManifest::ROOT_DASHBOARD, action: :index
end And the link follows the save convention as CRUD ones:
Not perfect, but still, cleaner than having to write all the stuff by hand Rails' already generating for you. |
@gjackson12 Were you able to get your custom action and link working? There are a couple of good approaches outlined above. I'm going to close up this ticket for now. |
Is there still any roadmap for Administrate? An easier API to add custom actions would be highly appreciated. I think generating the views for each model with custom actions, created unnecessary amounts of boilerplate. Would be great if there was a way to define the actions in the Dashboard or Controller class. |
Hi, why is this closed? Is not a fair feature request to have in the issue tracker? If is open someone with a bit of background may jump and do it. |
In my case, I wanted to update a record's field value with a single click. I only needed to customize my model's In this example, my model is
I hope this helps others! |
@jesseduffield, could you open a new issue, and reference this one? I think we should revisit this, as it has significant merit, but this particular issue has a lot of solutions which are likely not relevant any more and folks who are no longer so closely involved with Administrate. |
Sure thing, see #2743 |
Is there a way to add custom actions to the dashboard view? Right now I just see edit, and destroy. Along those actions I would like to list a few other custom actions if possible.
The text was updated successfully, but these errors were encountered: