Skip to content

Commit

Permalink
fix(dashboard_siae): fix du bug d'affichage des tabs pour compléter l…
Browse files Browse the repository at this point in the history
…es données des siaes (#1093)

* fix(dashboard_siae) : fix du bug d'affichage des tabs pour compléter les données des siaes

* fix edge case of external link
  • Loading branch information
madjid-asa authored Feb 21, 2024
1 parent 8874279 commit bc91e10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions lemarche/static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ window.addEventListener('DOMContentLoaded', function () {
initModalMessages();

// reload click events and tooltip after htmx content loading as in semantic search
document.addEventListener('htmx:afterSwap', function(event) {
document.addEventListener('htmx:afterSwap', function (event) {
initSuperBadges();
});
initSuperBadges();
Expand Down Expand Up @@ -79,17 +79,22 @@ const initSuperBadges = () => {

});
});
$('.s-tabs-01__nav .nav-item').on('click', function (event) {
$('#siaes_tabs .nav-item').on('click', function (event) {
event.preventDefault()
let tabContent = this.parentElement.parentElement.querySelector(".tab-content");
let hasSuperBadgeTab = this.children[0].classList.contains("super-badge-tab");
let childLink = this.children[0];

if (hasSuperBadgeTab) {
tabContent.classList.add("super-badge-tab");
if (childLink.classList.contains("nav-link-external")) { //edge case for external links
window.location = childLink.href;
} else {
tabContent.classList.remove("super-badge-tab");
let hasSuperBadgeTab = childLink.classList.contains("super-badge-tab");

if (hasSuperBadgeTab) {
tabContent.classList.add("super-badge-tab");
} else {
tabContent.classList.remove("super-badge-tab");
}
}
$(this).tab('show');
})
}

Expand Down
4 changes: 2 additions & 2 deletions lemarche/templates/dashboard/home_siae.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1 class="s-title-01__title h1"><strong>Tableau de bord</strong></h1>
{% if user.siaeuser_set.count %}
<section class="s-tabs-01 mb-3 mb-lg-5">
<div class="s-tabs-01__container container">
<div class="s-tabs-01__row row">
<div id="siaes_tabs" class="s-tabs-01__row row">
<div class="s-tabs-01__col col-12">
<ul class="s-tabs-01__nav nav nav-tabs" role="tablist">
{% for siaeuser in user.siaeuser_set.all %}
Expand All @@ -53,7 +53,7 @@ <h1 class="s-title-01__title h1"><strong>Tableau de bord</strong></h1>
</li>
{% endfor %}
<li class="nav-item" role="presentation">
<a class="nav-link" id="add-siae-btn" href="{% url 'dashboard_siaes:siae_search_by_siret' %}" aria-selected="false">
<a class="nav-link nav-link-external" id="add-siae-btn" href="{% url 'dashboard_siaes:siae_search_by_siret' %}" aria-selected="false">
<i class="ri-add-line"></i>
<span>Ajouter une structure</span>
</a>
Expand Down

0 comments on commit bc91e10

Please sign in to comment.