Active Admin not following :priority #1283

Closed
cgunnels opened this Issue Apr 26, 2012 · 10 comments

Projects

None yet

5 participants

@cgunnels

I am setting the menu :priority => 1 and the next tab I am setting to 2 and active admin is displaying the second tab first. How do I fix this, what am I doing wrong? The first tab has a sub tab.

First tab

ActiveAdmin.register Article do
  menu :priority => 1

Sub tab

ActiveAdmin.register Article, :as => 'ArticleReview' do
  menu :priority => 1, :parent => "Articles", :label => "Review Articles"

Second tab

ActiveAdmin.register Grids do
  menu :priority => 2
@seanlinsley
Active Admin member

First of all, I don't know why you'd ever want to register Article twice under two separate names...

I don't recall the reason currently, but in my app I have all of the "parent" links (Articles and Grids in your case) ordered from 10 onwards. So going left to right, they have priorities of 10, 11, 12, etc. In this configuration it works fine for me.

@cgunnels

Im actually registering the ArticleReview model which inherits from Article but has a default scope.

@keysen

I've encountered this problem when I've 2 parents, I can't set my parents element in the order that I want. I can only do this by setting numbers in the name of my parents because I've discovered that parent not used the priority when it's greater than one but they use the alphabetical order, but I've find my trick very ugly.

Have a look on my screen :

@seanlinsley
Active Admin member

Here's an explanation from this file:

# @option options [Integer] :priority
    # MenuItems are sorted by priority then by label. The lower the priority, the
    # earlier in the menu the item will be displayed.
    # Default: 10

Hence why my previously mentioned solution worked. @keysen, can you try and see if it works for you? That is, specifically use a priority greater than 10 for every top-level menu item.

@dyohi

I am also having an issue with :priority. It appears that menus with children are displayed first despite the priority setting. Is this because the :priority is for ordering submenu items only?

@seanlinsley
Active Admin member

@dyohi read my above post. The only case that doesn't handle is when you have a parent menu that itself doesn't belong to a model, because there's no way to currently set priority for such an entity. Thus, it defaults to a priority of 10.

@keysen

@Daxter thanks for the advise, Indeed I tried to play with priority, but nothing change.

@seanlinsley
Active Admin member

@keysen, I'm guessing here (since I don't speak French), but it appears you're using top-level menus that aren't associated with an AA page/model. It's that situation that doesn't work, because there's no way currently to set a priority for such a menu item.

@keysen

@daxter You're right they aren't associated :). Finally it's a bug, because the user can't use these submenu and the navbar is limited in space.

The trick's in doing a seperated resource which are only a container of submenu with 2 params like name, position

I'm not enough habituated with rails to do this, I'm in phase of learning, so, I wait someone implement this :s.

@jpmckinney

Moved to #1488.

@jpmckinney jpmckinney closed this Aug 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment