Skip to content

Commit

Permalink
[#2036] Added tab navigation for login pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jiromaykin committed Jan 30, 2024
1 parent bcfa399 commit 3caaac9
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% block content %}

<div class="registration-grid">
<h1 class="utrecht-heading-1">{% trans 'Registreren' %}</h1>
{% render_grid %}
{% if settings.DIGID_ENABLED and digid_url %}
{% render_column start=5 span=5 %}
Expand All @@ -30,13 +30,12 @@
{% if login_allow_registration %}
{% render_column start=5 span=5 %}
{% render_card tinted=True %}
<h1 class="h3">{% trans "Registreren met E-mail" %}</h1><br>
<h3 class="h3">{% trans "Registreren met E-mail" %}</h3>
{% form form_object=form method="POST" id="registration-form" submit_text=_('Registreren') extra_classes="form__registration" show_required=True %}
{% endrender_card %}
{% endrender_column %}
{% endif %}

{% endrender_grid %}
</div>

{% endblock content %}
187 changes: 102 additions & 85 deletions src/open_inwoner/accounts/templates/registration/login.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends 'master.html' %}
{% load i18n static logo_tags grid_tags card_tags form_tags link_tags button_tags solo_tags cms_tags %}
{% load i18n static logo_tags grid_tags card_tags form_tags link_tags button_tags icon_tags solo_tags cms_tags %}


{% block header_image %}
Expand All @@ -8,91 +8,108 @@


{% block content %}
<div class="login-grid">
{% render_grid %}
{% render_column start=5 span=5 %}
{% render_card %}
<h1 class="h1">{% trans 'Welkom' %}</h1>
{% if login_text %}<p class="p">{{ login_text|linebreaksbr }}</p>{% endif %}
<br>
{% if settings.DIGID_ENABLED %}
{% get_solo 'digid_eherkenning_oidc_generics.OpenIDConnectDigiDConfig' as digid_oidc_config %}
{% if digid_oidc_config.enabled %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'digid_oidc:init' %}" class="link digid-logo">
<img class="digid-logo__image" src="{% static 'accounts/digid_logo.svg' %}" alt="DigiD inlogpagina">
</a>
{% url 'digid_oidc:init' as href %}
{% link href=href text=_('Inloggen met DigiD') secondary=True icon='arrow_forward' extra_classes="link--digid" %}
{% endrender_card %}
{% else %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'digid:login' %}" class="link digid-logo">
<img class="digid-logo__image" src="{% static 'accounts/digid_logo.svg' %}" alt="DigiD inlogpagina">
</a>
{% url 'digid:login' as href %}
{% with href|addnexturl:next as href_with_next %}
{% link href=href_with_next text=_('Inloggen met DigiD') secondary=True icon='arrow_forward' extra_classes="link--digid" %}
{% endwith %}
{% endrender_card %}
{% endif %}
{% endif %}
<h1 class="utrecht-heading-1">{% trans 'Welkom' %}</h1>
{% if login_text %}<p class="p">{{ login_text|linebreaksbr }}</p>{% endif %}

