Fix client autocomplete pagination + hide admin sidebar on front-end pages
fetchClientNames() requested page[limit]=200 but never followed links.next, and JSON:API silently clamps to a 50-item hard cap -- with 106 client terms, everything past the 50th alphabetically (e.g. "LE CAMPUS") was dropped. Now loops through every page like fetchLignes() already does. The core Navigation module's admin sidebar (#admin-toolbar) was showing on our custom /lignes, /dashboard, /lignes/historique and lier-entree pages. Added a route-scoped library (attached only for those route names in hook_page_attachments(), not folded into the always-on admin_chrome attachment) so real Drupal admin pages keep the sidebar.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -33,3 +33,8 @@ admin_chrome:
|
||||
js/admin-chrome.js: {}
|
||||
dependencies:
|
||||
- core/drupal
|
||||
|
||||
hide_admin_sidebar:
|
||||
css:
|
||||
theme:
|
||||
css/hide-admin-sidebar.css: {}
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user