Skip to content

Commit f211001

Browse files
authored
Merge pull request #613 from maykinmedia/feature/1378-dynamic-menu
[#1378] Updated new menus to use dynamic pages
2 parents e066454 + 458dc2f commit f211001

File tree

7 files changed

+48
-127
lines changed

7 files changed

+48
-127
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from django.db.models import Q
2+
3+
from cms.models import Page
4+
5+
6+
def active_apphooks(request):
7+
"""
8+
add lookup of active CMS apps to context
9+
10+
"cms_apps": {
11+
"ProfileApphook": True,
12+
"profile": True,
13+
}
14+
"""
15+
active_app_hooks = (
16+
Page.objects.published()
17+
.exclude(Q(application_urls="") | Q(application_urls__isnull=True))
18+
.values_list("application_urls", "application_namespace")
19+
)
20+
21+
lookup = dict()
22+
23+
for classname, namespace in active_app_hooks:
24+
lookup[classname] = True
25+
lookup[namespace] = True
26+
27+
context = {"cms_apps": lookup}
28+
29+
return context

src/open_inwoner/components/templates/components/Header/Header.html

+13-76
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{% accessibility_header request=request %}
66
<header class="header" aria-label="Navigatie header">
77
<div class="header__container">
8-
98
<div class="header__menu">
109
<button class="header__button">
1110
<div class="header__menu-icon">
@@ -28,61 +27,25 @@
2827

2928
<dialog class="header__submenu">
3029

30+
{% if cms_apps.products %}
3131
<nav class="header__actions" aria-label="Zoek navigatie mobiel">
3232
{% url 'search:search' as search_url %}
3333
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=False %}
3434
{% input search_form.query no_label=True %}
3535
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
3636
{% endrender_form %}
3737
</nav>
38-
39-
{# * * * Start DISABLED * * * Django CMS dynamic mobile menu#}
40-
{# <nav class="primary-navigation" aria-label="Hoofd navigatie">#}
41-
{# <ul class="primary-navigation__list">#}
42-
{# {% show_menu 0 100 100 100 "cms/menu/primary.html" %}#}
43-
{##}
44-
{# {% if has_general_faq_questions %}#}
45-
{# <li class="primary-navigation__list-item">#}
46-
{# {% link text=_('FAQ') href='general_faq' icon="help_outline" icon_position="before" icon_outlined=True %}#}
47-
{# </li>#}
48-
{# {% endif %}#}
49-
{# </ul>#}
50-
{##}
51-
{# <section class="header__actions" aria-label="Navigatie mobiel voor inloggen en uitloggen">#}
52-
{# <div class="header__text-actions">#}
53-
{# <p class="p">#}
54-
{# {% if request.user.is_authenticated %}{% icon icon="person" icon_position="before" icon_outlined=True %}{% trans "Ingelogd als" %} {{ request.user.get_short_name }}{% endif %}#}
55-
{# </p>#}
56-
{##}
57-
{# {% if request.user.is_authenticated %}#}
58-
{# <ul class="header__list">#}
59-
{# <li class="header__list-item">#}
60-
{# {% trans "Logout" as logout %}#}
61-
{# {% link text=logout href=request.user.get_logout_url icon="arrow_forward" icon_position="before" primary=True %}#}
62-
{# </li>#}
63-
{# </ul>#}
64-
{# {% elif config.login_show %}#}
65-
{# <ul class="header__list">#}
66-
{# <li class="header__list-item">#}
67-
{# {% url 'login' as login_url %}#}
68-
{# {% trans "Inloggen" as login %}#}
69-
{# {% button text="Inloggen" href=login_url icon="person" icon_position="before" primary=True icon_outlined=True transparent=True %}#}
70-
{# </li>#}
71-
{# </ul>#}
72-
{# {% endif %}#}
73-
{# </div>#}
74-
{# </section>#}
75-
{# </nav>#}
76-
{# * * * End of DISABLED * * * Django CMS dynamic mobile menu#}
38+
{% endif %}
7739

7840
<nav class="primary-navigation" aria-label="Hoofd navigatie">
7941
<ul class="primary-navigation__list">
8042

8143
<li class="primary-navigation__list-item">
8244
{% trans "Overzicht" as link_text %}
83-
{% url 'root' as link %}
84-
{% link text=link_text href=link icon="grid_view" icon_position="before" %}
45+
{% link text=link_text href="/" icon="grid_view" icon_position="before" %}
8546
</li>
47+
48+
{% if cms_apps.products and categories %}
8649
<li class="primary-navigation__list-item dropdown-nav__toggle">
8750
<a href="#" class="link link--toggle link--icon link--icon-position-before" aria-label="{% trans "Onderwerpen" %}" title="{% trans "Onderwerpen" %}">
8851
<span >{% trans "Onderwerpen" %}</span>
@@ -101,40 +64,10 @@
10164
</ul>
10265
{% endif %}
10366
</li>
67+
{% endif %}
10468

105-
{% if request.user.is_authenticated %}
106-
<li class="primary-navigation__list-item">
107-
{% link text=_("Mijn profiel") href='profile:detail' icon="inventory_2" icon_position="before" icon_outlined=True %}
108-
</li>
109-
<li class="primary-navigation__list-item">
110-
{% link text=_('Mijn berichten') href='inbox:index' icon="inbox" icon_position="before" %}
111-
{% with request.user.get_new_messages_total as total_messages %}
112-
{% if total_messages %}
113-
{% with ""|addstr:total_messages|addstr:"" as message_total %}
114-
<span class="indicator">{% link text=message_total href='inbox:index' secondary=True extra_classes="indicator__link" %}<span class="indicator__dot"></span></span>
115-
{% endwith %}
116-
{% endif %}
117-
{% endwith %}
118-
</li>
69+
{% show_menu_below_id "home" 0 100 100 100 "cms/menu/primary.html" %}
11970

120-
{% if request.user.bsn and config.show_cases %}
121-
<li class="primary-navigation__list-item">
122-
{% link text=_('Mijn aanvragen') href='cases:open_cases' icon="inventory_2" icon_position="before" icon_outlined=True %}
123-
</li>
124-
{% endif %}
125-
{% if show_plans %}
126-
<li class="primary-navigation__list-item">
127-
{% link text=_('Samenwerken') href='collaborate:plan_list' icon="people" icon_outlined=True icon_position="before" %}
128-
{% with request.user.get_plan_contact_new_count as plan_count %}
129-
{% if plan_count %}
130-
{% with ""|addstr:plan_count|addstr:"" as plan_count %}
131-
<span class="indicator">{% link text=plan_count href='collaborate:plan_list' secondary=True %}<span class="indicator__dot"></span></span>
132-
{% endwith %}
133-
{% endif %}
134-
{% endwith %}
135-
</li>
136-
{% endif %}
137-
{% endif %}
13871
{% if has_general_faq_questions %}
13972
<li class="primary-navigation__list-item">
14073
{% link text=_('FAQ') href='general_faq' icon="help_outline" icon_position="before" icon_outlined=True %}
@@ -170,20 +103,23 @@
170103
{% firstof config.logo.default_alt_text config.name as logo_alt_text %}
171104
<div class="logo__desktop">{% logo src=config.logo.file.url alt=logo_alt_text svg_height=75 %}</div>
172105

173-
{% primary_navigation categories=categories request=request has_general_faq_questions=has_general_faq_questions show_plans=show_plans %}
106+
{% primary_navigation categories=categories request=request has_general_faq_questions=has_general_faq_questions cms_apps=cms_apps show_plans=show_plans %}
174107

108+
{% if cms_apps.products %}
175109
<nav class="header__actions" aria-label="Zoek navigatie desktop">
176110
{% url 'search:search' as search_url %}
177111
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=True %}
178112
{% input search_form.query no_label=True %}
179113
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
180114
{% endrender_form %}
181115
</nav>
116+
{% endif %}
182117

183118
{% navigation_authenticated categories=categories request=request has_general_faq_questions=has_general_faq_questions %}
184-
185119
</div>
186120
</header>
121+
122+
{% if cms_apps.products %}
187123
<section class="search search__mobile">
188124
<nav class="search__actions " aria-label="Zoek navigatie mobiel">
189125
{% url 'search:search' as search_url %}
@@ -193,3 +129,4 @@
193129
{% endrender_form %}
194130
</nav>
195131
</section>
132+
{% endif %}

src/open_inwoner/components/templates/components/Header/NavigationAuthenticated.html

+1-33
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,7 @@
1010
{% button text=_('Welkom ')|addstr:request.user.get_short_name type="button" icon="expand_more" icon_position="after" icon_outlined=True transparent=True extra_classes="primary-navigation--toggle" %}
1111

1212
<ul class="primary-navigation__list subpage-list">
13-
<li class="primary-navigation__list-item">
14-
{% link text=_("Mijn profiel") href='profile:detail' icon="inventory_2" icon_position="before" icon_outlined=True %}
15-
</li>
16-
<li class="primary-navigation__list-item">
17-
{% link text=_('Mijn berichten') href='inbox:index' icon="inbox" icon_position="before" %}
18-
{% with request.user.get_new_messages_total as total_messages %}
19-
{% if total_messages %}
20-
{% with ""|addstr:total_messages|addstr:"" as message_total %}
21-
<span class="indicator">{% link text=message_total href='inbox:index' secondary=True extra_classes="indicator__link" %}<span class="indicator__dot"></span></span>
22-
{% endwith %}
23-
{% endif %}
24-
{% endwith %}
25-
</li>
26-
27-
{% get_solo 'configurations.SiteConfiguration' as config %}
28-
29-
{% if request.user.bsn and config.show_cases %}
30-
<li class="primary-navigation__list-item">
31-
{% link text=_('Mijn aanvragen') href='cases:open_cases' icon="inventory_2" icon_position="before" icon_outlined=True %}
32-
</li>
33-
{% endif %}
34-
{% if show_plans %}
35-
<li class="primary-navigation__list-item">
36-
{% link text=_('Samenwerken') href='collaborate:plan_list' icon="people" icon_outlined=True icon_position="before" %}
37-
{% with request.user.get_plan_contact_new_count as plan_count %}
38-
{% if plan_count %}
39-
{% with ""|addstr:plan_count|addstr:"" as plan_count %}
40-
<span class="indicator">{% link text=plan_count href='collaborate:plan_list' secondary=True %}<span class="indicator__dot"></span></span>
41-
{% endwith %}
42-
{% endif %}
43-
{% endwith %}
44-
</li>
45-
{% endif %}
13+
{% show_menu_below_id "home" 0 100 100 100 "cms/menu/primary.html" %}
4614

4715
{% if has_general_faq_questions %}
4816
<li class="primary-navigation__list-item">
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
{% load i18n header_tags form_tags icon_tags link_tags string_tags solo_tags menu_tags button_tags %}
22

3-
{# * * * Start of DISABLED * * * Django CMS dynamic Desktop menu#}
4-
{#<nav class="primary-navigation" aria-label="Hoofd navigatie">#}
5-
{# <ul class="primary-navigation__list">#}
6-
{# {% show_menu 0 100 100 100 "cms/menu/primary.html" %}#}
7-
{##}
8-
{# {% if has_general_faq_questions %}#}
9-
{# <li class="primary-navigation__list-item">#}
10-
{# {% link text=_('FAQ') href='general_faq' icon="help_outline" icon_position="before" icon_outlined=True %}#}
11-
{# </li>#}
12-
{# {% endif %}#}
13-
{# </ul>#}
14-
{#</nav>#}
15-
{# * * * End of DISABLED * * * Django CMS dynamic Desktop menu#}
16-
173
{% get_solo "configurations.SiteConfiguration" as config %}
184

195
<nav class="primary-navigation primary-navigation__main" aria-label="Hoofd navigatie">
206
<ul class="primary-navigation__list">
21-
7+
{% if cms_apps.products and categories %}
228
<li class="primary-navigation__list-item">
239
{% button text=_('Onderwerpen') type="button" icon="expand_more" icon_position="after" icon_outlined=True transparent=True extra_classes="primary-navigation--toggle" %}
2410

@@ -33,6 +19,6 @@
3319
</ul>
3420
{% endif %}
3521
</li>
36-
22+
{% endif %}
3723
</ul>
3824
</nav>

src/open_inwoner/conf/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
"django.contrib.auth.context_processors.auth",
267267
"django.contrib.messages.context_processors.messages",
268268
"open_inwoner.utils.context_processors.settings",
269+
"open_inwoner.cms.context_processors.active_apphooks",
269270
"sekizai.context_processors.sekizai",
270271
"cms.context_processors.cms_settings",
271272
"django.template.context_processors.i18n",

src/open_inwoner/templates/cms/menu/primary.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load menu_tags link_tags %}
22
{% for child in children %}
33
{% with url=child.attr.redirect_url|default:child.get_absolute_url %}
4-
<li class="primary-navigation__list-item child{% if child.selected %} selected{% endif %}{% if child.ancestor %} ancestor{% endif %}{% if child.sibling %} sibling{% endif %}{% if child.descendant %} descendant{% endif %}">
4+
<li class="primary-navigation__list-item">
55
{% link text=child.get_menu_title href=url icon=child.common.menu_icon icon_position="before" %}
66
{% if child.indicator %}
77
<span class="indicator"><a class="link secondary indicator__link" href="{{ url }}">{{ child.indicator }}<span class="indicator__dot"></span></a></span>

src/open_inwoner/templates/master.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
3838
{% cms_toolbar %}
39-
{% header categories=menu_categories request=request breadcrumbs=breadcrumbs search_form=search_form has_general_faq_questions=has_general_faq_questions %}
39+
{% header categories=menu_categories request=request breadcrumbs=breadcrumbs search_form=search_form has_general_faq_questions=has_general_faq_questions cms_apps=cms_apps %}
4040

4141
{% if anchors %}
4242
{% anchor_menu anchors=anchors desktop=False %}

0 commit comments

Comments
 (0)