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 removing model from navigation without removing its routes #1417

Closed
robinboening opened this issue Sep 5, 2019 · 2 comments
Closed

Comments

@robinboening
Copy link

I have models like this: Order has many LineItem

It doesn't make much sense to look at a list of millions of line items. It makes sense to go through the order and check its list of line items there. I decided to remove line items it from the navigation but I still want line items to appear as a nested resource in Order#show.

The navigation simply renders all resources defined in the routes. So removing line_items from the routes will remove it from the navigation, but it will break the app when I open Order#show because it also uses the line items paths.

Right now there's no possibility to remove a resource from the navigation while keeping it as a nested resources. (Overriding _navigation partial and hardcode the entries is obviously not the right way)

While writing this issue I was playing around with an implementation to add configuration to Dashboards, like this:

# dashboards/line_item_dashboard.rb

class LineItemDashboard < Administrate::BaseDashboard

  configure do |config|
    config.navigation = false
  end

  ...
end

Then I introduced a Administrate::Navigation class collecting all resources configured to be displayed in the navigation. In the _navigation.html.erb partial I iterate through Navigation#resources

It works like a charm. Is it worth sending a PR?

@stratigos
Copy link

Thanks for working to improve administrate and how relational data is exposed and navigated through! 🙂

I had similar thoughts recently. Ill take a look at the PR I see linked, and see if I can contribute.

@nickcharlton
Copy link
Member

Closing this as we merged #1524 instead.

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

3 participants