Project

General

Profile

Actions

Patch #4250

closed

Tree based menus

Added by Eric Davis over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
UI
Target version:
Start date:
2009-11-19
Due date:
% Done:

100%

Estimated time:

Description

Currently Redmine's menus are only liner: Overview, Activity...

These patches convert the menus into a tree structure. The first patch will let menus be grouped and organized like so:

  • Overview
  • Issues
    • New Issue
  • Activity
  • Settings

Which renders to html as:

<div id="main-menu">
  <ul>
    ... other menu items here ...
    <li>
      <a class="issues" href="/projects/abc/issues">Issues</a>
      <ul class="menu-children">
        <li>
          <a class="new-issue" accesskey="7" href="/projects/abc/issues/new">New issue</a>
        </li>
      </ul>
    </li>
    ... other items ...
  </ul>
</div>

The second patch will allow a menu to define an "unattached" menu. This type of menu is a chunk of code that will create a menu on the fly, based on the current page's data (e.g. current project). I've used this to add a menu that lists all of the Custom Queries on a project:

<div id="main-menu">
  <ul>
    ... other menu items here ...
    <li>
      <a class="issues" href="/projects/abc/issues">Issues</a>
      <ul class="menu-children">
        <li>
          <a class="new-issue" accesskey="7" href="/projects/abc/issues/new">New issue</a>
        </li>
      </ul>
      <ul class="menu-children unattached">
        <li>
          <a class="query-2" href="/projects/cremin4/issues?query_id=2">Late</a>
          <a class="query-3" href="/projects/cremin4/issues?query_id=3">Needs an estimate</a>
      </li>
      </ul>

    </li>
    ... other items ...
  </ul>
</div>

These two patches (plus some javascript and custom css) are what makes the Shane and Peter theme work. You can see how the theme is building the menus in it's init.rb

Both of these patches are backwards compatible. They only change how menus are stored internally and provide a some new methods for core/plugin menus. I've also included a bunch of tests for the MenuManager (which was untested). Once I get a code review or two, I can commit these. If anyone has any questions, feel free to ask.


Files


Related issues

Related to Redmine - Patch #6427: Create CSS to support child and nested menusClosed2010-09-17

Actions
Actions #1

Updated by Mischa The Evil over 14 years ago

Not a real code review but looking at the patches this seems to be a huge improvement over the current implementation of the menus in Redmine.

+1

Actions #2

Updated by Shane Pearlman over 14 years ago

This goes a long way too in the ability to support plugins so that they may configure and add custom menu items. for example,

  • listing watched wiki pages in a drop down under wiki
  • showing all settings in the drop menu to avoid having to click 2x just to get to members
  • create a reports tab that includes both default reporting items and new custom reports

etc...

+1

Actions #3

Updated by Henrik Ammer over 14 years ago

+1

Actions #4

Updated by Jean-Philippe Lang over 14 years ago

Nice improvement for plugins indeed.

Small details:
  • the existing doc should be updated (eg. new option :parent_menu in Mapper#push is absent)
  • we have :before, :after, :last options (and not :before_menu, ...) so I expect a :parent option instead of :parent_menu
  • same thing for MenuItem#new, :parent_menu and :child_menus should be renamed to :parent and :children
  • it uses few methods of the (unpatched) rubytree lib, thus I'm not sure if it's worth the gem requirement
Actions #5

Updated by Jean-Philippe Lang over 14 years ago

  • Category set to UI
Actions #6

Updated by Dan Cameron over 14 years ago

Can't wait.

Actions #7

Updated by claire s over 14 years ago

I've been trying this patch on my system for several weeks now and it's been really great. No problems and our team is working more efficiently. Thanks Eric!!

Actions #8

Updated by Peter Chester over 14 years ago

Our whole team loves the new menus. I can't wait to see this implemented so that the community can start coding to it.

Actions #9

Updated by Eric Davis over 14 years ago

Jean-Philippe Lang wrote:

Small details:
  • the existing doc should be updated (eg. new option :parent_menu in Mapper#push is absent)

Agreed.

  • we have :before, :after, :last options (and not :before_menu, ...) so I expect a :parent option instead of :parent_menu
  • same thing for MenuItem#new, :parent_menu and :child_menus should be renamed to :parent and :children

I agree but I think there was a reason I didn't use :parent. I think the node class defined and used parent for something else. I'll look into it and see.

  • it uses few methods of the (unpatched) rubytree lib, thus I'm not sure if it's worth the gem requirement

What do you propose?

  1. Bundle the gem with Redmine in vendor?
  2. Extract only the classes we use and bundle them with Redmine in vendor?
  3. Patch the gem and require a custom patched version? (I could host the gem on my Rubyforge/gemcutter account)
Actions #10

Updated by Eric Davis over 14 years ago

Here's a new patch (3 in the series) with a few updates:

  • Updated Mapper#push documentation
  • Renamed :parent_menu to :parent
  • Renamed the external API for :child_menus to :children. Internally it needs to stay :child_menus because Tree::TreeNode already defines a children method for another purpose

The only other thing remaining is to decide on the rubytree gem dependency. I think it would be ok to include it into vendor, it's only 2,058 lines of code (1242 in setup.rb, 554 in tests, 262 in lib).

Actions #11

Updated by Jean-Philippe Lang over 14 years ago

Eric Davis wrote:

Here's a new patch (3 in the series) with a few updates:

  • Updated Mapper#push documentation
  • Renamed :parent_menu to :parent
  • Renamed the external API for :child_menus to :children. Internally it needs to stay :child_menus because Tree::TreeNode already defines a children method for another purpose

Thanks.

The only other thing remaining is to decide on the rubytree gem dependency. I think it would be ok to include it into vendor, it's only 2,058 lines of code (1242 in setup.rb, 554 in tests, 262 in lib).

Agreed.

Actions #12

Updated by Ted Lilley over 14 years ago

Since this is in support of the SP theme, it has my vote.

Actions #13

Updated by Eric Davis over 14 years ago

  • Status changed from 7 to Closed
  • Target version set to 0.9.0
  • % Done changed from 0 to 100

Added to trunk in r3090, r3091, and r3092. Thanks for the feedback and reviews everyone.

Actions #14

Updated by Mischa The Evil over 10 years ago

  • Related to Patch #6427: Create CSS to support child and nested menus added
Actions

Also available in: Atom PDF