Show More
@@ -31,7 +31,8 b' from rhodecode.translation import _' | |||||
31 |
|
31 | |||
32 | log = logging.getLogger(__name__) |
|
32 | log = logging.getLogger(__name__) | |
33 |
|
33 | |||
34 |
NavListEntry = collections.namedtuple( |
|
34 | NavListEntry = collections.namedtuple( | |
|
35 | 'NavListEntry', ['key', 'name', 'url', 'active_list']) | |||
35 |
|
36 | |||
36 |
|
37 | |||
37 | class NavEntry(object): |
|
38 | class NavEntry(object): | |
@@ -41,14 +42,14 b' class NavEntry(object):' | |||||
41 | :param key: Unique identifier used to store reference in an OrderedDict. |
|
42 | :param key: Unique identifier used to store reference in an OrderedDict. | |
42 | :param name: Display name, usually a translation string. |
|
43 | :param name: Display name, usually a translation string. | |
43 | :param view_name: Name of the view, used generate the URL. |
|
44 | :param view_name: Name of the view, used generate the URL. | |
44 | :param pyramid: Indicator to use pyramid for URL generation. This should |
|
45 | :param active_list: list of urls that we select active for this element | |
45 | be removed as soon as we are fully migrated to pyramid. |
|
|||
46 | """ |
|
46 | """ | |
47 |
|
47 | |||
48 | def __init__(self, key, name, view_name): |
|
48 | def __init__(self, key, name, view_name, active_list=None): | |
49 | self.key = key |
|
49 | self.key = key | |
50 | self.name = name |
|
50 | self.name = name | |
51 | self.view_name = view_name |
|
51 | self.view_name = view_name | |
|
52 | self._active_list = active_list or [] | |||
52 |
|
53 | |||
53 | def generate_url(self, request): |
|
54 | def generate_url(self, request): | |
54 | return request.route_path(self.view_name) |
|
55 | return request.route_path(self.view_name) | |
@@ -56,6 +57,13 b' class NavEntry(object):' | |||||
56 | def get_localized_name(self, request): |
|
57 | def get_localized_name(self, request): | |
57 | return request.translate(self.name) |
|
58 | return request.translate(self.name) | |
58 |
|
59 | |||
|
60 | @property | |||
|
61 | def active_list(self): | |||
|
62 | active_list = [self.key] | |||
|
63 | if self._active_list: | |||
|
64 | active_list = self._active_list | |||
|
65 | return active_list | |||
|
66 | ||||
59 |
|
67 | |||
60 | @implementer(IAdminNavigationRegistry) |
|
68 | @implementer(IAdminNavigationRegistry) | |
61 | class NavigationRegistry(object): |
|
69 | class NavigationRegistry(object): | |
@@ -106,7 +114,7 b' class NavigationRegistry(object):' | |||||
106 |
|
114 | |||
107 | def get_navlist(self, request): |
|
115 | def get_navlist(self, request): | |
108 | navlist = [NavListEntry(i.key, i.get_localized_name(request), |
|
116 | navlist = [NavListEntry(i.key, i.get_localized_name(request), | |
109 | i.generate_url(request)) |
|
117 | i.generate_url(request), i.active_list) | |
110 | for i in self._registered_entries.values()] |
|
118 | for i in self._registered_entries.values()] | |
111 | return navlist |
|
119 | return navlist | |
112 |
|
120 |
@@ -20,7 +20,7 b'' | |||||
20 |
|
20 | |||
21 | <%def name="side_bar_nav()"> |
|
21 | <%def name="side_bar_nav()"> | |
22 | % for navitem in c.navlist: |
|
22 | % for navitem in c.navlist: | |
23 |
<li class="${'active' if c.active |
|
23 | <li class="${'active' if c.active in navitem.active_list else ''}"> | |
24 | <a href="${navitem.url}">${navitem.name}</a> |
|
24 | <a href="${navitem.url}">${navitem.name}</a> | |
25 | </li> |
|
25 | </li> | |
26 | % endfor |
|
26 | % endfor |
General Comments 0
You need to be logged in to leave comments.
Login now