diff --git a/web/modules/custom/figli_compta_ledger/css/hide-admin-sidebar.css b/web/modules/custom/figli_compta_ledger/css/hide-admin-sidebar.css new file mode 100644 index 0000000..05b5c6e --- /dev/null +++ b/web/modules/custom/figli_compta_ledger/css/hide-admin-sidebar.css @@ -0,0 +1,13 @@ +/* The core Navigation module's admin sidebar (#admin-toolbar, ~65px fixed + rail) + its collapsed-state control bar and overlay. Only attached on + this module's own front-end routes (see + figli_compta_ledger_page_attachments()) -- real Drupal admin pages + (/admin/*, node edit forms, etc.) keep the sidebar as normal. */ +#admin-toolbar, +.admin-toolbar-control-bar, +.admin-toolbar-overlay { + display: none !important; +} +.dialog-off-canvas-main-canvas { + margin-inline-start: 0 !important; +} diff --git a/web/modules/custom/figli_compta_ledger/figli_compta_ledger.libraries.yml b/web/modules/custom/figli_compta_ledger/figli_compta_ledger.libraries.yml index e36af0a..f0865be 100644 --- a/web/modules/custom/figli_compta_ledger/figli_compta_ledger.libraries.yml +++ b/web/modules/custom/figli_compta_ledger/figli_compta_ledger.libraries.yml @@ -33,3 +33,8 @@ admin_chrome: js/admin-chrome.js: {} dependencies: - core/drupal + +hide_admin_sidebar: + css: + theme: + css/hide-admin-sidebar.css: {} diff --git a/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module b/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module index a423cd6..cf196c8 100644 --- a/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module +++ b/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module @@ -222,9 +222,24 @@ function figli_compta_ledger_theme($existing, $type, $theme, $path) { * Core Navigation's top bar renders empty (whitespace-only regions defeat * its own :not(:empty) visibility check) on every page, not just admin * routes -- attach the fix globally rather than per-route. + * + * The admin sidebar itself (#admin-toolbar) is only hidden on this + * module's own front-end pages -- real Drupal admin pages (/admin/*, node + * edit forms, etc.) should keep it, so that one is route-scoped rather + * than folded into the always-on admin_chrome attachment above. */ function figli_compta_ledger_page_attachments(array &$attachments) { $attachments['#attached']['library'][] = 'figli_compta_ledger/admin_chrome'; + + $front_end_routes = [ + 'figli_compta_ledger.home', + 'figli_compta_ledger.dashboard', + 'figli_compta_ledger.history', + 'figli_compta_ledger.link_entree', + ]; + if (in_array(\Drupal::routeMatch()->getRouteName(), $front_end_routes, TRUE)) { + $attachments['#attached']['library'][] = 'figli_compta_ledger/hide_admin_sidebar'; + } } /** diff --git a/web/modules/custom/figli_compta_ledger/js/home.js b/web/modules/custom/figli_compta_ledger/js/home.js index d3477d1..6373a86 100644 --- a/web/modules/custom/figli_compta_ledger/js/home.js +++ b/web/modules/custom/figli_compta_ledger/js/home.js @@ -124,10 +124,20 @@ } async function fetchClientNames() { - const res = await fetch('/jsonapi/taxonomy_term/client?sort=name&page[limit]=200', { headers: { Accept: 'application/vnd.api+json' } }); - if (!res.ok) throw new Error('JSON:API a répondu ' + res.status); - const json = await res.json(); - return (json.data || []).map((t) => t.attributes.name).filter(Boolean).sort(); + // page[limit]=200 is silently clamped to core's hard cap of 50 by + // JSON:API (Query\OffsetPage::SIZE_MAX) -- with 106 client terms, + // that cut off everything past the 50th alphabetically (e.g. "LE + // CAMPUS") unless every page is followed, same as fetchLignes() above. + let url = '/jsonapi/taxonomy_term/client?sort=name&page[limit]=50'; + const names = []; + while (url) { + const res = await fetch(url, { headers: { Accept: 'application/vnd.api+json' } }); + if (!res.ok) throw new Error('JSON:API a répondu ' + res.status); + const json = await res.json(); + names.push(...(json.data || []).map((t) => t.attributes.name).filter(Boolean)); + url = json.links && json.links.next ? json.links.next.href : null; + } + return names.sort(); } async function fetchYearsList() {