{% if eherkenning_enabled %}
{% get_solo 'digid_eherkenning_oidc_generics.OpenIDConnectEHerkenningConfig' as eherkenning_oidc_config %}
{% if eherkenning_oidc_config.enabled %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'eherkenning_oidc:init' %}" class="link eherkenning-logo">
<img class="eherkenning-logo__image" src="{% static 'accounts/eherkenning.png' %}" height=30 alt="eHerkenning inlogpagina">
</a>
{% url 'eherkenning_oidc:init' as href %}
{% link href=href text=_('Inloggen met eHerkenning') secondary=True icon='arrow_forward' extra_classes="link--eherkenning" %}
{% endrender_card %}
{% else %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'eherkenning:login' %}" class="link eherkenning-logo">
<img class="eherkenning-logo__image" src="{% static 'accounts/eherkenning.png' %}" height=30 alt="eHerkenning inlogpagina">
</a>
{% url 'eherkenning:login' as href %}
{% with href|addnexturl:next as href_with_next %}
{% link href=href_with_next text=_('Inloggen met eHerkenning') secondary=True icon='arrow_forward' extra_classes="link--eherkenning" %}
{% endwith %}
{% endrender_card %}
{% endif %}
{% endif %}
{# Tab panels Start #}
<div class="tab--container login-tab--container">
<div class="tabs">
<ul class="list tabs__headers">
<li class="list-item tab__header--item"><a href="/accounts/login" class="link tab__header active">Particulier</a></li>
<li class="list-item tab__header--item"><a href="/accounts/login-business" class="link tab__header">Zakelijk</a></li>
</ul>
{# Panel 1 #}
<div class="tabs__body">

{% get_solo 'mozilla_django_oidc_db.OpenIDConnectConfig' as oidc_config %}
{% get_solo 'configurations.SiteConfiguration' as site_config %}
{% if oidc_config.enabled and site_config.openid_enabled_for_regular_users %}
{% render_card tinted=True direction='horizontal' %}
{% if site_config.openid_connect_logo %}
<a href="{% url 'oidc_authentication_init' %}" class="link digid-logo">
<img class="digid-logo__image" src="{{ site_config.openid_connect_logo.url }}" alt="{{ site_config.openid_connect_logo.default_alt_text }}">
</a>
{% else %}
<div></div>
{% endif %}
{% url 'oidc_authentication_init' as href %}
{% with href|addnexturl:next as href_with_next %}
{% link text=site_config.openid_connect_login_text href=href_with_next secondary=True icon='arrow_forward' icon_position="after" %}
{% endwith %}
{% endrender_card %}
{% endif %}
<div id="particulier" class="tab__content">
{% render_grid %}
{% if settings.DIGID_ENABLED %}
{% render_column start=4 span=5 %}
{% get_solo 'digid_eherkenning_oidc_generics.OpenIDConnectDigiDConfig' as digid_oidc_config %}
{% if digid_oidc_config.enabled %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'digid_oidc:init' %}" class="link digid-logo">
<img class="digid-logo__image" src="{% static 'accounts/digid_logo.svg' %}" alt="DigiD inlogpagina">
</a>
{% url 'digid_oidc:init' as href %}
{% link href=href text=_('Inloggen met DigiD') primary=True icon='arrow_forward' extra_classes="link--digid" %}
{% endrender_card %}
{% else %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'digid:login' %}" class="link digid-logo">
<img class="digid-logo__image" src="{% static 'accounts/digid_logo.svg' %}" alt="DigiD inlogpagina">
</a>
{% url 'digid:login' as href %}
{% with href|addnexturl:next as href_with_next %}
{% link href=href_with_next text=_('Inloggen met DigiD') primary=True icon='arrow_forward' extra_classes="link--digid" %}
{% endwith %}
{% endrender_card %}
{% endif %}
{% endrender_column %}

{% if login_allow_registration %}
{% render_card tinted=True %}
{% render_form id="login-form" method="POST" form=form show_required=True %}
{% csrf_token %}
<input type="hidden" name="next" value="{{next}}" />
{% input form.username %}
{% input form.password %}
{% button text=_('Wachtwoord vergeten?') href='password_reset' secondary=True transparent=True align='right' %}
{% form_actions primary_text=_("Inloggen") primary_icon="arrow_forward" secondary_href='django_registration_register' secondary_text=_('Registreer') secondary_icon='arrow_forward' single=True %}
{% endrender_form %}
{% endrender_card %}
{% endif %}
{% endrender_card %}
{% endrender_column %}
{% endrender_grid %}
</div>
{% get_solo 'mozilla_django_oidc_db.OpenIDConnectConfig' as oidc_config %}
{% get_solo 'configurations.SiteConfiguration' as site_config %}
{% if oidc_config.enabled and site_config.openid_enabled_for_regular_users %}
{% render_column start=4 span=5 %}
{% render_card tinted=True direction='horizontal' %}
{% if site_config.openid_connect_logo %}
<a href="{% url 'oidc_authentication_init' %}" class="link digid-logo">
<img class="digid-logo__image" src="{{ site_config.openid_connect_logo.url }}" alt="{{ site_config.openid_connect_logo.default_alt_text }}">
</a>
{% else %}
<div></div>
{% endif %}
{% url 'oidc_authentication_init' as href %}
{% with href|addnexturl:next as href_with_next %}
{% link text=site_config.openid_connect_login_text href=href_with_next primary=True icon='arrow_forward' icon_position="after" %}
{% endwith %}
{% endrender_card %}
{% endrender_column %}
{% endif %}

{% if login_allow_registration %}
{% render_column start=4 span=5 %}
{% render_card direction='horizontal' tinted=True %}
<a href="#email" class="link icon--large">
{% icon icon="login" icon_position="before" outlined=True %}
</a>
{% link href="#email" text=_('Log in met e-mail adres') primary=True icon='arrow_forward' %}
{% endrender_card %}
{% endrender_column %}

{% render_column start=4 span=5 %}
{% render_card tinted=True %}
{% render_form id="login-form" method="POST" form=form show_required=True %}
{% csrf_token %}
<input type="hidden" name="next" value="{{next}}" id="email"/>
{% input form.username %}
{% input form.password %}
{% button text=_('Wachtwoord vergeten?') href='password_reset' primary=True transparent=True align='right' %}
{% form_actions primary_text=_("Inloggen") primary_icon="arrow_forward" single=True %}
{% endrender_form %}
{% endrender_card %}
{% endrender_column %}

{% render_column start=4 span=5 %}
<h4 class="h4">Of registreer</h4>
{% render_card direction='horizontal' tinted=True %}
<a href="/accounts/register" class="link icon--large">
{% icon icon="account_circle" icon_position="before" outlined=True %}
</a>
{% link href="/accounts/register" text=_('Maak een account aan') primary=True icon='arrow_forward' %}
{% endrender_card %}
{% endrender_column %}

{% endif %}

{% endif %}

{% endrender_grid %}
</div>
{# Panel 2 #}
{# Panel 2 End #}
</div>
</div>
</div>
{# Tab panels End #}
{% endblock content %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{% extends 'master.html' %}
{% load i18n static logo_tags grid_tags card_tags form_tags link_tags button_tags solo_tags cms_tags %}


{% block header_image %}
{% static_placeholder 'login_banner' %}
{% endblock header_image %}


{% block content %}

<h1 class="utrecht-heading-1">{% trans 'Inloggen' %}</h1>
{% if login_text %}<p class="p">{{ login_text|linebreaksbr }}</p>{% endif %}

{# Tab panels Start #}
<div class="tab--container login-tab--container">
<div class="tabs">
<ul class="list tabs__headers">
<li class="list-item tab__header--item"><a href="/accounts/login" class="link tab__header">Particulier</a></li>
<li class="list-item tab__header--item"><a href="/accounts/login-business" class="link tab__header active">Zakelijk</a></li>
</ul>
{# Panel 1 #}
<div class="tabs__body">

{# Panel 2 #}
<div id="zakelijk" class="tab__content">

{% render_grid %}
{% render_column start=4 span=5 %}
<h4 class="h4">Zakelijk</h4>
{% if eherkenning_enabled %}
{% get_solo 'digid_eherkenning_oidc_generics.OpenIDConnectEHerkenningConfig' as eherkenning_oidc_config %}
{% if eherkenning_oidc_config.enabled %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'eherkenning_oidc:init' %}" class="link eherkenning-logo">
<img class="eherkenning-logo__image" src="{% static 'accounts/eherkenning.png' %}" height=30 alt="eHerkenning inlogpagina">
</a>
{% url 'eherkenning_oidc:init' as href %}
{% link href=href text=_('Inloggen met eHerkenning') primary=True icon='arrow_forward' extra_classes="link--eherkenning" %}
{% endrender_card %}
{% else %}
{% render_card direction='horizontal' tinted=True %}
<a href="{% url 'eherkenning:login' %}" class="link eherkenning-logo">
<img class="eherkenning-logo__image" src="{% static 'accounts/eherkenning.png' %}" height=30 alt="eHerkenning inlogpagina">
</a>
{% url 'eherkenning:login' as href %}
{% with href|addnexturl:next as href_with_next %}
{% link href=href_with_next text=_('Inloggen met eHerkenning') primary=True icon='arrow_forward' extra_classes="link--eherkenning" %}
{% endwith %}
{% endrender_card %}
{% endif %}
{% endif %}
{% endrender_column %}
{% endrender_grid %}

</div>
{# Panel 2 End #}
</div>
</div>
</div>
{# Tab panels End #}

{% endblock content %}
1 change: 1 addition & 0 deletions src/open_inwoner/accounts/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .invite import InviteAcceptView
from .login import (
AddPhoneNumberWizardView,
CustomBusinessLoginView,
CustomLoginView,
ResendTokenView,
VerifyTokenView,
Expand Down
4 changes: 4 additions & 0 deletions src/open_inwoner/accounts/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def form_valid(self, form):
return redirect(furl(reverse("verify_token")).add(params).url)


class CustomBusinessLoginView(CustomLoginView):
template_name = "registration/login_business.html"


class VerifyTokenView(ThrottleMixin, FormView):
throttle_visits = 3
throttle_period = 60
Expand Down
2 changes: 2 additions & 0 deletions src/open_inwoner/js/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import './preview'
import './questionnaire'
import './readmore'
import './search'
import { TabPanel } from './tab-panels'
import './toggle'
import { StatusAccordion } from './cases/status_accordion'
import './session'
Expand All @@ -53,6 +54,7 @@ const elementWrappers = [
],
[Notification.selector, (elt) => new Notification(elt)],
[AnchorMobile.selector, (elt) => new AnchorMobile(elt)],
[TabPanel.selector, (elt) => new TabPanel(elt)],
[StatusAccordion.selector, (elt) => new StatusAccordion(elt)],
[FileInput.selector, (elt) => new FileInput(elt)],
]
Expand Down
49 changes: 49 additions & 0 deletions src/open_inwoner/js/components/tab-panels/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// export class TabPanel {
// static selector = '.login-tab--container'
//
// constructor(node) {
// this.node = node
// this.tabHeadersRow = node.querySelector('.tabs__headers')
// this.tabHeaders = node.querySelectorAll('.tab__header')
// this.tabContent = node.querySelectorAll('.tab__content')
//
// this.hideContent()
// this.showContent()
//
// this.tabHeadersRow.addEventListener('click', (e) => {
// // To prevent scrolling to the tab
// e.preventDefault()
// const target = e.target
// if (target.classList.contains('tab__header')) {
// console.log('there is a tabheader')
// this.tabHeaders.forEach((item, i) => {
// if (target == item) {
// this.hideContent()
// this.showContent(i)
// }
// })
// }
// })
// }
//
// hideContent() {
// console.log('Hide tab...')
// this.tabContent.forEach((item) => {
// item.classList.add('hide')
// item.classList.remove('active')
// })
// this.tabHeaders.forEach((item) => {
// item.classList.remove('active')
// })
// }
//
// showContent(i = 0) {
// console.log('Show tab...')
// this.tabContent[i].classList.add('active')
// this.tabContent[i].classList.remove('hide')
// this.tabHeaders[i].classList.add('active')
// }
// }
//
// const tabpanels = document.querySelectorAll(TabPanel.selector)
// ;[...tabpanels].forEach((tabpanel) => new TabPanel(tabpanel))
Loading

0 comments on commit 3caaac9

Please sign in to comment.