incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [08/50] [abbrv] git commit: [#5599] ticket:296 drop-down for grouped menu items
Date Tue, 07 May 2013 22:30:50 GMT
[#5599] ticket:296 drop-down for grouped menu items


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a028f972
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a028f972
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a028f972

Branch: refs/heads/tv/3876
Commit: a028f972b9c73eef5cc73e7be2d199e1188aa0de
Parents: 4469a52
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Mon Apr 15 10:28:57 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed May 1 20:38:37 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py               |    8 +-
 Allura/allura/model/project.py                     |    9 ++
 Allura/allura/nf/allura/css/site_style.css         |   78 +++++++++++----
 Allura/allura/templates/award.html                 |    2 +-
 .../templates/jinja_master/neigh_top_nav.html      |   40 --------
 Allura/allura/templates/jinja_master/top_nav.html  |   20 ++--
 .../templates/neighborhood_admin_accolades.html    |    2 +-
 .../templates/neighborhood_admin_overview.html     |    2 +-
 Allura/allura/templates/neighborhood_help.html     |    2 +-
 Allura/allura/templates/neighborhood_moderate.html |    2 +-
 .../templates/neighborhood_project_list.html       |    2 +-
 Allura/allura/templates/neighborhood_stats.html    |    2 +-
 .../templates/neighborhood_stats_adminlist.html    |    2 +-
 Allura/allura/tests/functional/test_admin.py       |   17 ++--
 Allura/allura/tests/functional/test_home.py        |   30 ++++++
 .../allura/tests/functional/test_neighborhood.py   |   16 ++--
 16 files changed, 138 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index e60b494..f8789a3 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -309,9 +309,11 @@ class ProjectController(FeedController):
 
     @expose('json:')
     def _nav(self):
-        return dict(menu=[
-                dict(name=s.label, url=s.url, icon=s.ui_icon)
-                for s in c.project.grouped_navbar_entries()])
+        menu = []
+        for s in c.project.grouped_navbar_entries():
+            children = [dict(name=child.label, url=child.url, icon=child.ui_icon) for child
in s.children]
+            menu.append(dict(name=s.label, url=s.url, icon=s.ui_icon, children=children))
+        return dict(menu=menu)
 
     @expose()
     def _lookup(self, name, *remainder):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 350f353..73894e3 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -18,6 +18,7 @@
 import logging
 from collections import Counter, OrderedDict
 from datetime import datetime
+from copy import deepcopy
 
 from tg import config
 from pylons import tmpl_context as c, app_globals as g
@@ -493,6 +494,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             else:
                 # tool of a type we don't have in the navbar yet
                 if tool_name not in grouped_nav:
+                    child = deepcopy(e)
                     # change label to be the tool name (type)
                     e.label = tool_name.capitalize()
                     # add tool url to list of urls that will match this nav entry
@@ -500,10 +502,17 @@ class Project(MappedClass, ActivityNode, ActivityObject):
                     e.matching_urls.append(e.url)
                     # change url to point to tool list page
                     e.url = self.url() + '_list/' + tool_name
+                    e.children.append(child)
                     grouped_nav[tool_name] = e
                 else:
                     # add tool url to list of urls that will match this nav entry
                     grouped_nav[tool_name].matching_urls.append(e.url)
+                    if len(grouped_nav[tool_name].children) < 10:
+                        grouped_nav[tool_name].children.append(e)
+                    elif len(grouped_nav[tool_name].children) == 10:
+                        e.url = self.url() + '_list/' + tool_name
+                        e.label = '...more...'
+                        grouped_nav[tool_name].children.append(e)
         return grouped_nav.values()
 
     def parent_iter(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index df703d9..98938e8 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -370,25 +370,6 @@ td, td img {
   vertical-align: middle;
 }
 
-.diamond {
-  z-index: 1;
-  height: 20px;
-  width: 20px;
-  display: block;
-  position: absolute;
-  bottom: -20px;
-  left: 50%;
-  margin-left: -10px;
-  overflow: hidden;
-  background: #e5e5e5;
-  border-left: 1px solid #aaaaaa;
-  border-top: 1px solid #aaaaaa;
-  -moz-transform: rotate(45deg);
-  -webkit-transform: rotate(45deg);
-  -o-transform: rotate(45deg);
-  transform: rotate(45deg);
-}
-
 .tool-count {
   display: block;
   position: absolute;
@@ -1013,6 +994,7 @@ a.btn:active {
   text-align: center;
   position: relative;
   margin: 0 0 20px;
+  height: 50px;
 }
 .btn-bar.pop, .pop#top_nav {
   height: 150px;
@@ -2905,3 +2887,61 @@ table thead tr th.narrow, table tr td.narrow {
   bottom: -5px;
   left: 45%;
 }
+ul.dropdown,
+ul.dropdown li,
+ul.dropdown ul {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
+
+ul.dropdown {
+    position: relative;
+    z-index: 597;
+    float: left;
+}
+
+ul.dropdown li {
+    float: left;
+    vertical-align: middle;
+    zoom: 1;
+}
+
+ul.dropdown li.hover,
+ul.dropdown li:hover {
+    position: relative;
+    z-index: 599;
+    cursor: default;
+}
+
+ul.dropdown ul {
+    visibility: hidden;
+    position: absolute;
+    top:50px;
+    left: 0;
+    z-index: 598;
+    background-color: #ffffff;
+    -moz-border-radius: 5px;
+    -webkit-border-radius: 5px;
+    border-radius: 5px;
+    border-width: 1px;
+    border-style: solid;
+    border-color: #E6EFC2;
+}
+
+ul.dropdown ul li {
+    float: left;
+    margin: 5px;
+    min-width: 100px;
+}
+
+ul.dropdown li:hover > ul {
+    visibility: visible;
+}
+ul.dropdown ul li a {
+    height: 20px !important;
+    font-weight:normal;
+}
+li.selected {
+    font-weight:bold;
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/award.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/award.html b/Allura/allura/templates/award.html
index 3cb2b72..503714f 100644
--- a/Allura/allura/templates/award.html
+++ b/Allura/allura/templates/award.html
@@ -27,7 +27,7 @@
 {% endblock %}
 
 {% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+{% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block content %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/jinja_master/neigh_top_nav.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/neigh_top_nav.html b/Allura/allura/templates/jinja_master/neigh_top_nav.html
deleted file mode 100644
index 39b37b9..0000000
--- a/Allura/allura/templates/jinja_master/neigh_top_nav.html
+++ /dev/null
@@ -1,40 +0,0 @@
-{#-
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
--#}
-{% if neighborhood and neighborhood.neighborhood_project %}
-  {% for s in neighborhood.neighborhood_project.sitemap() %}
-    <a href="{{s.url}}" class="ui-icon-{{s.ui_icon or 'admin'}}">
-      {{s.label}}
-      {% if s.label == 'Home' %}
-        {% set url_length = s.url|length %}
-        {% if request.url.rfind(s.url, -url_length) != -1 %}
-          <span class="diamond"></span>
-        {% endif %}
-      {% elif s.label == 'Admin' %}
-        {% if s.url in request.url or c.project.neighborhood.url()+'_admin' in request.url
%}
-          <span class="diamond"></span>
-        {% endif %}
-      {% else %}
-        {% if s.url in request.url %}
-          <span class="diamond"></span>
-        {% endif %}
-      {% endif %}
-    </a>
-        {% endfor %}
-        <div style="clear:both"></div>
-{% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/jinja_master/top_nav.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/top_nav.html b/Allura/allura/templates/jinja_master/top_nav.html
index 1b17d11..aeec126 100644
--- a/Allura/allura/templates/jinja_master/top_nav.html
+++ b/Allura/allura/templates/jinja_master/top_nav.html
@@ -17,7 +17,7 @@
        under the License.
 -#}
 {% if c.project %}
-  <div><ul>
+<ul class="dropdown">
   {% for s in c.project.grouped_navbar_entries() %}
     {% set selected = False %}
     {% if s.label == 'Home' %}
@@ -30,17 +30,19 @@
         {% set selected = True %}
       {% endif %}
     {% endif %}
-    <li class="ui-icon-{{s.ui_icon or 'admin'}}{% if selected %} selected{% endif %}">
-      <a href="{{s.url}}">
-        <span>
-        {{s.label}}
+    <li class="{% if selected %}selected{% endif %}">
+        <a href="{{s.url}}" class="ui-icon-{{s.ui_icon or 'admin'}}">
+            {{s.label}}
+        </a>
         {% set grouped_tool_count = s.matching_urls|length %}
         {% if grouped_tool_count %}
-          <span class="tool-count">{{grouped_tool_count}}</span>
+          <ul>
+              {%for tool in s.children%}
+                <li><span><a href="{{tool.url}}">{{tool.label}}</a></span></li>
+              {%endfor%}
+          </ul>
         {% endif %}
-        </span>
-      </a>
     </li>
 	{% endfor %}
-	</div></ul>
+</ul>
 {% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_admin_accolades.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_admin_accolades.html b/Allura/allura/templates/neighborhood_admin_accolades.html
index 63264bc..2f6d82f 100644
--- a/Allura/allura/templates/neighborhood_admin_accolades.html
+++ b/Allura/allura/templates/neighborhood_admin_accolades.html
@@ -27,7 +27,7 @@
 {% endblock %}
 
 {% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+{% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block content %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_admin_overview.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_admin_overview.html b/Allura/allura/templates/neighborhood_admin_overview.html
index 07489e9..8944b22 100644
--- a/Allura/allura/templates/neighborhood_admin_overview.html
+++ b/Allura/allura/templates/neighborhood_admin_overview.html
@@ -27,7 +27,7 @@
 {% endblock %}
 
 {% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+{% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block content %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_help.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_help.html b/Allura/allura/templates/neighborhood_help.html
index 6ad8163..ed57b53 100644
--- a/Allura/allura/templates/neighborhood_help.html
+++ b/Allura/allura/templates/neighborhood_help.html
@@ -27,7 +27,7 @@
 {% endblock %}
 
 {% block top_nav %}
-    {% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+    {% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block content %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_moderate.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_moderate.html b/Allura/allura/templates/neighborhood_moderate.html
index 7beea44..5fe5c3f 100644
--- a/Allura/allura/templates/neighborhood_moderate.html
+++ b/Allura/allura/templates/neighborhood_moderate.html
@@ -28,7 +28,7 @@
 {% endblock %}
 
 {% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+{% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block content %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_project_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_project_list.html b/Allura/allura/templates/neighborhood_project_list.html
index 1f2939e..b747af0 100644
--- a/Allura/allura/templates/neighborhood_project_list.html
+++ b/Allura/allura/templates/neighborhood_project_list.html
@@ -42,7 +42,7 @@
 {% endblock %}
 
 {% block top_nav %}
-{% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+{% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block inner_grid %}{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_stats.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_stats.html b/Allura/allura/templates/neighborhood_stats.html
index fa0e68f..3b0b0ee 100644
--- a/Allura/allura/templates/neighborhood_stats.html
+++ b/Allura/allura/templates/neighborhood_stats.html
@@ -19,7 +19,7 @@
 {% extends g.theme.master %}
 
 {% block top_nav %}
-    {% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+    {% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block title %}Neighborhood Statistics{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/templates/neighborhood_stats_adminlist.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_stats_adminlist.html b/Allura/allura/templates/neighborhood_stats_adminlist.html
index 4e3afe0..4deafe1 100644
--- a/Allura/allura/templates/neighborhood_stats_adminlist.html
+++ b/Allura/allura/templates/neighborhood_stats_adminlist.html
@@ -23,7 +23,7 @@
 {% block header %}Admins list{% endblock %}
 
 {% block top_nav %}
-    {% include 'allura:templates/jinja_master/neigh_top_nav.html' %}
+    {% include 'allura:templates/jinja_master/top_nav.html' %}
 {% endblock %}
 
 {% block content %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index ac63ffe..1752707 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -105,9 +105,9 @@ class TestProjectAdmin(TestController):
         assert 'error' not in self.webflash(r)
         # check tool in the nav
         r = self.app.get('/p/test/test-tool/').follow()
-        active_link = r.html.findAll('span',{'class':'diamond'})
-        assert len(active_link) == 1
-        assert active_link[0].parent['href'] == '/p/test/test-tool/'
+        active_link = r.html.findAll('li',{'class':'selected'})
+        assert_equals(len(active_link), 1)
+        assert active_link[0].contents[1]['href'] == '/p/test/test-tool/'
         with audits('install tool test-tool2'):
             r = self.app.post('/admin/update_mounts', params={
                     'new.install':'install',
@@ -118,13 +118,12 @@ class TestProjectAdmin(TestController):
         assert 'error' not in self.webflash(r)
         # check the nav - tools of same type are grouped
         r = self.app.get('/p/test/test-tool/Home/')
-        active_link = r.html.findAll('span', {'class':'diamond'})
+        active_link = r.html.findAll('li',{'class':'selected'})
         assert len(active_link) == 1
-        assert active_link[0].parent['href'] == '/p/test/_list/wiki'
-        # check tool-count of grouped tools
-        tool_count = active_link[0].findNextSibling('span')
-        assert tool_count['class'] == u'tool-count', tool_count['class']
-        assert tool_count.text == u'2', tool_count.text
+        assert active_link[0].contents[1]['href'] == '/p/test/_list/wiki'
+        assert r.html.findAll('a', {'href':'/p/test/test-tool2/'})
+        assert r.html.findAll('a', {'href':'/p/test/test-tool/'})
+
         # check can't create dup tool
         r = self.app.post('/admin/update_mounts', params={
                 'new.install':'install',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/tests/functional/test_home.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py
index 88b2c0d..4904394 100644
--- a/Allura/allura/tests/functional/test_home.py
+++ b/Allura/allura/tests/functional/test_home.py
@@ -18,6 +18,8 @@
 import json
 import re
 
+from pylons import tmpl_context as c
+
 from allura.tests import TestController
 from allura.tests import decorators as td
 from allura import model as M
@@ -38,6 +40,34 @@ class TestProjectHome(TestController):
             assert nl['href'] == entry['url']
 
     @td.with_wiki
+    def test_project_group_nav(self):
+        c.user = M.User.by_username('test-admin')
+        p = M.Project.query.get(shortname='test')
+        c.project = p
+        if 'wiki2' and not p.app_instance('wiki2'):
+            c.app = p.install_app('wiki', 'wiki2', 'wiki2', 9)
+
+        response = self.app.get('/p/test/_nav.json')
+        menu = response.json['menu']
+        assert_equal(len(menu[1]['children']), 2)
+        assert {u'url': u'/p/test/wiki/', u'name': u'Wiki', u'icon': u'tool-wiki'} in menu[1]['children'],
menu[1]['children']
+        assert {u'url': u'/p/test/wiki2/', u'name': u'wiki2', u'icon': u'tool-wiki'} in menu[1]['children'],
menu[1]['children']
+
+    @td.with_wiki
+    def test_project_group_nav_more_than_ten(self):
+        for i in range(1,15):
+            tool_name = "wiki%s" % str(i)
+            c.user = M.User.by_username('test-admin')
+            p = M.Project.query.get(shortname='test')
+            c.project = p
+            if tool_name and not p.app_instance(tool_name):
+                c.app = p.install_app('wiki', tool_name, tool_name, i)
+        response = self.app.get('/p/test/_nav.json')
+        menu = response.json['menu']
+        assert_equal(len(menu[1]['children']), 11)
+        assert {u'url': u'/p/test/_list/wiki', u'name': u'...more...', u'icon': u'tool-wiki'}
in menu[1]['children']
+
+    @td.with_wiki
     def test_neighborhood_home(self):
         self.app.get('/p/test/wiki/', status=302)
         self.app.get('/adobe/test/wiki/', status=404)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a028f972/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index f91b5cb..a641f74 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -638,14 +638,14 @@ class TestNeighborhood(TestController):
         p = M.Project.query.get(shortname='testtemp')
         # make sure the correct tools got installed in the right order
         top_nav = r.html.find('div', {'id':'top_nav'})
-        assert top_nav.contents[1]['href'] == '/adobe/testtemp/wiki/'
-        assert 'Wiki' in top_nav.contents[1].contents[0]
-        assert top_nav.contents[3]['href'] == '/adobe/testtemp/discussion/'
-        assert 'Discussion' in top_nav.contents[3].contents[0]
-        assert top_nav.contents[5]['href'] == '/adobe/testtemp/news/'
-        assert 'News' in top_nav.contents[5].contents[0]
-        assert top_nav.contents[7]['href'] == '/adobe/testtemp/admin/'
-        assert 'Admin' in top_nav.contents[7].contents[0]
+        assert top_nav.contents[1].contents[1].contents[1]['href'] == '/adobe/testtemp/wiki/'
+        assert 'Wiki' in top_nav.contents[1].contents[1].contents[1].contents[0]
+        assert top_nav.contents[1].contents[3].contents[1]['href'] == '/adobe/testtemp/discussion/'
+        assert 'Discussion' in top_nav.contents[1].contents[3].contents[1].contents[0]
+        assert top_nav.contents[1].contents[5].contents[1]['href'] == '/adobe/testtemp/news/'
+        assert 'News' in top_nav.contents[1].contents[5].contents[1].contents[0]
+        assert top_nav.contents[1].contents[7].contents[1]['href'] == '/adobe/testtemp/admin/'
+        assert 'Admin' in top_nav.contents[1].contents[7].contents[1].contents[0]
         # make sure project is private
         r = self.app.get(
             '/adobe/testtemp/wiki/',


Mime
View raw message