Patch #4250
closedTree based menus
100%
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
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
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
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
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!!
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.
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?
- Bundle the gem with Redmine in vendor?
- Extract only the classes we use and bundle them with Redmine in vendor?
- Patch the gem and require a custom patched version? (I could host the gem on my Rubyforge/gemcutter account)
Updated by Eric Davis over 14 years ago
- File 0003-Updated-menus-from-JPL-s-feedback.patch 0003-Updated-menus-from-JPL-s-feedback.patch added
- Status changed from New to 7
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).
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.
Updated by Ted Lilley over 14 years ago
Since this is in support of the SP theme, it has my vote.
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
Updated by Mischa The Evil about 11 years ago
- Related to Patch #6427: Create CSS to support child and nested menus added