Mise en ligne de la version 0.2.0
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<aside class="drawer" [class.drawer-open]="isOpen" aria-label="Assistant IA">
|
||||
|
||||
<header class="drawer-header">
|
||||
<h2>Assistant IA</h2>
|
||||
<button type="button" class="close-btn" (click)="onClose()" aria-label="Fermer">
|
||||
<lucide-icon [img]="X" [size]="18"></lucide-icon>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div #messagesContainer class="messages">
|
||||
<!-- Message d'accueil (non-stocké dans `messages`, toujours visible tant que la conversation est vide). -->
|
||||
<div class="msg msg-assistant" *ngIf="messages.length === 0 && !currentAssistantText">
|
||||
{{ welcomeMessage }}
|
||||
</div>
|
||||
|
||||
<!-- Historique -->
|
||||
<ng-container *ngFor="let m of messages">
|
||||
<div class="msg" [class.msg-user]="m.role === 'user'" [class.msg-assistant]="m.role === 'assistant'">
|
||||
{{ m.content }}
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<!-- Bulle en cours de streaming -->
|
||||
<div class="msg msg-assistant msg-streaming" *ngIf="currentAssistantText">
|
||||
{{ currentAssistantText }}<span class="caret"></span>
|
||||
</div>
|
||||
|
||||
<!-- Indicateur pendant la phase "en train de réfléchir" (avant le premier token) -->
|
||||
<div class="typing-indicator" *ngIf="isStreaming && !currentAssistantText" aria-live="polite">
|
||||
<span></span><span></span><span></span>
|
||||
</div>
|
||||
|
||||
<!-- Erreur locale au drawer -->
|
||||
<div class="msg msg-error" *ngIf="errorMessage" role="alert">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Action primaire (optionnelle) : ne passe PAS par le chat -->
|
||||
<div class="primary-action" *ngIf="primaryAction">
|
||||
<button
|
||||
type="button"
|
||||
class="primary-btn"
|
||||
(click)="onPrimaryAction()"
|
||||
[disabled]="isStreaming">
|
||||
<lucide-icon [img]="Wand2" [size]="14"></lucide-icon>
|
||||
{{ primaryAction.label }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Suggestions rapides -->
|
||||
<div class="quick-suggestions" *ngIf="quickSuggestions.length">
|
||||
<p class="quick-label">Suggestions rapides :</p>
|
||||
<div class="quick-list">
|
||||
<button
|
||||
type="button"
|
||||
class="quick-btn"
|
||||
*ngFor="let s of quickSuggestions"
|
||||
(click)="useQuickSuggestion(s)"
|
||||
[disabled]="isStreaming">
|
||||
<lucide-icon [img]="Lightbulb" [size]="12"></lucide-icon>
|
||||
{{ s }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Zone de saisie -->
|
||||
<form class="input-row" (ngSubmit)="send()">
|
||||
<input
|
||||
type="text"
|
||||
[(ngModel)]="input"
|
||||
name="chatInput"
|
||||
placeholder="Posez une question..."
|
||||
[disabled]="isStreaming"
|
||||
autocomplete="off" />
|
||||
<button type="submit" class="send-btn" [disabled]="!input.trim() || isStreaming" aria-label="Envoyer">
|
||||
<lucide-icon [img]="Send" [size]="16"></lucide-icon>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</aside>
|
||||
261
web/src/app/shared/ai-chat-drawer/ai-chat-drawer.component.scss
Normal file
261
web/src/app/shared/ai-chat-drawer/ai-chat-drawer.component.scss
Normal file
@@ -0,0 +1,261 @@
|
||||
:host {
|
||||
// Le drawer lui-même gère son positionnement fixed. Rien à prévoir côté host.
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.drawer {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 380px;
|
||||
height: 100vh;
|
||||
background: #0f0f1a;
|
||||
border-left: 1px solid #1e1e3a;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transform: translateX(100%);
|
||||
transition: transform 0.25s ease;
|
||||
z-index: 1000;
|
||||
box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.drawer-open {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
// --- Header --------------------------------------------------------------
|
||||
|
||||
.drawer-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1rem 1.25rem;
|
||||
border-bottom: 1px solid #1e1e3a;
|
||||
flex-shrink: 0;
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
padding: 0.25rem;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
|
||||
&:hover {
|
||||
color: white;
|
||||
background: #1e1e3a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Zone messages -------------------------------------------------------
|
||||
|
||||
.messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1rem 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.msg {
|
||||
max-width: 85%;
|
||||
padding: 0.6rem 0.85rem;
|
||||
border-radius: 10px;
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.msg-assistant {
|
||||
align-self: flex-start;
|
||||
background: #1a1a2e;
|
||||
color: #e5e7eb;
|
||||
border: 1px solid #2a2a3d;
|
||||
}
|
||||
|
||||
.msg-user {
|
||||
align-self: flex-end;
|
||||
background: #6c63ff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.msg-streaming {
|
||||
// Le caret clignotant à la fin donne la sensation de "l'IA est en train d'écrire"
|
||||
.caret {
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
height: 1em;
|
||||
background: #a5b4fc;
|
||||
margin-left: 2px;
|
||||
vertical-align: text-bottom;
|
||||
animation: blink 1s step-end infinite;
|
||||
}
|
||||
}
|
||||
|
||||
.msg-error {
|
||||
align-self: stretch;
|
||||
background: #3f1f1f;
|
||||
color: #fca5a5;
|
||||
border: 1px solid #7f1d1d;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0; }
|
||||
}
|
||||
|
||||
// --- Indicateur "typing" -------------------------------------------------
|
||||
|
||||
.typing-indicator {
|
||||
display: flex;
|
||||
gap: 0.3rem;
|
||||
padding: 0.6rem 0.85rem;
|
||||
align-self: flex-start;
|
||||
|
||||
span {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: #6c63ff;
|
||||
border-radius: 50%;
|
||||
animation: bounce 1.2s infinite ease-in-out both;
|
||||
}
|
||||
span:nth-child(2) { animation-delay: 0.15s; }
|
||||
span:nth-child(3) { animation-delay: 0.3s; }
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
|
||||
40% { transform: scale(1); opacity: 1; }
|
||||
}
|
||||
|
||||
// --- Action primaire -----------------------------------------------------
|
||||
|
||||
.primary-action {
|
||||
padding: 0.75rem 1.25rem 0;
|
||||
flex-shrink: 0;
|
||||
|
||||
.primary-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.45rem;
|
||||
width: 100%;
|
||||
padding: 0.65rem 0.9rem;
|
||||
background: #6c63ff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 0.88rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, opacity 0.15s;
|
||||
|
||||
&:hover:not(:disabled) { background: #5a52e0; }
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Suggestions rapides -------------------------------------------------
|
||||
|
||||
.quick-suggestions {
|
||||
padding: 0.75rem 1.25rem 0;
|
||||
border-top: 1px solid #1e1e3a;
|
||||
flex-shrink: 0;
|
||||
|
||||
.quick-label {
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
.quick-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.quick-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
padding: 0.35rem 0.6rem;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
border-radius: 4px;
|
||||
color: #d1d5db;
|
||||
font-size: 0.78rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #2a2a3d;
|
||||
color: white;
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Zone de saisie ------------------------------------------------------
|
||||
|
||||
.input-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1.25rem 1rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
color: white;
|
||||
padding: 0.55rem 0.75rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.88rem;
|
||||
font-family: inherit;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: #6c63ff;
|
||||
}
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
background: #6c63ff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
width: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, opacity 0.15s;
|
||||
|
||||
&:hover:not(:disabled) { background: #5a52e0; }
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
199
web/src/app/shared/ai-chat-drawer/ai-chat-drawer.component.ts
Normal file
199
web/src/app/shared/ai-chat-drawer/ai-chat-drawer.component.ts
Normal file
@@ -0,0 +1,199 @@
|
||||
import { Component, ElementRef, EventEmitter, Input, Output, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { LucideAngularModule, X, Send, Sparkles, Lightbulb, Wand2 } from 'lucide-angular';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { AiChatService, ChatMessage, NarrativeEntityType } from '../../services/ai-chat.service';
|
||||
|
||||
/**
|
||||
* Action primaire optionnelle rendue en gros bouton au-dessus des suggestions.
|
||||
* Utilisée pour les actions "spéciales" qui NE passent PAS par le chat
|
||||
* (ex: "Remplir automatiquement tous les champs" → déclenche le one-shot b4).
|
||||
*/
|
||||
export interface ChatPrimaryAction {
|
||||
label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drawer de chat IA réutilisable — panneau fixe à droite de l'écran.
|
||||
*
|
||||
* Usage minimal :
|
||||
* <app-ai-chat-drawer
|
||||
* [loreId]="loreId"
|
||||
* [isOpen]="chatOpen"
|
||||
* [quickSuggestions]="['Développe l'histoire', ...]"
|
||||
* (close)="chatOpen = false">
|
||||
* </app-ai-chat-drawer>
|
||||
*
|
||||
* Contrainte de design : conversation éphémère (on perd tout à la fermeture
|
||||
* ou à la destruction du composant — choix MVP assumé).
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-ai-chat-drawer',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, LucideAngularModule],
|
||||
templateUrl: './ai-chat-drawer.component.html',
|
||||
styleUrls: ['./ai-chat-drawer.component.scss']
|
||||
})
|
||||
export class AiChatDrawerComponent implements OnDestroy {
|
||||
readonly X = X;
|
||||
readonly Send = Send;
|
||||
readonly Sparkles = Sparkles;
|
||||
readonly Lightbulb = Lightbulb;
|
||||
readonly Wand2 = Wand2;
|
||||
|
||||
/**
|
||||
* Mode Lore : fournir `loreId` (et optionnellement `pageId`).
|
||||
* Mode Campagne : fournir `campaignId` (et optionnellement `entityType`+`entityId`).
|
||||
* Les deux modes sont exclusifs — si `campaignId` est non-vide, on route
|
||||
* vers l'endpoint Campagne, sinon vers l'endpoint Lore.
|
||||
*/
|
||||
@Input() loreId = '';
|
||||
/**
|
||||
* Optionnel : ID d'une page précise en cours d'édition. Si fourni, le
|
||||
* backend focalise l'IA sur cette page (template, champs, valeurs) via
|
||||
* un bloc "PAGE EN COURS" dans le system prompt. Sans cet ID, le chat
|
||||
* reste générique au Lore.
|
||||
*/
|
||||
@Input() pageId: string | null = null;
|
||||
|
||||
/** ID de la Campagne — active le mode chat Campagne si non-vide. */
|
||||
@Input() campaignId: string | null = null;
|
||||
/** Optionnel : "arc"|"chapter"|"scene" — focalise l'IA sur une entité narrative. */
|
||||
@Input() entityType: NarrativeEntityType | null = null;
|
||||
/** Optionnel : ID de l'entité narrative en cours d'édition. */
|
||||
@Input() entityId: string | null = null;
|
||||
@Input() isOpen = false;
|
||||
/** Texte accueil affiché au premier ouverture (avant tout échange). */
|
||||
@Input() welcomeMessage = 'Bonjour ! Je peux vous aider à développer cette page. Que souhaitez-vous créer ?';
|
||||
/** Suggestions rapides cliquables en bas (hardcodées par le parent, MVP). */
|
||||
@Input() quickSuggestions: string[] = [];
|
||||
/** Action primaire optionnelle (ex: "Remplir automatiquement") — ne passe PAS par le chat. */
|
||||
@Input() primaryAction: ChatPrimaryAction | null = null;
|
||||
/**
|
||||
* Instructions système supplémentaires injectées en tête de la conversation
|
||||
* envoyée au backend, INVISIBLES côté UI. Usage : mode wizard, où on veut
|
||||
* contextualiser l'IA (template cible, format JSON attendu) sans polluer
|
||||
* l'historique visuel.
|
||||
*/
|
||||
@Input() systemPromptAddon: string | null = null;
|
||||
|
||||
@Output() close = new EventEmitter<void>();
|
||||
/** Émis au clic sur l'action primaire — le parent gère entièrement (one-shot, etc.). */
|
||||
@Output() primaryActionClick = new EventEmitter<void>();
|
||||
/** Émis à chaque fin de réponse assistant — utile pour parser côté parent (ex: bloc <values> du wizard). */
|
||||
@Output() assistantReply = new EventEmitter<string>();
|
||||
|
||||
@ViewChild('messagesContainer') messagesContainer?: ElementRef<HTMLDivElement>;
|
||||
|
||||
/** Conversation en cours (user + assistant). Le welcome n'est pas dedans — rendu séparément. */
|
||||
messages: ChatMessage[] = [];
|
||||
/** Texte en cours de streaming (écrit token par token, pas encore poussé dans `messages`). */
|
||||
currentAssistantText = '';
|
||||
/** Champ de saisie. */
|
||||
input = '';
|
||||
/** Stream en cours ? Désactive le bouton envoyer + les suggestions rapides. */
|
||||
isStreaming = false;
|
||||
/** Dernier message d'erreur (affiché dans une bannière locale au drawer). */
|
||||
errorMessage: string | null = null;
|
||||
|
||||
private streamSub: Subscription | null = null;
|
||||
|
||||
constructor(private readonly chatService: AiChatService) {}
|
||||
|
||||
// --- Handlers UI --------------------------------------------------------
|
||||
|
||||
onClose(): void {
|
||||
this.abortStream();
|
||||
this.close.emit();
|
||||
}
|
||||
|
||||
/** Envoi explicite depuis le formulaire (Entrée ou bouton envoyer). */
|
||||
send(): void {
|
||||
const text = this.input.trim();
|
||||
if (!text || this.isStreaming) return;
|
||||
this.sendUserMessage(text);
|
||||
this.input = '';
|
||||
}
|
||||
|
||||
/** Envoi depuis une suggestion rapide (bouton cliquable en bas). */
|
||||
useQuickSuggestion(suggestion: string): void {
|
||||
if (this.isStreaming) return;
|
||||
this.sendUserMessage(suggestion);
|
||||
}
|
||||
|
||||
/** Clic sur l'action primaire — on délègue entièrement au parent. */
|
||||
onPrimaryAction(): void {
|
||||
if (this.isStreaming) return;
|
||||
this.primaryActionClick.emit();
|
||||
}
|
||||
|
||||
// --- Logique envoi + streaming -----------------------------------------
|
||||
|
||||
private sendUserMessage(text: string): void {
|
||||
this.errorMessage = null;
|
||||
this.messages.push({ role: 'user', content: text });
|
||||
this.currentAssistantText = '';
|
||||
this.isStreaming = true;
|
||||
this.scrollToBottom();
|
||||
|
||||
// Construit la liste effectivement envoyée au backend : systemPromptAddon
|
||||
// (si fourni) préfixé, puis l'historique visible. Le system n'est PAS stocké
|
||||
// dans this.messages → reste invisible côté UI.
|
||||
const payload = this.systemPromptAddon
|
||||
? [{ role: 'system' as const, content: this.systemPromptAddon }, ...this.messages]
|
||||
: this.messages;
|
||||
|
||||
const stream$ = this.campaignId
|
||||
? this.chatService.streamChatForCampaign(this.campaignId, payload, this.entityType, this.entityId)
|
||||
: this.chatService.streamChat(this.loreId, payload, this.pageId);
|
||||
|
||||
this.streamSub = stream$.subscribe({
|
||||
next: (event) => {
|
||||
if (event.type === 'token') {
|
||||
this.currentAssistantText += event.value;
|
||||
this.scrollToBottom();
|
||||
}
|
||||
// 'done' : l'Observable va compléter → géré par complete()
|
||||
},
|
||||
error: (err) => {
|
||||
this.isStreaming = false;
|
||||
this.errorMessage = err?.message ?? 'Erreur inconnue.';
|
||||
this.currentAssistantText = '';
|
||||
},
|
||||
complete: () => {
|
||||
// On fige le texte streamé en message assistant réel, puis on reset le buffer.
|
||||
const reply = this.currentAssistantText;
|
||||
if (reply) {
|
||||
this.messages.push({ role: 'assistant', content: reply });
|
||||
this.assistantReply.emit(reply);
|
||||
}
|
||||
this.currentAssistantText = '';
|
||||
this.isStreaming = false;
|
||||
this.scrollToBottom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private abortStream(): void {
|
||||
this.streamSub?.unsubscribe();
|
||||
this.streamSub = null;
|
||||
this.isStreaming = false;
|
||||
this.currentAssistantText = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll différé au prochain tick : donne à Angular le temps de rendre
|
||||
* le nouveau contenu avant qu'on mesure/ajuste la position du scroll.
|
||||
*/
|
||||
private scrollToBottom(): void {
|
||||
queueMicrotask(() => {
|
||||
const el = this.messagesContainer?.nativeElement;
|
||||
if (el) el.scrollTop = el.scrollHeight;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.abortStream();
|
||||
}
|
||||
}
|
||||
12
web/src/app/shared/breadcrumb/breadcrumb.component.html
Normal file
12
web/src/app/shared/breadcrumb/breadcrumb.component.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<nav class="breadcrumb" aria-label="Fil d'Ariane" *ngIf="items.length">
|
||||
<ol>
|
||||
<li *ngFor="let item of items; let last = last; trackBy: trackByIndex"
|
||||
class="breadcrumb-item"
|
||||
[class.current]="last">
|
||||
<a *ngIf="item.route && !last"
|
||||
[routerLink]="item.route"
|
||||
class="breadcrumb-link">{{ item.label }}</a>
|
||||
<span *ngIf="!item.route || last" class="breadcrumb-text">{{ item.label }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
50
web/src/app/shared/breadcrumb/breadcrumb.component.scss
Normal file
50
web/src/app/shared/breadcrumb/breadcrumb.component.scss
Normal file
@@ -0,0 +1,50 @@
|
||||
.breadcrumb {
|
||||
font-size: 0.82rem;
|
||||
color: #6b7280;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
ol {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
|
||||
&::before {
|
||||
content: '›';
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
&:first-child::before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
&.current .breadcrumb-text {
|
||||
color: #e5e7eb;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb-link {
|
||||
color: #9ca3af;
|
||||
text-decoration: none;
|
||||
transition: color 0.15s;
|
||||
|
||||
&:hover {
|
||||
color: #a5b4fc;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb-text {
|
||||
color: inherit;
|
||||
}
|
||||
35
web/src/app/shared/breadcrumb/breadcrumb.component.ts
Normal file
35
web/src/app/shared/breadcrumb/breadcrumb.component.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Un niveau dans le fil d'Ariane.
|
||||
* Si `route` est défini, l'item est cliquable (navigation).
|
||||
* Sinon, c'est la position courante (dernier niveau, non-cliquable).
|
||||
*/
|
||||
export interface BreadcrumbItem {
|
||||
label: string;
|
||||
route?: string | any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Composant réutilisable de fil d'Ariane.
|
||||
* Utilisation type :
|
||||
* <app-breadcrumb [items]="[
|
||||
* { label: 'Mon Univers', route: ['/lore', loreId] },
|
||||
* { label: 'PNJ', route: ['/lore', loreId, 'folders', nodeId, 'edit'] },
|
||||
* { label: 'Aldric' }
|
||||
* ]"></app-breadcrumb>
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-breadcrumb',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink],
|
||||
templateUrl: './breadcrumb.component.html',
|
||||
styleUrls: ['./breadcrumb.component.scss']
|
||||
})
|
||||
export class BreadcrumbComponent {
|
||||
@Input() items: BreadcrumbItem[] = [];
|
||||
|
||||
trackByIndex = (i: number) => i;
|
||||
}
|
||||
15
web/src/app/shared/chips-input/chips-input.component.html
Normal file
15
web/src/app/shared/chips-input/chips-input.component.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="chips-wrapper">
|
||||
<span class="chip" *ngFor="let tag of value; let i = index">
|
||||
{{ tag }}
|
||||
<button type="button" class="chip-remove" (click)="remove(i)" title="Retirer">
|
||||
<lucide-icon [img]="X" [size]="12"></lucide-icon>
|
||||
</button>
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
class="chip-input"
|
||||
[placeholder]="placeholder"
|
||||
[(ngModel)]="current"
|
||||
(keydown)="onKeyDown($event)"
|
||||
(blur)="add()" />
|
||||
</div>
|
||||
53
web/src/app/shared/chips-input/chips-input.component.scss
Normal file
53
web/src/app/shared/chips-input/chips-input.component.scss
Normal file
@@ -0,0 +1,53 @@
|
||||
.chips-wrapper {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.55rem 0.65rem;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
border-radius: 6px;
|
||||
|
||||
&:focus-within {
|
||||
border-color: #6c63ff;
|
||||
}
|
||||
}
|
||||
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
padding: 0.2rem 0.55rem;
|
||||
background: #1e1c3a;
|
||||
color: #a5b4fc;
|
||||
border-radius: 999px;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.2;
|
||||
|
||||
.chip-remove {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
opacity: 0.7;
|
||||
|
||||
&:hover { opacity: 1; color: #fca5a5; }
|
||||
}
|
||||
}
|
||||
|
||||
.chip-input {
|
||||
flex: 1;
|
||||
min-width: 140px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: white;
|
||||
font-size: 0.88rem;
|
||||
padding: 0.15rem 0;
|
||||
outline: none;
|
||||
|
||||
&::placeholder { color: #6b7280; }
|
||||
}
|
||||
68
web/src/app/shared/chips-input/chips-input.component.ts
Normal file
68
web/src/app/shared/chips-input/chips-input.component.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { LucideAngularModule, X } from 'lucide-angular';
|
||||
|
||||
/**
|
||||
* Composant réutilisable de saisie de chips (étiquettes textuelles).
|
||||
*
|
||||
* Usage :
|
||||
* <app-chips-input
|
||||
* [value]="tags"
|
||||
* (valueChange)="tags = $event"
|
||||
* placeholder="Ajouter un tag..."></app-chips-input>
|
||||
*
|
||||
* Règles UX :
|
||||
* - Entrée valide la saisie en cours
|
||||
* - Virgule valide aussi (pratique pour enchaîner plusieurs tags)
|
||||
* - Doublons silencieusement ignorés
|
||||
* - Espaces en début/fin trimmés
|
||||
* - Clic sur X retire le chip
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-chips-input',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, LucideAngularModule],
|
||||
templateUrl: './chips-input.component.html',
|
||||
styleUrls: ['./chips-input.component.scss']
|
||||
})
|
||||
export class ChipsInputComponent {
|
||||
readonly X = X;
|
||||
|
||||
@Input() value: string[] = [];
|
||||
@Input() placeholder = 'Ajouter...';
|
||||
@Output() valueChange = new EventEmitter<string[]>();
|
||||
|
||||
/** Texte de l'input en cours de saisie. */
|
||||
current = '';
|
||||
|
||||
/** Ajoute le texte courant s'il est non vide et non déjà présent. */
|
||||
add(): void {
|
||||
const raw = this.current.trim().replace(/,$/, '').trim();
|
||||
if (!raw) return;
|
||||
if (this.value.includes(raw)) {
|
||||
this.current = '';
|
||||
return;
|
||||
}
|
||||
this.valueChange.emit([...this.value, raw]);
|
||||
this.current = '';
|
||||
}
|
||||
|
||||
/** Retire le chip à l'index donné. */
|
||||
remove(index: number): void {
|
||||
const next = [...this.value];
|
||||
next.splice(index, 1);
|
||||
this.valueChange.emit(next);
|
||||
}
|
||||
|
||||
/** Gère Enter et virgule comme déclencheurs d'ajout. */
|
||||
onKeyDown(event: KeyboardEvent): void {
|
||||
if (event.key === 'Enter' || event.key === ',') {
|
||||
event.preventDefault();
|
||||
this.add();
|
||||
} else if (event.key === 'Backspace' && this.current === '' && this.value.length > 0) {
|
||||
// Backspace sur input vide retire le dernier chip (UX courante).
|
||||
this.remove(this.value.length - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<div class="expandable-section" [class.private]="variant === 'private'">
|
||||
|
||||
<button type="button" class="section-header" (click)="toggle()">
|
||||
<span class="section-title">
|
||||
<span class="section-icon" *ngIf="icon">{{ icon }}</span>
|
||||
{{ title }}
|
||||
</span>
|
||||
<lucide-icon [img]="isOpen ? ChevronUp : ChevronDown" [size]="16"></lucide-icon>
|
||||
</button>
|
||||
|
||||
<div class="section-content" *ngIf="isOpen">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
.expandable-section {
|
||||
background: #1f2937;
|
||||
border: 1px solid #374151;
|
||||
border-radius: 8px;
|
||||
// Pas de overflow: hidden : les dropdowns en position absolute (ex. LoreLinkPicker)
|
||||
// doivent pouvoir deborder du conteneur. Le padding interne evite tout debordement
|
||||
// visuel des coins arrondis en rendu normal.
|
||||
|
||||
&.private {
|
||||
border-color: #7f1d1d;
|
||||
|
||||
.section-header { background: rgba(127, 29, 29, 0.12); }
|
||||
.section-title { color: #fca5a5; }
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.9rem 1.1rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: #d1d5db;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover { background: #374151; }
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
color: #e5e7eb;
|
||||
}
|
||||
|
||||
.section-icon {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.section-content {
|
||||
padding: 1rem 1.1rem 1.2rem 1.1rem;
|
||||
border-top: 1px solid #374151;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { LucideAngularModule, ChevronDown, ChevronUp } from 'lucide-angular';
|
||||
|
||||
/**
|
||||
* Section repliable avec titre (icône + texte) et contenu projeté via ng-content.
|
||||
* Utilisé dans les écrans d'édition de Scene pour structurer les champs narratifs.
|
||||
*
|
||||
* Usage :
|
||||
* <app-expandable-section title="Contexte et ambiance" icon="📍" [initiallyOpen]="true">
|
||||
* <!-- champs de formulaire -->
|
||||
* </app-expandable-section>
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-expandable-section',
|
||||
standalone: true,
|
||||
imports: [CommonModule, LucideAngularModule],
|
||||
templateUrl: './expandable-section.component.html',
|
||||
styleUrls: ['./expandable-section.component.scss']
|
||||
})
|
||||
export class ExpandableSectionComponent {
|
||||
readonly ChevronDown = ChevronDown;
|
||||
readonly ChevronUp = ChevronUp;
|
||||
|
||||
@Input() title = '';
|
||||
@Input() icon = ''; // Emoji ou caractère unicode (ex: '📍', '📖')
|
||||
@Input() initiallyOpen = false;
|
||||
@Input() variant: 'default' | 'private' = 'default'; // 'private' = notes MJ (couleur différente)
|
||||
|
||||
isOpen = false;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.isOpen = this.initiallyOpen;
|
||||
}
|
||||
|
||||
toggle(): void {
|
||||
this.isOpen = !this.isOpen;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<div class="gs-overlay" *ngIf="open" (click)="close()">
|
||||
<div class="gs-modal" (click)="$event.stopPropagation()">
|
||||
|
||||
<div class="gs-input-row">
|
||||
<lucide-icon [img]="Search" [size]="18" class="gs-search-icon"></lucide-icon>
|
||||
<input
|
||||
#searchInput
|
||||
type="text"
|
||||
class="gs-input"
|
||||
placeholder="Rechercher dans LoreMind..."
|
||||
[ngModel]="query"
|
||||
(ngModelChange)="onQueryChange($event)" />
|
||||
<span class="gs-kbd">ESC</span>
|
||||
</div>
|
||||
|
||||
<div class="gs-results" *ngIf="results.length > 0">
|
||||
<button
|
||||
*ngFor="let r of results; let i = index"
|
||||
class="gs-result"
|
||||
[class.active]="i === activeIndex"
|
||||
(mouseenter)="activeIndex = i"
|
||||
(click)="select(r)">
|
||||
<lucide-icon [img]="iconFor(r.kind)" [size]="16" class="gs-result-icon"></lucide-icon>
|
||||
<div class="gs-result-body">
|
||||
<div class="gs-result-title">{{ r.title }}</div>
|
||||
<div class="gs-result-subtitle" *ngIf="r.subtitle">{{ r.subtitle }}</div>
|
||||
<div class="gs-result-tag">{{ r.tag }}</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="gs-empty" *ngIf="!loading && query.trim().length >= 2 && results.length === 0">
|
||||
Aucun résultat
|
||||
</div>
|
||||
<div class="gs-empty" *ngIf="query.trim().length < 2">
|
||||
Tape au moins 2 caractères
|
||||
</div>
|
||||
|
||||
<div class="gs-footer">
|
||||
<div class="gs-hints">
|
||||
<span><kbd>↑</kbd><kbd>↓</kbd> naviguer</span>
|
||||
<span><kbd>↵</kbd> sélectionner</span>
|
||||
<span><kbd>ESC</kbd> fermer</span>
|
||||
</div>
|
||||
<span class="gs-count" *ngIf="results.length > 0">
|
||||
{{ results.length }} résultat{{ results.length > 1 ? 's' : '' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
118
web/src/app/shared/global-search/global-search.component.scss
Normal file
118
web/src/app/shared/global-search/global-search.component.scss
Normal file
@@ -0,0 +1,118 @@
|
||||
.gs-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-top: 10vh;
|
||||
}
|
||||
|
||||
.gs-modal {
|
||||
width: min(640px, 92vw);
|
||||
background: #1f2232;
|
||||
border: 1px solid #2d3145;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.gs-input-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 1.25rem;
|
||||
border-bottom: 1px solid #2d3145;
|
||||
}
|
||||
|
||||
.gs-search-icon { color: #6b7280; flex-shrink: 0; }
|
||||
|
||||
.gs-input {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
color: #e5e7eb;
|
||||
font-size: 1rem;
|
||||
|
||||
&::placeholder { color: #6b7280; }
|
||||
}
|
||||
|
||||
.gs-kbd,
|
||||
.gs-hints kbd {
|
||||
background: #2d3145;
|
||||
color: #9ca3af;
|
||||
font-size: 0.7rem;
|
||||
padding: 0.15rem 0.4rem;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #3a3f55;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.gs-results {
|
||||
max-height: 50vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.gs-result {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 1.25rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #e5e7eb;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
|
||||
&.active { background: rgba(99, 102, 241, 0.18); }
|
||||
}
|
||||
|
||||
.gs-result-icon { color: #9ca3af; margin-top: 2px; flex-shrink: 0; }
|
||||
|
||||
.gs-result-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.gs-result-title { font-weight: 600; color: #e5e7eb; }
|
||||
.gs-result-subtitle {
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.gs-result-tag {
|
||||
color: #6b7280;
|
||||
font-size: 0.75rem;
|
||||
margin-top: 0.15rem;
|
||||
}
|
||||
|
||||
.gs-empty {
|
||||
padding: 1.5rem;
|
||||
text-align: center;
|
||||
color: #6b7280;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.gs-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.6rem 1.25rem;
|
||||
border-top: 1px solid #2d3145;
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.gs-hints {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
|
||||
span { display: flex; align-items: center; gap: 0.3rem; }
|
||||
}
|
||||
216
web/src/app/shared/global-search/global-search.component.ts
Normal file
216
web/src/app/shared/global-search/global-search.component.ts
Normal file
@@ -0,0 +1,216 @@
|
||||
import { Component, ElementRef, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { BehaviorSubject, Subject, forkJoin, of } from 'rxjs';
|
||||
import { catchError, debounceTime, distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators';
|
||||
import { LucideAngularModule, Search, BookOpen, Folder, Users, FileText, Scroll } from 'lucide-angular';
|
||||
import { GlobalSearchService } from '../../services/global-search.service';
|
||||
import { LoreService } from '../../services/lore.service';
|
||||
import { PageService } from '../../services/page.service';
|
||||
import { TemplateService } from '../../services/template.service';
|
||||
import { CampaignService } from '../../services/campaign.service';
|
||||
|
||||
type ResultKind = 'lore' | 'node' | 'template' | 'page' | 'campaign';
|
||||
|
||||
interface SearchResult {
|
||||
id: string;
|
||||
kind: ResultKind;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
/** Tag affiché sous le titre (ex: "Lore", "Dossier", "Template", "Page"). */
|
||||
tag: string;
|
||||
/** Route Angular (array pour router.navigate). */
|
||||
route: any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Command palette globale (Ctrl+K / Cmd+K).
|
||||
* Agrège 4 endpoints search (Lore, LoreNode, Template, Page) côté frontend.
|
||||
* Navigation clavier : ↑↓ ↵ Esc.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-global-search',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, LucideAngularModule],
|
||||
templateUrl: './global-search.component.html',
|
||||
styleUrls: ['./global-search.component.scss']
|
||||
})
|
||||
export class GlobalSearchComponent implements OnInit, OnDestroy {
|
||||
readonly Search = Search;
|
||||
readonly BookOpen = BookOpen;
|
||||
readonly Folder = Folder;
|
||||
readonly Users = Users;
|
||||
readonly FileText = FileText;
|
||||
readonly Scroll = Scroll;
|
||||
|
||||
@ViewChild('searchInput') searchInput?: ElementRef<HTMLInputElement>;
|
||||
|
||||
open = false;
|
||||
query = '';
|
||||
loading = false;
|
||||
results: SearchResult[] = [];
|
||||
activeIndex = 0;
|
||||
|
||||
private readonly queryChanges$ = new BehaviorSubject<string>('');
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private globalSearch: GlobalSearchService,
|
||||
private router: Router,
|
||||
private loreService: LoreService,
|
||||
private pageService: PageService,
|
||||
private templateService: TemplateService,
|
||||
private campaignService: CampaignService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.globalSearch.open$.pipe(takeUntil(this.destroy$)).subscribe(open => {
|
||||
this.open = open;
|
||||
if (open) {
|
||||
this.query = '';
|
||||
this.results = [];
|
||||
this.activeIndex = 0;
|
||||
// focus après le tick de rendu (ngIf du template)
|
||||
setTimeout(() => this.searchInput?.nativeElement.focus(), 0);
|
||||
}
|
||||
});
|
||||
|
||||
this.queryChanges$.pipe(
|
||||
debounceTime(200),
|
||||
distinctUntilChanged(),
|
||||
switchMap(q => {
|
||||
const trimmed = q.trim();
|
||||
if (trimmed.length < 2) {
|
||||
this.loading = false;
|
||||
return of<SearchResult[]>([]);
|
||||
}
|
||||
this.loading = true;
|
||||
return forkJoin({
|
||||
lores: this.loreService.searchLores(trimmed).pipe(catchError(() => of([]))),
|
||||
nodes: this.loreService.searchLoreNodes(trimmed).pipe(catchError(() => of([]))),
|
||||
templates: this.templateService.search(trimmed).pipe(catchError(() => of([]))),
|
||||
pages: this.pageService.search(trimmed).pipe(catchError(() => of([]))),
|
||||
campaigns: this.campaignService.search(trimmed).pipe(catchError(() => of([])))
|
||||
}).pipe(
|
||||
switchMap(({ lores, nodes, templates, pages, campaigns }) => of(this.buildResults(lores, nodes, templates, pages, campaigns))),
|
||||
catchError(() => of<SearchResult[]>([]))
|
||||
);
|
||||
}),
|
||||
takeUntil(this.destroy$)
|
||||
).subscribe(results => {
|
||||
this.results = results;
|
||||
this.activeIndex = 0;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
onQueryChange(value: string): void {
|
||||
this.query = value;
|
||||
this.queryChanges$.next(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construit la liste unifiée. Ordre d'affichage : pages d'abord (le plus recherché),
|
||||
* puis noeuds, templates, campagnes, et lores — les entités racines apparaissent en dernier.
|
||||
*/
|
||||
private buildResults(
|
||||
lores: any[], nodes: any[], templates: any[], pages: any[], campaigns: any[]
|
||||
): SearchResult[] {
|
||||
const pageResults: SearchResult[] = pages.map(p => ({
|
||||
id: p.id,
|
||||
kind: 'page' as ResultKind,
|
||||
title: p.title,
|
||||
subtitle: p.notes ? this.firstLine(p.notes) : '',
|
||||
tag: 'Page',
|
||||
route: ['/lore', p.loreId, 'pages', p.id]
|
||||
}));
|
||||
const nodeResults: SearchResult[] = nodes.map(n => ({
|
||||
id: n.id,
|
||||
kind: 'node' as ResultKind,
|
||||
title: n.name,
|
||||
subtitle: '',
|
||||
tag: 'Dossier',
|
||||
route: ['/lore', n.loreId, 'folders', n.id, 'edit']
|
||||
}));
|
||||
const templateResults: SearchResult[] = templates.map(t => ({
|
||||
id: t.id,
|
||||
kind: 'template' as ResultKind,
|
||||
title: t.name,
|
||||
subtitle: t.description ?? '',
|
||||
tag: 'Template',
|
||||
route: ['/lore', t.loreId, 'templates', t.id]
|
||||
}));
|
||||
const loreResults: SearchResult[] = lores.map(l => ({
|
||||
id: l.id,
|
||||
kind: 'lore' as ResultKind,
|
||||
title: l.name,
|
||||
subtitle: l.description ?? '',
|
||||
tag: 'Lore',
|
||||
route: ['/lore', l.id]
|
||||
}));
|
||||
const campaignResults: SearchResult[] = campaigns.map(c => ({
|
||||
id: c.id,
|
||||
kind: 'campaign' as ResultKind,
|
||||
title: c.name,
|
||||
subtitle: c.description ?? '',
|
||||
tag: 'Campagne',
|
||||
route: ['/campaigns', c.id]
|
||||
}));
|
||||
return [...pageResults, ...nodeResults, ...templateResults, ...campaignResults, ...loreResults];
|
||||
}
|
||||
|
||||
private firstLine(text: string): string {
|
||||
const line = text.split('\n')[0] ?? '';
|
||||
return line.length > 120 ? line.slice(0, 117) + '…' : line;
|
||||
}
|
||||
|
||||
select(result: SearchResult): void {
|
||||
this.router.navigate(result.route);
|
||||
this.globalSearch.close();
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.globalSearch.close();
|
||||
}
|
||||
|
||||
/** Raccourcis clavier globaux — actifs uniquement quand la modale est ouverte. */
|
||||
@HostListener('document:keydown', ['$event'])
|
||||
onKeydown(event: KeyboardEvent): void {
|
||||
if (!this.open) return;
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
this.close();
|
||||
} else if (event.key === 'ArrowDown') {
|
||||
event.preventDefault();
|
||||
if (this.results.length > 0) {
|
||||
this.activeIndex = (this.activeIndex + 1) % this.results.length;
|
||||
}
|
||||
} else if (event.key === 'ArrowUp') {
|
||||
event.preventDefault();
|
||||
if (this.results.length > 0) {
|
||||
this.activeIndex = (this.activeIndex - 1 + this.results.length) % this.results.length;
|
||||
}
|
||||
} else if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
const r = this.results[this.activeIndex];
|
||||
if (r) this.select(r);
|
||||
}
|
||||
}
|
||||
|
||||
iconFor(kind: ResultKind) {
|
||||
switch (kind) {
|
||||
case 'lore': return this.BookOpen;
|
||||
case 'node': return this.Folder;
|
||||
case 'template': return this.Users;
|
||||
case 'page': return this.FileText;
|
||||
case 'campaign': return this.Scroll;
|
||||
default: return this.FileText;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<!-- Grille de vignettes + uploader si editable. -->
|
||||
<div class="gallery"
|
||||
*ngIf="imageIds.length > 0 || editable; else empty">
|
||||
|
||||
<div class="gallery-tile"
|
||||
*ngFor="let id of imageIds"
|
||||
(click)="openLightbox(id)"
|
||||
role="button"
|
||||
tabindex="0">
|
||||
<img [src]="urlFor(id)" [alt]="'Illustration ' + id" loading="lazy" />
|
||||
|
||||
<button type="button"
|
||||
class="gallery-remove"
|
||||
*ngIf="editable"
|
||||
(click)="remove(id, $event)"
|
||||
aria-label="Retirer cette image">
|
||||
<lucide-icon [img]="X" [size]="14"></lucide-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Bouton + (uploader compact), uniquement en mode edition -->
|
||||
<app-image-uploader
|
||||
*ngIf="editable"
|
||||
[compact]="true"
|
||||
(uploaded)="onUploaded($event)">
|
||||
</app-image-uploader>
|
||||
</div>
|
||||
|
||||
<!-- Etat vide (lecture uniquement). -->
|
||||
<ng-template #empty>
|
||||
<div class="gallery-empty">
|
||||
<lucide-icon [img]="ImageIcon" [size]="20"></lucide-icon>
|
||||
<span>Aucune illustration</span>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<!-- Lightbox : image plein ecran sur fond noir, clic pour fermer. -->
|
||||
<div class="lightbox-backdrop"
|
||||
*ngIf="lightboxId"
|
||||
(click)="closeLightbox()"
|
||||
role="dialog"
|
||||
aria-label="Image en plein ecran">
|
||||
<img [src]="urlFor(lightboxId)" alt="Image agrandie" class="lightbox-image" />
|
||||
<button type="button" class="lightbox-close" (click)="closeLightbox()" aria-label="Fermer">
|
||||
<lucide-icon [img]="X" [size]="24"></lucide-icon>
|
||||
</button>
|
||||
</div>
|
||||
107
web/src/app/shared/image-gallery/image-gallery.component.scss
Normal file
107
web/src/app/shared/image-gallery/image-gallery.component.scss
Normal file
@@ -0,0 +1,107 @@
|
||||
.gallery {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.8rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.gallery-tile {
|
||||
position: relative;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
cursor: zoom-in;
|
||||
transition: border-color 0.15s, transform 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: #6c63ff;
|
||||
transform: translateY(-2px);
|
||||
|
||||
.gallery-remove { opacity: 1; }
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.gallery-remove {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
right: 6px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: rgba(17, 17, 30, 0.85);
|
||||
color: #fca5a5;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s, background 0.15s;
|
||||
|
||||
&:hover { background: #7f1d1d; color: white; }
|
||||
}
|
||||
|
||||
.gallery-empty {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: #4b5563;
|
||||
font-size: 0.85rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
// Lightbox plein ecran
|
||||
.lightbox-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
background: rgba(0, 0, 0, 0.88);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
cursor: zoom-out;
|
||||
animation: fade-in 0.15s ease-out;
|
||||
}
|
||||
|
||||
.lightbox-image {
|
||||
max-width: 95vw;
|
||||
max-height: 90vh;
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.lightbox-close {
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: rgba(30, 30, 60, 0.8);
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover { background: #6c63ff; }
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
76
web/src/app/shared/image-gallery/image-gallery.component.ts
Normal file
76
web/src/app/shared/image-gallery/image-gallery.component.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { LucideAngularModule, X, Image as ImageIcon } from 'lucide-angular';
|
||||
import { ImageService } from '../../services/image.service';
|
||||
import { Image } from '../../services/image.model';
|
||||
import { ImageUploaderComponent } from '../image-uploader/image-uploader.component';
|
||||
|
||||
/**
|
||||
* Composant reutilisable de galerie d'images.
|
||||
*
|
||||
* Deux modes :
|
||||
* - editable=false (defaut) : affichage en grille, clic sur une image ouvre
|
||||
* un lightbox plein ecran pour zoomer.
|
||||
* - editable=true : bouton "+ ajouter" en fin de grille (via app-image-uploader),
|
||||
* chaque vignette a un bouton "X" pour la retirer.
|
||||
*
|
||||
* La galerie raisonne sur une liste d'IDs d'images (string[]). Elle ne stocke
|
||||
* pas les objets Image eux-memes : les thumbs utilisent `imageService.contentUrl(id)`
|
||||
* directement comme src. Le navigateur cache les binaires via Cache-Control immutable
|
||||
* pose par le backend, donc aucune requete redondante.
|
||||
*
|
||||
* Usage :
|
||||
* <app-image-gallery [imageIds]="scene.illustrationImageIds"></app-image-gallery>
|
||||
* <app-image-gallery [imageIds]="tempIds" [editable]="true"
|
||||
* (imageIdsChange)="tempIds = $event"></app-image-gallery>
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-image-gallery',
|
||||
standalone: true,
|
||||
imports: [CommonModule, LucideAngularModule, ImageUploaderComponent],
|
||||
templateUrl: './image-gallery.component.html',
|
||||
styleUrls: ['./image-gallery.component.scss']
|
||||
})
|
||||
export class ImageGalleryComponent {
|
||||
readonly X = X;
|
||||
readonly ImageIcon = ImageIcon;
|
||||
|
||||
/** IDs d'images a afficher. */
|
||||
@Input() imageIds: string[] = [];
|
||||
|
||||
/** Mode edition : afficher le bouton d'ajout + les boutons de suppression. */
|
||||
@Input() editable = false;
|
||||
|
||||
/** Emet la nouvelle liste quand l'utilisateur ajoute/retire une image. */
|
||||
@Output() imageIdsChange = new EventEmitter<string[]>();
|
||||
|
||||
/** ID de l'image actuellement ouverte en lightbox (null = ferme). */
|
||||
lightboxId: string | null = null;
|
||||
|
||||
constructor(private imageService: ImageService) {}
|
||||
|
||||
/** URL absolue du binaire d'une image. */
|
||||
urlFor(id: string): string {
|
||||
return this.imageService.contentUrl(id);
|
||||
}
|
||||
|
||||
onUploaded(image: Image): void {
|
||||
this.imageIdsChange.emit([...this.imageIds, image.id]);
|
||||
}
|
||||
|
||||
remove(id: string, event: MouseEvent): void {
|
||||
event.stopPropagation(); // Evite d'ouvrir le lightbox en cliquant sur X.
|
||||
// On supprime aussi cote serveur pour ne pas laisser d'image orpheline.
|
||||
// Best-effort : on n'attend pas le retour pour emettre la nouvelle liste.
|
||||
this.imageService.delete(id).subscribe({ error: () => {} });
|
||||
this.imageIdsChange.emit(this.imageIds.filter(i => i !== id));
|
||||
}
|
||||
|
||||
openLightbox(id: string): void {
|
||||
this.lightboxId = id;
|
||||
}
|
||||
|
||||
closeLightbox(): void {
|
||||
this.lightboxId = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<!-- Mode compact : bouton "+ ajouter" carre, utilise dans les galeries. -->
|
||||
<ng-container *ngIf="compact; else dropZone">
|
||||
<label class="upload-compact" [class.loading]="uploading" [title]="errorMessage || 'Ajouter une image'">
|
||||
<ng-container *ngIf="!uploading; else spinner">
|
||||
<lucide-icon [img]="Upload" [size]="18"></lucide-icon>
|
||||
<span>Ajouter</span>
|
||||
</ng-container>
|
||||
<input type="file"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
(change)="onFileSelected($event)"
|
||||
[disabled]="uploading"
|
||||
hidden />
|
||||
</label>
|
||||
<p *ngIf="errorMessage" class="upload-error-inline">
|
||||
<lucide-icon [img]="AlertCircle" [size]="12"></lucide-icon>
|
||||
{{ errorMessage }}
|
||||
</p>
|
||||
</ng-container>
|
||||
|
||||
<!-- Mode standard : grande drop-zone cliquable. -->
|
||||
<ng-template #dropZone>
|
||||
<label class="upload-zone"
|
||||
[class.drag-over]="dragOver"
|
||||
[class.loading]="uploading"
|
||||
(dragover)="onDragOver($event)"
|
||||
(dragleave)="onDragLeave()"
|
||||
(drop)="onDrop($event)">
|
||||
|
||||
<ng-container *ngIf="!uploading; else spinner">
|
||||
<lucide-icon [img]="Upload" [size]="32"></lucide-icon>
|
||||
<p class="upload-zone-title">Glisse une image ici</p>
|
||||
<p class="upload-zone-hint">ou clique pour choisir un fichier (JPEG, PNG, WebP, GIF, max 10 Mo)</p>
|
||||
</ng-container>
|
||||
|
||||
<input type="file"
|
||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||
(change)="onFileSelected($event)"
|
||||
[disabled]="uploading"
|
||||
hidden />
|
||||
</label>
|
||||
|
||||
<p *ngIf="errorMessage" class="upload-error" role="alert">
|
||||
<lucide-icon [img]="AlertCircle" [size]="14"></lucide-icon>
|
||||
{{ errorMessage }}
|
||||
</p>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #spinner>
|
||||
<div class="upload-spinner" aria-label="Upload en cours"></div>
|
||||
<p class="upload-zone-hint">Upload en cours...</p>
|
||||
</ng-template>
|
||||
@@ -0,0 +1,88 @@
|
||||
// Drop-zone standard
|
||||
.upload-zone {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
min-height: 140px;
|
||||
padding: 1.5rem;
|
||||
background: #1a1a2e;
|
||||
border: 2px dashed #2a2a3d;
|
||||
border-radius: 8px;
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s, color 0.15s;
|
||||
|
||||
&:hover { border-color: #6c63ff; color: #d1d5db; }
|
||||
&.drag-over { border-color: #6c63ff; background: #1f1f3a; color: white; }
|
||||
&.loading { cursor: progress; opacity: 0.7; }
|
||||
}
|
||||
|
||||
.upload-zone-title {
|
||||
margin: 0;
|
||||
font-size: 0.92rem;
|
||||
font-weight: 500;
|
||||
color: #d1d5db;
|
||||
}
|
||||
|
||||
.upload-zone-hint {
|
||||
margin: 0;
|
||||
font-size: 0.78rem;
|
||||
color: #6b7280;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
// Variante compacte (bouton carre pour galerie)
|
||||
.upload-compact {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.3rem;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background: #1a1a2e;
|
||||
border: 2px dashed #2a2a3d;
|
||||
border-radius: 6px;
|
||||
color: #6b7280;
|
||||
font-size: 0.78rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s, color 0.15s;
|
||||
|
||||
&:hover { border-color: #6c63ff; color: #a5b4fc; background: #1f1f3a; }
|
||||
&.loading { cursor: progress; opacity: 0.7; }
|
||||
}
|
||||
|
||||
.upload-error, .upload-error-inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0.5rem 0.7rem;
|
||||
background: #3f1f1f;
|
||||
color: #fca5a5;
|
||||
border: 1px solid #7f1d1d;
|
||||
border-radius: 6px;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.upload-error-inline {
|
||||
padding: 0.3rem 0.5rem;
|
||||
font-size: 0.72rem;
|
||||
margin-top: 0.3rem;
|
||||
}
|
||||
|
||||
// Spinner CSS simple (pas de dep externe)
|
||||
.upload-spinner {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: 3px solid #2a2a3d;
|
||||
border-top-color: #6c63ff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
100
web/src/app/shared/image-uploader/image-uploader.component.ts
Normal file
100
web/src/app/shared/image-uploader/image-uploader.component.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { LucideAngularModule, Upload, AlertCircle } from 'lucide-angular';
|
||||
import { ImageService } from '../../services/image.service';
|
||||
import { Image } from '../../services/image.model';
|
||||
|
||||
/**
|
||||
* Composant reutilisable d'upload d'image (drop-zone + bouton file).
|
||||
*
|
||||
* Usage :
|
||||
* <app-image-uploader (uploaded)="onImageUploaded($event)"></app-image-uploader>
|
||||
*
|
||||
* Responsabilites :
|
||||
* - Accepter un fichier via drag&drop OU clic sur la zone
|
||||
* - Valider cote client (MIME + taille) pour eviter un aller-retour inutile
|
||||
* - POSTer vers /api/images (service ImageService)
|
||||
* - Emettre (uploaded) avec l'objet Image recu
|
||||
* - Afficher l'etat loading et les erreurs
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-image-uploader',
|
||||
standalone: true,
|
||||
imports: [CommonModule, LucideAngularModule],
|
||||
templateUrl: './image-uploader.component.html',
|
||||
styleUrls: ['./image-uploader.component.scss']
|
||||
})
|
||||
export class ImageUploaderComponent {
|
||||
readonly Upload = Upload;
|
||||
readonly AlertCircle = AlertCircle;
|
||||
|
||||
/** Compact mode : bouton "+ ajouter" plutot que grande drop-zone. */
|
||||
@Input() compact = false;
|
||||
|
||||
/** Emit quand l'image est uploadee avec succes. */
|
||||
@Output() uploaded = new EventEmitter<Image>();
|
||||
|
||||
uploading = false;
|
||||
errorMessage: string | null = null;
|
||||
dragOver = false;
|
||||
|
||||
/** MIME types alignes avec le backend (ImageService.java). */
|
||||
private readonly ALLOWED_MIMES = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
|
||||
private readonly MAX_BYTES = 10 * 1024 * 1024;
|
||||
|
||||
constructor(private imageService: ImageService) {}
|
||||
|
||||
onFileSelected(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
if (input.files && input.files.length > 0) {
|
||||
this.handleFile(input.files[0]);
|
||||
// Reset pour permettre de re-uploader la meme image si besoin.
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
onDragOver(event: DragEvent): void {
|
||||
event.preventDefault();
|
||||
this.dragOver = true;
|
||||
}
|
||||
|
||||
onDragLeave(): void {
|
||||
this.dragOver = false;
|
||||
}
|
||||
|
||||
onDrop(event: DragEvent): void {
|
||||
event.preventDefault();
|
||||
this.dragOver = false;
|
||||
if (event.dataTransfer?.files && event.dataTransfer.files.length > 0) {
|
||||
this.handleFile(event.dataTransfer.files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private handleFile(file: File): void {
|
||||
this.errorMessage = null;
|
||||
|
||||
// Validation cote client (premier filet de securite).
|
||||
if (!this.ALLOWED_MIMES.includes(file.type)) {
|
||||
this.errorMessage = 'Format non supporte (JPEG, PNG, WebP, GIF uniquement).';
|
||||
return;
|
||||
}
|
||||
if (file.size > this.MAX_BYTES) {
|
||||
this.errorMessage = `Fichier trop volumineux (max ${this.MAX_BYTES / 1024 / 1024} Mo).`;
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploading = true;
|
||||
this.imageService.upload(file).subscribe({
|
||||
next: (image) => {
|
||||
this.uploading = false;
|
||||
this.uploaded.emit(image);
|
||||
},
|
||||
error: (err) => {
|
||||
this.uploading = false;
|
||||
this.errorMessage = err?.status === 413
|
||||
? 'Fichier refuse par le serveur (trop volumineux).'
|
||||
: 'Echec de l\'upload. Verifiez que le backend et MinIO tournent.';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<div class="picker">
|
||||
|
||||
<!-- Chips des pages déjà liées -->
|
||||
<div class="linked-chips" *ngIf="linkedPages.length > 0">
|
||||
<span class="chip" *ngFor="let p of linkedPages">
|
||||
<a
|
||||
class="chip-label"
|
||||
[href]="pageUrl(p.id!)"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
title="Ouvrir dans un nouvel onglet">
|
||||
<lucide-icon [img]="Link2" [size]="12"></lucide-icon>
|
||||
{{ p.title }}
|
||||
</a>
|
||||
<button type="button" class="chip-remove" (click)="remove(p.id!)" title="Retirer le lien">
|
||||
<lucide-icon [img]="X" [size]="12"></lucide-icon>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Input + dropdown de suggestions -->
|
||||
<div class="search-wrapper">
|
||||
<input
|
||||
type="text"
|
||||
class="search-input"
|
||||
placeholder="Rechercher une page à lier..."
|
||||
[(ngModel)]="query"
|
||||
(focus)="dropdownOpen = true"
|
||||
(blur)="onBlur()" />
|
||||
|
||||
<ul class="suggestions" *ngIf="dropdownOpen && suggestions.length > 0">
|
||||
<li *ngFor="let p of suggestions" (mousedown)="add(p)">
|
||||
{{ p.title }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p class="empty-hint" *ngIf="dropdownOpen && query && suggestions.length === 0">
|
||||
Aucune page ne correspond
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,114 @@
|
||||
.picker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.linked-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
background: #1e1c3a;
|
||||
color: #a5b4fc;
|
||||
border-radius: 999px;
|
||||
font-size: 0.82rem;
|
||||
overflow: hidden;
|
||||
|
||||
.chip-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
padding: 0.25rem 0.6rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover { color: #c7d2fe; }
|
||||
}
|
||||
|
||||
.chip-remove {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.25rem 0.5rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-left: 1px solid #2a2a3d;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
|
||||
&:hover { opacity: 1; color: #fca5a5; background: #2a2a3d; }
|
||||
}
|
||||
}
|
||||
|
||||
.search-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
color: white;
|
||||
padding: 0.65rem 0.9rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.88rem;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: #6c63ff;
|
||||
}
|
||||
|
||||
&::placeholder { color: #6b7280; }
|
||||
}
|
||||
|
||||
.suggestions {
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
left: 0;
|
||||
right: 0;
|
||||
list-style: none;
|
||||
padding: 0.25rem 0;
|
||||
margin: 0;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
z-index: 10;
|
||||
|
||||
li {
|
||||
padding: 0.55rem 0.9rem;
|
||||
color: #d1d5db;
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover { background: #20203a; color: white; }
|
||||
}
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 0.55rem 0.9rem;
|
||||
margin: 0;
|
||||
background: #1a1a2e;
|
||||
border: 1px solid #2a2a3d;
|
||||
border-radius: 6px;
|
||||
color: #6b7280;
|
||||
font-size: 0.82rem;
|
||||
font-style: italic;
|
||||
z-index: 10;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { LucideAngularModule, X, Link2 } from 'lucide-angular';
|
||||
import { Page } from '../../services/page.model';
|
||||
|
||||
/**
|
||||
* Composant pour lier une entité (Page, Arc, Chapter, Scene...) à un ensemble
|
||||
* de Pages du Lore par leurs IDs.
|
||||
*
|
||||
* Prévu pour être réutilisé en Phase cross-context Campagne↔Lore (sous-tâche 4) :
|
||||
* un Arc/Chapter/Scene pourra pointer vers des Pages du Lore via ce même picker.
|
||||
*
|
||||
* Usage :
|
||||
* <app-lore-link-picker
|
||||
* [value]="relatedPageIds"
|
||||
* [availablePages]="allPages"
|
||||
* [excludePageId]="currentPageId"
|
||||
* [loreId]="loreId"
|
||||
* (valueChange)="relatedPageIds = $event"></app-lore-link-picker>
|
||||
*
|
||||
* Design :
|
||||
* - Liste des pages liées = chips cliquables (clic → navigation vers la page)
|
||||
* - Input de recherche avec dropdown de suggestions filtrées (max 8 résultats)
|
||||
* - Exclut la page courante et les pages déjà sélectionnées
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-lore-link-picker',
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, LucideAngularModule],
|
||||
templateUrl: './lore-link-picker.component.html',
|
||||
styleUrls: ['./lore-link-picker.component.scss']
|
||||
})
|
||||
export class LoreLinkPickerComponent {
|
||||
readonly X = X;
|
||||
readonly Link2 = Link2;
|
||||
|
||||
/** IDs des pages actuellement liées (contrôlées par le parent). */
|
||||
@Input() value: string[] = [];
|
||||
/** Référentiel de pages dans lequel on peut piocher. */
|
||||
@Input() availablePages: Page[] = [];
|
||||
/** ID de la page courante (exclue des suggestions) — optionnel. */
|
||||
@Input() excludePageId: string | null = null;
|
||||
/** ID du lore courant, utilisé pour construire les URLs des chips cliquables. */
|
||||
@Input() loreId = '';
|
||||
|
||||
@Output() valueChange = new EventEmitter<string[]>();
|
||||
|
||||
/** Texte de recherche courant. */
|
||||
query = '';
|
||||
/** true tant que l'input a le focus (pour afficher le dropdown). */
|
||||
dropdownOpen = false;
|
||||
|
||||
/** Pages actuellement liées (résolues en objets complets pour affichage). */
|
||||
get linkedPages(): Page[] {
|
||||
return this.value
|
||||
.map(id => this.availablePages.find(p => p.id === id))
|
||||
.filter((p): p is Page => !!p);
|
||||
}
|
||||
|
||||
/** Pages proposables dans le dropdown — filtrées par query, exclut current + déjà liées. */
|
||||
get suggestions(): Page[] {
|
||||
const q = this.query.trim().toLowerCase();
|
||||
return this.availablePages
|
||||
.filter(p => p.id !== this.excludePageId)
|
||||
.filter(p => !this.value.includes(p.id!))
|
||||
.filter(p => q === '' || p.title.toLowerCase().includes(q))
|
||||
.slice(0, 8);
|
||||
}
|
||||
|
||||
/** Ajoute une page aux liens. */
|
||||
add(page: Page): void {
|
||||
if (!page.id || this.value.includes(page.id)) return;
|
||||
this.valueChange.emit([...this.value, page.id]);
|
||||
this.query = '';
|
||||
}
|
||||
|
||||
/** Retire une page des liens. */
|
||||
remove(pageId: string): void {
|
||||
this.valueChange.emit(this.value.filter(id => id !== pageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* URL vers la page liée — utilisée par un <a target="_blank"> dans le template.
|
||||
* Ouverture en nouvel onglet : on consulte la fiche d'un PNJ/lieu sans perdre
|
||||
* le contexte de la page/scène en cours d'édition.
|
||||
*/
|
||||
pageUrl(pageId: string): string {
|
||||
return `/lore/${this.loreId}/pages/${pageId}`;
|
||||
}
|
||||
|
||||
/** Retarde la fermeture du dropdown pour laisser le temps au clic de se propager. */
|
||||
onBlur(): void {
|
||||
setTimeout(() => { this.dropdownOpen = false; }, 150);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<aside class="secondary-sidebar" [class.collapsed]="isCollapsed">
|
||||
|
||||
<div class="collapse-toggle" (click)="toggleCollapse()">
|
||||
<lucide-icon [img]="isCollapsed ? PanelLeftOpen : PanelLeftClose" [size]="16"></lucide-icon>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="!isCollapsed">
|
||||
|
||||
<h2 class="sidebar-title">{{ title }}</h2>
|
||||
|
||||
<div class="actions-row" *ngIf="createActions.length">
|
||||
<button
|
||||
*ngFor="let action of createActions"
|
||||
class="btn-pill"
|
||||
[class.primary]="action.variant === 'primary'"
|
||||
[class.secondary]="action.variant === 'secondary'"
|
||||
(click)="runAction(action)">
|
||||
{{ action.label }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="tree">
|
||||
<ng-container *ngFor="let item of items">
|
||||
<ng-container *ngTemplateOutlet="treeNode; context: { $implicit: item, level: 0 }"></ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
<!-- Template récursif : un noeud d'arbre rend son bouton, puis ses enfants via ce même template -->
|
||||
<ng-template #treeNode let-item let-level="level">
|
||||
<div class="tree-item" [style.padding-left.px]="level * 12">
|
||||
<div class="tree-row">
|
||||
<button
|
||||
*ngIf="!item.isAction && item.children?.length"
|
||||
type="button"
|
||||
class="chevron-btn"
|
||||
(click)="clickChevron($event, item)">
|
||||
<lucide-icon
|
||||
[img]="isExpanded(item.id) ? ChevronDown : ChevronRight"
|
||||
[size]="12">
|
||||
</lucide-icon>
|
||||
</button>
|
||||
<span *ngIf="item.isAction || !item.children?.length" class="chevron-spacer"></span>
|
||||
|
||||
<button type="button" class="tree-btn" [class.action]="item.isAction" (click)="clickItem(item)">
|
||||
<lucide-icon
|
||||
*ngIf="iconFor(item) as icon"
|
||||
[img]="icon"
|
||||
[size]="14"
|
||||
class="item-icon">
|
||||
</lucide-icon>
|
||||
{{ item.label }}
|
||||
<span class="tree-item-meta" *ngIf="!item.isAction && item.meta">{{ item.meta }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="tree-children" *ngIf="isExpanded(item.id) && item.children?.length">
|
||||
<ng-container *ngFor="let child of item.children">
|
||||
<ng-container *ngTemplateOutlet="treeNode; context: { $implicit: child, level: level + 1 }"></ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<!-- Panneau bas (ex: Templates) ------------------------------------ -->
|
||||
<section class="bottom-panel" *ngIf="bottomPanel">
|
||||
<button class="panel-header" (click)="togglePanel()">
|
||||
<span class="panel-title">{{ bottomPanel.title }}</span>
|
||||
<lucide-icon
|
||||
[img]="panelOpen ? ChevronDown : ChevronRight"
|
||||
[size]="14">
|
||||
</lucide-icon>
|
||||
</button>
|
||||
<ul class="panel-list" *ngIf="panelOpen">
|
||||
<li *ngFor="let item of bottomPanel.items">
|
||||
<button
|
||||
class="panel-item"
|
||||
[class.action]="item.isAction"
|
||||
(click)="clickPanelItem(item)">
|
||||
<span class="panel-item-label">{{ item.label }}</span>
|
||||
<span class="panel-item-meta" *ngIf="item.meta">{{ item.meta }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</ng-container>
|
||||
|
||||
</aside>
|
||||
@@ -0,0 +1,235 @@
|
||||
.secondary-sidebar {
|
||||
width: 220px;
|
||||
height: 100vh;
|
||||
background: #0d0d1f;
|
||||
border-right: 1px solid #1e1e3a;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 1.25rem 0.75rem;
|
||||
gap: 0.75rem;
|
||||
overflow-y: auto;
|
||||
transition: width 0.25s ease;
|
||||
|
||||
&.collapsed {
|
||||
width: 44px;
|
||||
padding: 1.25rem 0.5rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.collapse-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: #6b7280;
|
||||
transition: color 0.2s, background 0.2s;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover { color: white; background: #1f2937; }
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 6px;
|
||||
transition: color 0.2s;
|
||||
width: fit-content;
|
||||
|
||||
&:hover { color: white; }
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
padding: 0 0.5rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.btn-pill {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.5rem 0.6rem;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, filter 0.15s;
|
||||
|
||||
&.primary { background: #6c63ff; color: white; }
|
||||
&.primary:hover { background: #5a52e0; }
|
||||
&.secondary { background: #2a2a3d; color: #d1d5db; }
|
||||
&.secondary:hover { background: #363650; }
|
||||
}
|
||||
|
||||
.tree {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.15rem;
|
||||
overflow-y: auto;
|
||||
padding: 0.25rem 0;
|
||||
}
|
||||
|
||||
.tree-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #d1d5db;
|
||||
font-size: 0.82rem;
|
||||
padding: 0.4rem 0.5rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover { background: #1f2937; }
|
||||
&.action { color: #6b7280; font-style: italic; }
|
||||
&.action:hover { color: #a5b4fc; background: #1f2937; }
|
||||
|
||||
.tree-item-meta {
|
||||
margin-left: auto;
|
||||
font-size: 0.72rem;
|
||||
color: #6b7280;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.item-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
color: #a5b4fc;
|
||||
flex-shrink: 0;
|
||||
margin-right: 0.1rem;
|
||||
}
|
||||
|
||||
.tree-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.15rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.chevron-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
color: #6b7280;
|
||||
padding: 0;
|
||||
|
||||
&:hover { background: #374151; color: white; }
|
||||
}
|
||||
|
||||
.chevron-spacer {
|
||||
display: inline-block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tree-children {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
}
|
||||
|
||||
|
||||
/* --- Bottom panel (ex: Templates) ------------------------------------- */
|
||||
.bottom-panel {
|
||||
border-top: 1px solid #1e1e3a;
|
||||
padding-top: 0.5rem;
|
||||
margin-top: auto; /* colle en bas de la sidebar flex */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #a5b4fc;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 600;
|
||||
padding: 0.4rem 0.5rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover { background: #1f2937; }
|
||||
|
||||
.panel-title { letter-spacing: 0.02em; }
|
||||
}
|
||||
|
||||
.panel-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
}
|
||||
|
||||
.panel-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #d1d5db;
|
||||
font-size: 0.82rem;
|
||||
padding: 0.4rem 0.6rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover { background: #1f2937; }
|
||||
|
||||
&.action {
|
||||
color: #6b7280;
|
||||
font-style: italic;
|
||||
}
|
||||
&.action:hover { color: #a5b4fc; }
|
||||
|
||||
.panel-item-meta {
|
||||
font-size: 0.72rem;
|
||||
color: #6b7280;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Router } from '@angular/router';
|
||||
import { LucideAngularModule, ChevronRight, ChevronDown, PanelLeftClose, PanelLeftOpen, LucideIconData } from 'lucide-angular';
|
||||
import { TreeItem, SidebarAction, BottomPanel, BottomPanelItem, LayoutService } from '../../services/layout.service';
|
||||
import { resolveIcon } from '../../lore/lore-icons';
|
||||
|
||||
@Component({
|
||||
selector: 'app-secondary-sidebar',
|
||||
standalone: true,
|
||||
imports: [CommonModule, LucideAngularModule],
|
||||
templateUrl: './secondary-sidebar.component.html',
|
||||
styleUrls: ['./secondary-sidebar.component.scss']
|
||||
})
|
||||
export class SecondarySidebarComponent {
|
||||
@Input() title = '';
|
||||
@Input() createActions: SidebarAction[] = [];
|
||||
@Input() bottomPanel: BottomPanel | null = null;
|
||||
@Output() collapsedChange = new EventEmitter<boolean>();
|
||||
|
||||
/** true = ouvert (on affiche les items) ; false = replié (titre seul). */
|
||||
panelOpen = true;
|
||||
|
||||
readonly ChevronDown = ChevronDown;
|
||||
readonly ChevronRight = ChevronRight;
|
||||
readonly PanelLeftClose = PanelLeftClose;
|
||||
readonly PanelLeftOpen = PanelLeftOpen;
|
||||
|
||||
isCollapsed = false;
|
||||
|
||||
private _items: TreeItem[] = [];
|
||||
|
||||
@Input() set items(value: TreeItem[]) {
|
||||
this._items = value ?? [];
|
||||
this.autoExpandActiveAncestors();
|
||||
}
|
||||
get items(): TreeItem[] { return this._items; }
|
||||
|
||||
constructor(private router: Router, private layoutService: LayoutService) {}
|
||||
|
||||
runAction(action: SidebarAction): void {
|
||||
if (action.route) { this.router.navigate([action.route]); }
|
||||
}
|
||||
|
||||
clickItem(item: TreeItem): void {
|
||||
if (item.route) { this.router.navigate([item.route]); return; }
|
||||
this.toggleItem(item.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clic sur le chevron : toggle uniquement (ne navigue jamais).
|
||||
* stopPropagation évite que l'event remonte au bouton parent.
|
||||
*/
|
||||
clickChevron(event: Event, item: TreeItem): void {
|
||||
event.stopPropagation();
|
||||
this.toggleItem(item.id);
|
||||
}
|
||||
|
||||
toggleCollapse(): void {
|
||||
this.isCollapsed = !this.isCollapsed;
|
||||
this.collapsedChange.emit(this.isCollapsed);
|
||||
}
|
||||
|
||||
toggleItem(id: string): void {
|
||||
this.layoutService.toggleExpanded(id);
|
||||
}
|
||||
|
||||
isExpanded(id: string): boolean {
|
||||
return this.layoutService.isExpanded(id);
|
||||
}
|
||||
|
||||
togglePanel(): void {
|
||||
this.panelOpen = !this.panelOpen;
|
||||
}
|
||||
|
||||
clickPanelItem(item: BottomPanelItem): void {
|
||||
if (item.route) { this.router.navigate([item.route]); }
|
||||
}
|
||||
|
||||
/** Résout la clé d'icône d'un TreeItem en icône lucide pour le template. */
|
||||
iconFor(item: TreeItem): LucideIconData | null {
|
||||
return item.iconKey ? resolveIcon(item.iconKey) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-déplie la chaîne d'ancêtres du item dont `route` matche l'URL active.
|
||||
* Nécessaire car la sidebar est détruite/recréée à chaque navigation (ngIf
|
||||
* dans app.component.html) : sans ça, même si on persiste `expandedItems`
|
||||
* dans le service, un deep-link sur une page profonde arriverait tout replié.
|
||||
*/
|
||||
private autoExpandActiveAncestors(): void {
|
||||
const url = this.router.url;
|
||||
// On descend d'abord dans les enfants pour trouver le match le plus profond :
|
||||
// sinon, un parent qui matche par préfixe (ex. /campaigns/A/arcs/X matche
|
||||
// aussi /campaigns/A/arcs/X/chapters/M) court-circuiterait la descente et
|
||||
// on ne déplierait pas l'arc pour montrer le chapitre actif.
|
||||
const walk = (item: TreeItem, ancestors: string[]): boolean => {
|
||||
if (item.children) {
|
||||
const nextAncestors = [...ancestors, item.id];
|
||||
for (const child of item.children) {
|
||||
if (walk(child, nextAncestors)) return true;
|
||||
}
|
||||
}
|
||||
const matches = !!item.route && (item.route === url || url.startsWith(item.route + '/'));
|
||||
if (matches) {
|
||||
ancestors.forEach(id => this.layoutService.setExpanded(id, true));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
for (const root of this._items) {
|
||||
walk(root, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user