Update menu resolution to return a list of lists of resolved objects. Allows segmented 'Action' dropdown on multi objects action menu.
This commit is contained in:
@@ -101,18 +101,20 @@
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{% get_menu_links 'main menu' as menu_links %}
|
||||
{% for link in menu_links %}
|
||||
{% with 'true' as as_li %}
|
||||
{% with 'true' as hide_active_anchor %}
|
||||
{% with 'active' as li_class_active %}
|
||||
{% with 'first' as li_class_first %}
|
||||
{% with ' ' as link_classes %}
|
||||
{% include 'navigation/generic_subnavigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% for link_set in menu_links %}
|
||||
{% for link in link_set %}
|
||||
{% with 'true' as as_li %}
|
||||
{% with 'true' as hide_active_anchor %}
|
||||
{% with 'active' as li_class_active %}
|
||||
{% with 'first' as li_class_first %}
|
||||
{% with ' ' as link_classes %}
|
||||
{% include 'navigation/generic_subnavigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
@@ -170,9 +172,9 @@
|
||||
<li><a class="btn-sm" href="{{ entry.url }}">{{ entry.text }}</a></li>
|
||||
{% endfor %}
|
||||
|
||||
{% if not forloop.last and links_set %}
|
||||
<li class="divider"></li>
|
||||
{% endif %}
|
||||
{% if not forloop.last and links_set %}
|
||||
<li class="divider"></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -182,15 +184,15 @@
|
||||
{% if form_navigation_links %}
|
||||
<div class="pull-right list-group">
|
||||
{% if form_navigation_links %}
|
||||
{% with form_navigation_links as object_navigation_links %}
|
||||
{% with 'true' as hide_active_anchor %}
|
||||
{% with 'active' as link_class_active %}
|
||||
{% with 'list-group-item btn-sm' as link_classes %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% for object_navigation_links in form_navigation_links %}
|
||||
{% with 'true' as hide_active_anchor %}
|
||||
{% with 'active' as link_class_active %}
|
||||
{% with 'list-group-item btn-sm' as link_classes %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
<div class="well center-block">
|
||||
<div class="row">
|
||||
{% with 'navigation/large_button_link.html' as link_template %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% for object_navigation_links in resolved_links %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<th>{% trans 'Identifier' %}</th>
|
||||
{% endif %}
|
||||
|
||||
{% for column in object_list.0|get_model_list_columns %}
|
||||
{% for column in object_list|get_model_list_columns %}
|
||||
<th>{{ column.name }}</th>
|
||||
{% endfor %}
|
||||
|
||||
@@ -101,17 +101,17 @@
|
||||
{% endfor %}
|
||||
{% if not hide_links %}
|
||||
<td class="last">
|
||||
{% get_menu_links 'object menu' source=object as links %}
|
||||
{% with links as object_navigation_links %}
|
||||
{% with 'true' as horizontal %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% get_menu_links 'object menu' source=object as resolved_links %}
|
||||
{% for object_navigation_links in resolved_links %}
|
||||
{% with 'true' as horizontal %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr><td colspan=99 class="tc">{% trans 'No results' %}</td></tr>
|
||||
<tr><td class="text-center" colspan=99>{% trans 'No results' %}</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
|
||||
<div class="well center-block">
|
||||
<div class="row">
|
||||
{% get_menu_links 'front page menu' as object_navigation_links %}
|
||||
{% get_menu_links 'front page menu' as resolved_links %}
|
||||
{% with 'navigation/large_button_link.html' as link_template %}
|
||||
{% with 'col-xs-12 col-sm-6 col-md-4 col-lg-4' as div_class %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% for object_navigation_links in resolved_links %}
|
||||
{% include 'navigation/generic_navigation.html' %}
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
@@ -459,7 +459,7 @@ class SetupListView(TemplateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
data = super(SetupListView, self).get_context_data(**kwargs)
|
||||
data.update({
|
||||
'object_navigation_links': menu_setup.resolve(context=RequestContext(self.request)),
|
||||
'resolved_links': menu_setup.resolve(context=RequestContext(self.request)),
|
||||
'title': _('Setup items'),
|
||||
})
|
||||
return data
|
||||
@@ -471,7 +471,7 @@ class ToolsListView(TemplateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
data = super(ToolsListView, self).get_context_data(**kwargs)
|
||||
data.update({
|
||||
'object_navigation_links': menu_tools.resolve(context=RequestContext(self.request)),
|
||||
'resolved_links': menu_tools.resolve(context=RequestContext(self.request)),
|
||||
'title': _('Tools'),
|
||||
})
|
||||
return data
|
||||
|
||||
@@ -86,29 +86,43 @@ class Menu(object):
|
||||
pass
|
||||
|
||||
for resolved_navigation_object in resolved_navigation_object_list:
|
||||
for source, links in self.bound_links.iteritems():
|
||||
resolved_links = []
|
||||
|
||||
for bound_source, links in self.bound_links.iteritems():
|
||||
try:
|
||||
if inspect.isclass(source) and isinstance(resolved_navigation_object, source) or source == CombinedSource(obj=resolved_navigation_object.__class__, view=current_view):
|
||||
if inspect.isclass(bound_source) and isinstance(resolved_navigation_object, bound_source) or source == CombinedSource(obj=resolved_navigation_object.__class__, view=current_view):
|
||||
for link in links:
|
||||
resolved_link = link.resolve(context=context, resolved_object=resolved_navigation_object)
|
||||
if resolved_link:
|
||||
result.append(resolved_link)
|
||||
resolved_links.append(resolved_link)
|
||||
break # No need for further content object match testing
|
||||
except TypeError:
|
||||
# When source is a dictionary
|
||||
pass
|
||||
|
||||
if resolved_links:
|
||||
result.append(resolved_links)
|
||||
|
||||
resolved_links = []
|
||||
# View links
|
||||
for link in self.bound_links.get(current_view, []):
|
||||
resolved_link = link.resolve(context)
|
||||
if resolved_link:
|
||||
result.append(resolved_link)
|
||||
resolved_links.append(resolved_link)
|
||||
|
||||
if resolved_links:
|
||||
result.append(resolved_links)
|
||||
|
||||
resolved_links = []
|
||||
|
||||
# Main menu links
|
||||
for link in self.bound_links.get(None, []):
|
||||
resolved_link = link.resolve(context)
|
||||
if resolved_link:
|
||||
result.append(resolved_link)
|
||||
resolved_links.append(resolved_link)
|
||||
|
||||
if resolved_links:
|
||||
result.append(resolved_links)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -20,16 +20,20 @@ def get_menus_links(context, names, source=None):
|
||||
result = []
|
||||
|
||||
for name in names.split(','):
|
||||
links = Menu.get(name=name).resolve(context)
|
||||
if links:
|
||||
result.append(links)
|
||||
for links in Menu.get(name=name).resolve(context):
|
||||
if links:
|
||||
result.append(links)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def get_multi_item_links_form(context, object_list):
|
||||
actions = [(link.url, link.text) for link in Menu.get('multi item menu').resolve(context=context, source=object_list[0])]
|
||||
actions = []
|
||||
for link_set in Menu.get('multi item menu').resolve(context=context, source=object_list[0]):
|
||||
for link in link_set:
|
||||
actions.append((link.url, link.text))
|
||||
|
||||
form = MultiItemForm(actions=actions)
|
||||
context.update({'multi_item_form': form, 'multi_item_actions': actions})
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user