codeplant/simple-navigation

Navigation (index) not showing for member actions - EDIT: for namespaced controllers

mjrk opened this issue · 3 comments

mjrk commented

Not sure if this feature exists already, if it's a feature or bug.

My main navigation kind of depends on my first level (user context). In other words my main navigation is level 2. Now, if I'm on a member action of, let's say, edit on my users controller, the level 2 disappears completely - because I didn't add the "edit" action as a child of user#index.

I can fix this by adding all member actions. But ... with a growing application it really becomes a big overhead and I just want my navigation index item to highlight on member actions. I guess this is possible but I could not find it in the docs. Help appreciated.

mjrk commented

I noticed, that the problem only occurs in my namespaced controllers. In my non namespaced controller, the navigation level: 2 is not empty (, although the index is not highlighted, easy to fix with highlights_on).

andi commented

Not sure if I understand the problem correctly. So can you work around the issue with highlights_on regexp? That's basically what it was made for, to "catch" those circumstances where the standard behaviour is not feasible.

mjrk commented

Well, in cases without further nesting (but admin) I only needed to add the highlights_on. However, with further nesting I need to catch

if @model_instance 
  ...

because member actions will fail without. At the end, the navigation.rb became pretty bloated.

The general setup will make member actions highlight the index as expected. But with namespaced controllers

primary.item :admin, "Admin view", admin_path do |admin_nav|
  admin_nav.item :customers, "Customers", admin_customers_path
  ...

I have to add hightlights_on and with some nesting even more logic (i.e. adding every member action or adding regexes for hightlights_on based on params[:controller] =~ etc.). I just wondered if member_actions shouldn't just hightlight the index-item out of the box, even on namespaced controllers. Especially confusing was, that the navigation level 2 disappeared completely when not working arround the problem.