Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1378] Updated new menus to use dynamic pages #613

Merged
merged 3 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/open_inwoner/cms/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.db.models import Q

from cms.models import Page


def active_apphooks(request):
"""
add lookup of active CMS apps to context

"cms_apps": {
"ProfileApphook": True,
"profile": True,
}
"""
active_app_hooks = (
Page.objects.published()
.exclude(Q(application_urls="") | Q(application_urls__isnull=True))
.values_list("application_urls", "application_namespace")
)

lookup = dict()

for classname, namespace in active_app_hooks:
lookup[classname] = True
lookup[namespace] = True

context = {"cms_apps": lookup}

return context
89 changes: 13 additions & 76 deletions src/open_inwoner/components/templates/components/Header/Header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{% accessibility_header request=request %}
<header class="header" aria-label="Navigatie header">
<div class="header__container">

<div class="header__menu">
<button class="header__button">
<div class="header__menu-icon">
Expand All @@ -28,61 +27,25 @@

<dialog class="header__submenu">

{% if cms_apps.products %}
<nav class="header__actions" aria-label="Zoek navigatie mobiel">
{% url 'search:search' as search_url %}
{% render_form form=search_form method="GET" form_action=search_url inline=True spaceless=False %}
{% input search_form.query no_label=True %}
{% form_actions primary_icon="search" primary_text=_("Zoeken") hide_primary_text=True %}
{% endrender_form %}
</nav>

{# * * * Start DISABLED * * * Django CMS dynamic mobile menu#}
{# <nav class="primary-navigation" aria-label="Hoofd navigatie">#}
{# <ul class="primary-navigation__list">#}
{# {% show_menu 0 100 100 100 "cms/menu/primary.html" %}#}
{##}
{# {% if has_general_faq_questions %}#}
{# <li class="primary-navigation__list-item">#}
{# {% link text=_('FAQ') href='general_faq' icon="help_outline" icon_position="before" icon_outlined=True %}#}
{# </li>#}
{# {% endif %}#}
{# </ul>#}
{##}
{# <section class="header__actions" aria-label="Navigatie mobiel voor inloggen en uitloggen">#}
{# <div class="header__text-actions">#}
{# <p class="p">#}
{# {% if request.user.is_authenticated %}{% icon icon="person" icon_position="before" icon_outlined=True %}{% trans "Ingelogd als" %} {{ request.user.get_short_name }}{% endif %}#}
{# </p>#}
{##}
{# {% if request.user.is_authenticated %}#}
{# <ul class="header__list">#}
{# <li class="header__list-item">#}
{# {% trans "Logout" as logout %}#}
{# {% link text=logout href=request.user.get_logout_url icon="arrow_forward" icon_position="before" primary=True %}#}
{# </li>#}
{# </ul>#}
{# {% elif config.login_show %}#}
{# <ul class="header__list">#}
{# <li class="header__list-item">#}
{# {% url 'login' as login_url %}#}
{# {% trans "Inloggen" as login %}#}
{# {% button text="Inloggen" href=login_url icon="person" icon_position="before" primary=True icon_outlined=True transparent=True %}#}
{# </li>#}
{# </ul>#}
{# {% endif %}#}
{# </div>#}
{# </section>#}
{# </nav>#}
{# * * * End of DISABLED * * * Django CMS dynamic mobile menu#}
{% endif %}

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

<li class="primary-navigation__list-item">
{% trans "Overzicht" as link_text %}
{% url 'root' as link %}
{% link text=link_text href=link icon="grid_view" icon_position="before" %}
{% link text=link_text href="/" icon="grid_view" icon_position="before" %}
</li>

{% if cms_apps.products and categories %}
<li class="primary-navigation__list-item dropdown-nav__toggle">
<a href="#" class="link link--toggle link--icon link--icon-position-before" aria-label="{% trans "Onderwerpen" %}" title="{% trans "Onderwerpen" %}">
<span >{% trans "Onderwerpen" %}</span>
Expand All @@ -101,40 +64,10 @@
</ul>
{% endif %}
</li>
{% endif %}

{% if request.user.is_authenticated %}
<li class="primary-navigation__list-item">
{% link text=_("Mijn profiel") href='profile:detail' icon="inventory_2" icon_position="before" icon_outlined=True %}
</li>
<li class="primary-navigation__list-item">
{% link text=_('Mijn berichten') href='inbox:index' icon="inbox" icon_position="before" %}
{% with request.user.get_new_messages_total as total_messages %}
{% if total_messages %}
{% with ""|addstr:total_messages|addstr:"" as message_total %}
<span class="indicator">{% link text=message_total href='inbox:index' secondary=True extra_classes="indicator__link" %}<span class="indicator__dot"></span></span>
{% endwith %}
{% endif %}
{% endwith %}
</li>
{% show_menu_below_id "home" 0 100 100 100 "cms/menu/primary.html" %}

{% if request.user.bsn and config.show_cases %}
<li class="primary-navigation__list-item">
{% link text=_('Mijn aanvragen') href='cases:open_cases' icon="inventory_2" icon_position="before" icon_outlined=True %}
</li>
{% endif %}
{% if show_plans %}
<li class="primary-navigation__list-item">
{% link text=_('Samenwerken') href='collaborate:plan_list' icon="people" icon_outlined=True icon_position="before" %}
{% with request.user.get_plan_contact_new_count as plan_count %}
{% if plan_count %}
{% with ""|addstr:plan_count|addstr:"" as plan_count %}
<span class="indicator">{% link text=plan_count href='collaborate:plan_list' secondary=True %}<span class="indicator__dot"></span></span>
{% endwith %}
{% endif %}
{% endwith %}
</li>
{% endif %}
{% endif %}
{% if has_general_faq_questions %}
<li class="primary-navigation__list-item">
{% link text=_('FAQ') href='general_faq' icon="help_outline" icon_position="before" icon_outlined=True %}
Expand Down Expand Up @@ -170,20 +103,23 @@
{% firstof config.logo.default_alt_text config.name as logo_alt_text %}
<div class="logo__desktop">{% logo src=config.logo.file.url alt=logo_alt_text svg_height=75 %}</div>

{% primary_navigation categories=categories request=request has_general_faq_questions=has_general_faq_questions show_plans=show_plans %}
{% primary_navigation categories=categories request=request has_general_faq_questions=has_general_faq_questions cms_apps=cms_apps show_plans=show_plans %}

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

{% navigation_authenticated categories=categories request=request has_general_faq_questions=has_general_faq_questions %}

</div>
</header>

{% if cms_apps.products %}
<section class="search search__mobile">
<nav class="search__actions " aria-label="Zoek navigatie mobiel">
{% url 'search:search' as search_url %}
Expand All @@ -193,3 +129,4 @@
{% endrender_form %}
</nav>
</section>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,7 @@
{% 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" %}

<ul class="primary-navigation__list subpage-list">
<li class="primary-navigation__list-item">
{% link text=_("Mijn profiel") href='profile:detail' icon="inventory_2" icon_position="before" icon_outlined=True %}
</li>
<li class="primary-navigation__list-item">
{% link text=_('Mijn berichten') href='inbox:index' icon="inbox" icon_position="before" %}
{% with request.user.get_new_messages_total as total_messages %}
{% if total_messages %}
{% with ""|addstr:total_messages|addstr:"" as message_total %}
<span class="indicator">{% link text=message_total href='inbox:index' secondary=True extra_classes="indicator__link" %}<span class="indicator__dot"></span></span>
{% endwith %}
{% endif %}
{% endwith %}
</li>

{% get_solo 'configurations.SiteConfiguration' as config %}

{% if request.user.bsn and config.show_cases %}
<li class="primary-navigation__list-item">
{% link text=_('Mijn aanvragen') href='cases:open_cases' icon="inventory_2" icon_position="before" icon_outlined=True %}
</li>
{% endif %}
{% if show_plans %}
<li class="primary-navigation__list-item">
{% link text=_('Samenwerken') href='collaborate:plan_list' icon="people" icon_outlined=True icon_position="before" %}
{% with request.user.get_plan_contact_new_count as plan_count %}
{% if plan_count %}
{% with ""|addstr:plan_count|addstr:"" as plan_count %}
<span class="indicator">{% link text=plan_count href='collaborate:plan_list' secondary=True %}<span class="indicator__dot"></span></span>
{% endwith %}
{% endif %}
{% endwith %}
</li>
{% endif %}
{% show_menu_below_id "home" 0 100 100 100 "cms/menu/primary.html" %}

{% if has_general_faq_questions %}
<li class="primary-navigation__list-item">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
{% load i18n header_tags form_tags icon_tags link_tags string_tags solo_tags menu_tags button_tags %}

{# * * * Start of DISABLED * * * Django CMS dynamic Desktop menu#}
{#<nav class="primary-navigation" aria-label="Hoofd navigatie">#}
{# <ul class="primary-navigation__list">#}
{# {% show_menu 0 100 100 100 "cms/menu/primary.html" %}#}
{##}
{# {% if has_general_faq_questions %}#}
{# <li class="primary-navigation__list-item">#}
{# {% link text=_('FAQ') href='general_faq' icon="help_outline" icon_position="before" icon_outlined=True %}#}
{# </li>#}
{# {% endif %}#}
{# </ul>#}
{#</nav>#}
{# * * * End of DISABLED * * * Django CMS dynamic Desktop menu#}

{% get_solo "configurations.SiteConfiguration" as config %}

<nav class="primary-navigation primary-navigation__main" aria-label="Hoofd navigatie">
<ul class="primary-navigation__list">

{% if cms_apps.products and categories %}
<li class="primary-navigation__list-item">
{% button text=_('Onderwerpen') type="button" icon="expand_more" icon_position="after" icon_outlined=True transparent=True extra_classes="primary-navigation--toggle" %}

Expand All @@ -33,6 +19,6 @@
</ul>
{% endif %}
</li>

{% endif %}
</ul>
</nav>
1 change: 1 addition & 0 deletions src/open_inwoner/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"open_inwoner.utils.context_processors.settings",
"open_inwoner.cms.context_processors.active_apphooks",
"sekizai.context_processors.sekizai",
"cms.context_processors.cms_settings",
"django.template.context_processors.i18n",
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/templates/cms/menu/primary.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load menu_tags link_tags %}
{% for child in children %}
{% with url=child.attr.redirect_url|default:child.get_absolute_url %}
<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 %}">
<li class="primary-navigation__list-item">
{% link text=child.get_menu_title href=url icon=child.common.menu_icon icon_position="before" %}
{% if child.indicator %}
<span class="indicator"><a class="link secondary indicator__link" href="{{ url }}">{{ child.indicator }}<span class="indicator__dot"></span></a></span>
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

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

{% if anchors %}
{% anchor_menu anchors=anchors desktop=False %}
Expand Down