refactor: remove favorite selection elements from filter modal and adjust filter button layout

This commit is contained in:
kdeterme 2026-10-12 15:00:11 +02:00
parent 3d76855d0e
commit 91b2ca79ad
2 changed files with 6 additions and 54 deletions

View file

@ -3135,24 +3135,6 @@ function initFavoriteFilters() {
});
}
const btnModalSave = document.getElementById('modal-save-favorite-btn');
if (btnModalSave) {
btnModalSave.addEventListener('click', function(e) {
e.preventDefault();
openSaveFavoriteModal();
});
}
// Modal favorite select change
const modalSelect = document.getElementById('modal-favorite-filter-select');
if (modalSelect) {
modalSelect.addEventListener('change', function() {
if (this.value) {
applyFavoriteFilter(this.value);
}
});
}
// Confirm save button
const btnConfirmSave = document.getElementById('btn-confirm-save-favorite');
if (btnConfirmSave) {
@ -3176,7 +3158,6 @@ function initFavoriteFilters() {
function renderFavoriteFiltersUI() {
const countBadge = document.getElementById('favorite-filters-count');
const itemsContainer = document.getElementById('favorite-filters-items');
const modalSelect = document.getElementById('modal-favorite-filter-select');
if (countBadge) {
countBadge.textContent = (typeof userFavoriteFilters !== 'undefined' && Array.isArray(userFavoriteFilters)) ? userFavoriteFilters.length : 0;
@ -3212,18 +3193,6 @@ function renderFavoriteFiltersUI() {
itemsContainer.innerHTML = html;
}
}
if (modalSelect) {
const currentVal = modalSelect.value;
let selectHtml = `<option value="">— ${gettext('Sélectionner un favori')} —</option>`;
if (typeof userFavoriteFilters !== 'undefined' && Array.isArray(userFavoriteFilters)) {
userFavoriteFilters.forEach(fav => {
selectHtml += `<option value="${fav.id}">${fav.name}</option>`;
});
}
modalSelect.innerHTML = selectHtml;
modalSelect.value = currentVal;
}
}
function getCurrentFilterValues() {
@ -3307,7 +3276,6 @@ function checkActiveFavoriteMatch() {
}
const activeLabel = document.getElementById('active-favorite-label');
const modalSelect = document.getElementById('modal-favorite-filter-select');
// Reset all star icons and active classes
document.querySelectorAll('.dropdown-item-favorite').forEach(el => el.classList.remove('active'));
@ -3327,16 +3295,10 @@ function checkActiveFavoriteMatch() {
if (activeStar) {
activeStar.className = 'bi bi-star-fill favorite-star-icon text-warning';
}
if (modalSelect) {
modalSelect.value = matchedFav.id;
}
} else {
if (activeLabel) {
activeLabel.textContent = gettext('Favoris');
}
if (modalSelect) {
modalSelect.value = '';
}
}
}

View file

@ -45,6 +45,10 @@
margin-top: 2px;
}
#filter-badge {
z-index: 5;
}
.dropdown-item-favorite {
transition: background-color 0.15s ease;
border-radius: 4px;
@ -578,20 +582,6 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
</div>
<div class="modal-body">
<!-- Barre de sélection rapide de favoris -->
<div class="d-flex flex-wrap align-items-center justify-content-between bg-light p-2 rounded mb-3 border gap-2">
<div class="d-flex align-items-center gap-2 flex-grow-1" style="min-width: 220px;">
<i class="bi bi-bookmark-star text-warning flex-shrink-0"></i>
<label for="modal-favorite-filter-select" class="form-label small fw-semibold mb-0 text-nowrap">{% translate "Favori :" %}</label>
<select id="modal-favorite-filter-select" class="form-select form-select-sm">
<option value="">{% translate "— Sélectionner un favori —" %}</option>
</select>
</div>
<button type="button" class="btn btn-sm btn-outline-primary text-nowrap" id="modal-save-favorite-btn">
<i class="bi bi-star me-1"></i>{% translate "Enregistrer en favori" %}
</button>
</div>
<!-- Formulaire de filtre -->
<form method="get" id="filter-form" class="mb-4">
<!-- Thématique, Statut et Catégorie -->
@ -1299,8 +1289,8 @@
<div id="interventions-table-container" style="display: none; flex: 1; min-height: 0; overflow: hidden;">
<!-- Bouton de filtre et Favoris -->
<div id="filter-dropdown-wrapper" class="float-left mb-2 d-flex align-items-center gap-1">
<button class="btn btn-light position-relative" type="button" data-bs-toggle="modal" data-bs-target="#filterModal">
<div id="filter-dropdown-wrapper" class="float-left mb-2 d-flex align-items-center">
<button class="btn btn-light position-relative me-3" type="button" data-bs-toggle="modal" data-bs-target="#filterModal">
<i class="bi bi-funnel"></i> {% translate "Filtre" %}
<span id="filter-badge" class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-black d-none">
<span id="filter-count">0</span>