diff --git a/web/modules/custom/figli_compta_ledger/css/home.css b/web/modules/custom/figli_compta_ledger/css/home.css index c036668..49e48a9 100644 --- a/web/modules/custom/figli_compta_ledger/css/home.css +++ b/web/modules/custom/figli_compta_ledger/css/home.css @@ -58,6 +58,15 @@ html.gin--dark-mode #figli-home-app { border-radius: 4px; } +/* Compte/Type filters: . // "aller" isn't an ongoing filter (jumpYearValue itself always resets // to '' right after firing) but its target year is worth remembering // for this purpose, so it's tracked separately (lastJumpYear) purely @@ -216,9 +218,9 @@ function readHashState() { const params = new URLSearchParams(location.hash.replace(/^#/, '')); return { - filterCompte: params.get('compte') || '', + filterCompte: params.get('compte') ? params.get('compte').split(',') : [], filterClient: params.get('client') || '', - filterType: params.get('type') || '', + filterType: params.get('type') ? params.get('type').split(',') : [], filterYear: params.get('annee') || '', onlyErrors: params.get('ecarts') === '1', aller: params.get('aller') || '', @@ -227,9 +229,9 @@ function buildHashString(state) { const params = new URLSearchParams(); - if (state.filterCompte) params.set('compte', state.filterCompte); + if (state.filterCompte.length) params.set('compte', state.filterCompte.join(',')); if (state.filterClient) params.set('client', state.filterClient); - if (state.filterType) params.set('type', state.filterType); + if (state.filterType.length) params.set('type', state.filterType.join(',')); if (state.filterYear) params.set('annee', state.filterYear); if (state.onlyErrors) params.set('ecarts', '1'); // Redundant/ambiguous alongside an active "Année" filter -- that @@ -302,9 +304,13 @@ allClientsList: [], allYearsList: [], ouvertureEcarts: {}, - filterCompte: '', + // Arrays -- both are native to an array natively, no custom handling needed). An + // empty array means "tous", same as the single-value '' used to. + filterCompte: [], filterClient: '', - filterType: '', + filterType: [], filterYear: '', jumpYearValue: '', // Not a filter itself (jumpYearValue always resets to '' right @@ -482,9 +488,12 @@ }, filteredRows() { return this.rows.filter((r) => { - if (this.filterCompte && r.parCompte[this.filterCompte] === undefined) return false; + // Several selected comptes/types match with OR semantics ("any + // of these") -- a line either touches one of the selected + // comptes or it doesn't, same idea for type. + if (this.filterCompte.length && !this.filterCompte.some((c) => r.parCompte[c] !== undefined)) return false; if (this.filterClient && r.client !== this.filterClient) return false; - if (this.filterType && r.type !== this.filterType) return false; + if (this.filterType.length && !this.filterType.includes(r.type)) return false; if (this.filterYear && (r.date || '').slice(0, 4) !== this.filterYear) return false; if (this.onlyErrors && !r.hasError) return false; return true; @@ -960,7 +969,7 @@ // filter with only a few matches a year could search almost forever // without surfacing more of them. isFiltering() { - return !!(this.filterCompte || this.filterClient || this.filterType || this.onlyErrors); + return !!(this.filterCompte.length || this.filterClient || this.filterType.length || this.onlyErrors); }, // Keeps extending the window (both directions) as long as a filter // leaves too few matching rows to fill the viewport -- otherwise diff --git a/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig b/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig index 57acde8..d57dec0 100644 --- a/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig +++ b/web/modules/custom/figli_compta_ledger/templates/figli-compta-home.html.twig @@ -20,8 +20,7 @@ {% verbatim %} @@ -34,8 +33,7 @@