Améliore la navigation et la mise en page des exports PDF
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
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
- 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
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { CampaignContentHit, campaignContentRoute, campaignContentContext } from './campaign-content-search.model';
|
||||
|
||||
const hit: CampaignContentHit = { kind: 'scene', id: '4', name: 'Le témoin', campaignId: '1',
|
||||
campaignName: 'Les Ombres', arcId: '2', arcName: 'Le port', chapterId: '3', chapterName: 'La nuit' };
|
||||
|
||||
describe('campaign search destinations', () => {
|
||||
it('resolves each entity even when IDs overlap between types', () => {
|
||||
expect(campaignContentRoute(hit)).toEqual(['/campaigns', '1', 'arcs', '2', 'chapters', '3', 'scenes', '4']);
|
||||
expect(campaignContentRoute({ ...hit, kind: 'chapter' })).toEqual(['/campaigns', '1', 'arcs', '2', 'chapters', '4']);
|
||||
expect(campaignContentRoute({ ...hit, kind: 'arc' })).toEqual(['/campaigns', '1', 'arcs', '4']);
|
||||
expect(campaignContentRoute({ ...hit, kind: 'quest', arcId: null })).toEqual(['/campaigns', '1', 'quests', '4']);
|
||||
});
|
||||
it('keeps a system arc in the destination but out of the visible context', () => {
|
||||
expect(campaignContentContext({ ...hit, arcName: null })).toBe('Les Ombres › La nuit');
|
||||
expect(campaignContentContext(hit)).toBe('Les Ombres › Le port › La nuit');
|
||||
expect(campaignContentRoute({ ...hit, chapterId: null })).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
export interface CampaignContentHit {
|
||||
kind: 'arc' | 'chapter' | 'scene' | 'quest';
|
||||
id: string;
|
||||
name: string;
|
||||
campaignId: string;
|
||||
campaignName: string;
|
||||
arcId: string | null;
|
||||
arcName: string | null;
|
||||
chapterId: string | null;
|
||||
chapterName: string | null;
|
||||
}
|
||||
|
||||
export function campaignContentRoute(hit: CampaignContentHit): string[] {
|
||||
const root = ['/campaigns', hit.campaignId];
|
||||
if (hit.kind === 'quest') return [...root, 'quests', hit.id];
|
||||
if (hit.kind === 'arc') return [...root, 'arcs', hit.id];
|
||||
if (!hit.arcId) return [];
|
||||
const arc = [...root, 'arcs', hit.arcId];
|
||||
if (hit.kind === 'chapter') return [...arc, 'chapters', hit.id];
|
||||
return hit.chapterId ? [...arc, 'chapters', hit.chapterId, 'scenes', hit.id] : [];
|
||||
}
|
||||
|
||||
export function campaignContentContext(hit: CampaignContentHit): string {
|
||||
return [hit.campaignName, hit.kind !== 'arc' ? hit.arcName : null,
|
||||
hit.kind === 'scene' ? hit.chapterName : null].filter(Boolean).join(' › ');
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { Npc } from './npc.model';
|
||||
import { RandomTable } from './random-table.model';
|
||||
import { Enemy } from './enemy.model';
|
||||
import { PdfExportOptions } from './pdf-export.model';
|
||||
import { CampaignContentHit } from './campaign-content-search.model';
|
||||
|
||||
/**
|
||||
* Arbre de campagne AGRÉGÉ (une seule requête HTTP) — miroir de CampaignTreeDTO.
|
||||
@@ -262,4 +263,8 @@ export class CampaignService {
|
||||
const params = new HttpParams().set('q', q);
|
||||
return this.http.get<Campaign[]>(`${this.apiUrl}/search`, { params });
|
||||
}
|
||||
|
||||
searchContent(q: string): Observable<CampaignContentHit[]> {
|
||||
return this.http.get<CampaignContentHit[]>(`${this.apiUrl}/search-content`, { params: { q } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { Router } from '@angular/router';
|
||||
import { LayoutService, SecondarySidebarConfig } from './layout.service';
|
||||
import { campaignBreadcrumbs, isWithinRoute } from '../shared/navigation-path';
|
||||
import { NavigationEntry, NavigationHistory, contentUrl, readHistory, rememberVisit, toggleFavorite } from '../shared/navigation-history';
|
||||
|
||||
/** Shortcuts belong to this browser and origin; unavailable storage is non-fatal. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class NavigationHistoryService {
|
||||
private readonly key = 'loremind.navigation.v1';
|
||||
private readonly state = signal<NavigationHistory>(this.load());
|
||||
readonly history = this.state.asReadonly();
|
||||
private context: SecondarySidebarConfig | null = null;
|
||||
|
||||
constructor(layout: LayoutService, router: Router) {
|
||||
layout.secondarySidebar$.pipe(takeUntilDestroyed()).subscribe(context => {
|
||||
this.context = context;
|
||||
const current = this.state().recent.find(item => item.url === contentUrl(router.url));
|
||||
if (current) this.visit(current.url, current.title);
|
||||
});
|
||||
}
|
||||
|
||||
private subtitleFor(url: string): string {
|
||||
const path = campaignBreadcrumbs(url, this.context, '');
|
||||
if (path.length > 1) return path.slice(0, -1).map(item => item.label).join(' › ');
|
||||
const parent = this.context?.globalItems.find(item => item.route !== url && isWithinRoute(url, item.route));
|
||||
return parent?.name ?? '';
|
||||
}
|
||||
|
||||
private load(): NavigationHistory {
|
||||
try { return readHistory(localStorage.getItem(this.key)); }
|
||||
catch { return { recent: [], favorites: [] }; }
|
||||
}
|
||||
|
||||
private save(history: NavigationHistory): void {
|
||||
this.state.set(history);
|
||||
try { localStorage.setItem(this.key, JSON.stringify(history)); } catch { /* Keep shortcuts in memory. */ }
|
||||
}
|
||||
|
||||
visit(url: string, title: string, subtitle = ''): void {
|
||||
const path = contentUrl(url);
|
||||
if (path && title.trim()) {
|
||||
const existing = this.state().recent.find(item => item.url === path);
|
||||
this.save(rememberVisit(this.state(), { url: path, title, subtitle: subtitle || this.subtitleFor(path) || existing?.subtitle || '' }));
|
||||
}
|
||||
}
|
||||
|
||||
isFavorite(url: string): boolean { return this.state().favorites.some(item => item.url === url); }
|
||||
|
||||
toggle(entry: NavigationEntry): void {
|
||||
if (contentUrl(entry.url) === entry.url) this.save(toggleFavorite(this.state(), entry));
|
||||
}
|
||||
|
||||
clearRecent(): void { this.save({ ...this.state(), recent: [] }); }
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { Router } from '@angular/router';
|
||||
import { NavigationHistoryService } from './navigation-history.service';
|
||||
|
||||
/**
|
||||
* Service centralisé pour le titre de l'onglet navigateur.
|
||||
@@ -11,7 +13,7 @@ import { Title } from '@angular/platform-browser';
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PageTitleService {
|
||||
constructor(private title: Title) {}
|
||||
constructor(private title: Title, private router: Router, private history: NavigationHistoryService) {}
|
||||
|
||||
/**
|
||||
* Définit le titre de l'onglet au format "LoreMind - <subject>".
|
||||
@@ -21,5 +23,6 @@ export class PageTitleService {
|
||||
set(subject: string | null | undefined): void {
|
||||
const s = subject?.trim();
|
||||
this.title.setTitle(s ? `LoreMind - ${s}` : 'LoreMind');
|
||||
if (s) this.history.visit(this.router.url, s);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user