Files
LoreMind/web/src/app/shared/navigation-path.ts
T
ietm64 0ef1380265
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 37s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Failing after 1m37s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 1m1s
Améliore la navigation et la mise en page des exports PDF
- Ajoute les fils d’Ariane, les favoris et l’historique de navigation
- Étend la recherche aux arcs, chapitres, scènes et quêtes
- Regroupe les actions de campagne dans le menu Gérer
- Améliore la navigation au clavier et sur mobile
- Refonte de l’export A4 : deux colonnes, couverture illustrée et encadrés
- Ajoute des motifs décoratifs en pied de page et une variante pour l’impression
- Vérifie la pagination, les renvois et la confidentialité de l’édition joueurs
2026-10-17 19:05:15 +02:00

47 lines
1.9 KiB
TypeScript

import type { SecondarySidebarConfig, TreeItem } from '../services/layout.service';
import type { BreadcrumbItem } from './breadcrumb/breadcrumb.component';
/** Segment boundaries prevent campaign 1 from matching campaign 10. */
export function isWithinRoute(url: string, route: string): boolean {
const path = url.split(/[?#]/)[0];
return path === route || path.startsWith(route + '/');
}
/** Follow the visible tree, including flattened campaigns and quest containers. */
export function campaignBreadcrumbs(
url: string, config: SecondarySidebarConfig | null, editLabel: string
): BreadcrumbItem[] {
const root = config?.titleRoute;
if (!config || !root?.startsWith('/campaigns/') || !isWithinRoute(url, root)) return [];
const path = url.split(/[?#]/)[0];
if (path === root) return [];
let best: BreadcrumbItem[] = [];
let matchedRoute = '';
const visit = (items: TreeItem[], parents: BreadcrumbItem[]) => {
for (const item of items) {
const trail = item.route === root ? parents : [...parents, { label: item.label, route: item.route }];
if (item.route && item.route !== root && isWithinRoute(path, item.route) && item.route.length > matchedRoute.length) {
best = trail;
matchedRoute = item.route;
}
for (const action of item.createActions ?? []) {
if (path === action.route) {
best = [...trail, { label: action.label }];
matchedRoute = action.route;
}
}
visit(item.children ?? [], trail);
}
};
visit(config.items, []);
for (const action of config.createActions) {
if (action.route === path) {
best = [{ label: action.label }];
matchedRoute = path;
}
}
if (!matchedRoute || (path !== matchedRoute && path !== matchedRoute + '/edit')) return [];
if (path.endsWith('/edit')) best.push({ label: editLabel });
return [{ label: config.title, route: root }, ...best];
}