Initial commit - LoreMind project

This commit is contained in:
2026-04-19 12:08:16 +02:00
parent 95928b7165
commit b3e0e0883b
213 changed files with 25358 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<div class="page" *ngIf="template">
<header class="page-header">
<div>
<h1>{{ template.name }}</h1>
<p class="subtitle">Template</p>
</div>
<div class="header-actions">
<button type="button" class="btn-danger" (click)="delete()">Supprimer</button>
<button type="button" class="btn-primary" (click)="save()" [disabled]="form.invalid">Sauvegarder</button>
</div>
</header>
<form [formGroup]="form" class="template-form">
<!-- Colonne gauche ---------------------------------------------- -->
<div class="col-left">
<div class="field">
<label>Nom</label>
<input type="text" formControlName="name" />
</div>
<div class="field">
<label>Dossier par défaut</label>
<select formControlName="defaultNodeId">
<option value="">-- Aucun --</option>
<option *ngFor="let node of nodes" [value]="node.id">{{ node.name }}</option>
</select>
<p class="hint">Les pages créées avec ce template seront placées dans ce dossier par défaut</p>
</div>
<div class="field">
<label>Description</label>
<textarea formControlName="description" rows="6"></textarea>
</div>
</div>
<!-- Colonne droite --------------------------------------------- -->
<div class="col-right">
<label class="section-label">Champs du template</label>
<ul class="fields-list">
<li class="field-row" *ngFor="let f of fields; let i = index">
<span class="field-chip">{{ f }}</span>
<button type="button" class="btn-icon-ghost" (click)="removeField(i)" aria-label="Supprimer">
<lucide-icon [img]="X" [size]="14"></lucide-icon>
</button>
</li>
</ul>
<div class="field-row add-row">
<input
type="text"
[(ngModel)]="newFieldName"
[ngModelOptions]="{ standalone: true }"
placeholder="+ Ajouter un champ"
(keydown.enter)="$event.preventDefault(); addField()" />
<button type="button" class="btn-add" (click)="addField()">
<lucide-icon [img]="Plus" [size]="14"></lucide-icon>
</button>
</div>
<p class="hint">Définissez les champs qui apparaîtront dans les pages créées avec ce template</p>
</div>
</form>
</div>

View File

@@ -0,0 +1,205 @@
.page {
padding: 2rem 3rem;
max-width: 1000px;
}
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 2rem;
h1 {
font-size: 1.6rem;
font-weight: 700;
color: white;
margin: 0 0 0.25rem;
}
.subtitle {
color: #9ca3af;
font-size: 0.85rem;
margin: 0;
}
.header-actions {
display: flex;
gap: 0.6rem;
}
}
.template-form {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem 2.5rem;
.col-left, .col-right {
display: flex;
flex-direction: column;
gap: 1.25rem;
}
}
.field {
display: flex;
flex-direction: column;
gap: 0.4rem;
label {
font-size: 0.82rem;
font-weight: 500;
color: #d1d5db;
}
input, textarea, select {
background: #1a1a2e;
border: 1px solid #2a2a3d;
color: white;
padding: 0.7rem 0.9rem;
border-radius: 6px;
font-size: 0.9rem;
font-family: inherit;
&:focus {
outline: none;
border-color: #6c63ff;
}
}
textarea { resize: vertical; }
}
.hint {
font-size: 0.76rem;
color: #6b7280;
margin: 0;
}
.section-label {
font-size: 0.82rem;
font-weight: 500;
color: #d1d5db;
margin-bottom: 0.4rem;
}
.fields-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.field-row {
display: flex;
align-items: center;
gap: 0.5rem;
.field-chip {
flex: 1;
background: #1a1a2e;
border: 1px solid #2a2a3d;
color: white;
padding: 0.6rem 0.9rem;
border-radius: 6px;
font-size: 0.88rem;
display: flex;
align-items: center;
justify-content: space-between;
}
input {
flex: 1;
background: #1a1a2e;
border: 1px solid #2a2a3d;
color: white;
padding: 0.6rem 0.9rem;
border-radius: 6px;
font-size: 0.88rem;
&:focus {
outline: none;
border-color: #6c63ff;
}
&::placeholder { color: #6b7280; }
}
&.add-row {
margin-top: 0.25rem;
border: 1px dashed #2a2a3d;
border-radius: 6px;
padding: 0;
input {
border: none;
background: transparent;
&:focus { border: none; }
}
}
}
.btn-icon-ghost {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
background: transparent;
color: #6b7280;
border: none;
border-radius: 6px;
cursor: pointer;
transition: color 0.15s, background 0.15s;
&:hover { color: #fca5a5; background: #2a1f1f; }
}
.btn-add {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
margin-right: 0.4rem;
background: transparent;
color: #6c63ff;
border: none;
border-radius: 6px;
cursor: pointer;
transition: background 0.15s;
&:hover { background: #2a2a3d; }
}
.btn-primary, .btn-secondary, .btn-danger {
padding: 0.6rem 1.1rem;
border: none;
border-radius: 6px;
font-size: 0.88rem;
font-weight: 500;
cursor: pointer;
transition: background 0.15s, opacity 0.15s;
}
.btn-primary {
background: #6c63ff;
color: white;
&:hover:not(:disabled) { background: #5a52e0; }
&:disabled { opacity: 0.5; cursor: not-allowed; }
}
.btn-secondary {
background: #2a2a3d;
color: #d1d5db;
&:hover { background: #363650; }
}
.btn-danger {
background: #3f1f1f;
color: #fca5a5;
&:hover { background: #5a2a2a; }
}

View File

@@ -0,0 +1,119 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { forkJoin } from 'rxjs';
import { LucideAngularModule, Plus, X, Trash2 } from 'lucide-angular';
import { LoreService } from '../../services/lore.service';
import { TemplateService } from '../../services/template.service';
import { PageService } from '../../services/page.service';
import { LayoutService } from '../../services/layout.service';
import { PageTitleService } from '../../services/page-title.service';
import { LoreNode } from '../../services/lore.model';
import { Template } from '../../services/template.model';
import { loadLoreSidebarData, buildLoreSidebarConfig } from '../lore-sidebar.helper';
/**
* Écran d'édition d'un Template existant.
* Mêmes champs que la création + bouton Supprimer.
*/
@Component({
selector: 'app-template-edit',
standalone: true,
imports: [CommonModule, FormsModule, ReactiveFormsModule, LucideAngularModule],
templateUrl: './template-edit.component.html',
styleUrls: ['./template-edit.component.scss']
})
export class TemplateEditComponent implements OnInit, OnDestroy {
readonly Plus = Plus;
readonly X = X;
readonly Trash2 = Trash2;
form: FormGroup;
loreId = '';
templateId = '';
template: Template | null = null;
nodes: LoreNode[] = [];
fields: string[] = [];
newFieldName = '';
constructor(
private fb: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private loreService: LoreService,
private templateService: TemplateService,
private pageService: PageService,
private layoutService: LayoutService,
private pageTitleService: PageTitleService
) {
this.form = this.fb.group({
name: ['', Validators.required],
description: [''],
defaultNodeId: ['']
});
}
ngOnInit(): void {
this.loreId = this.route.snapshot.paramMap.get('loreId')!;
this.templateId = this.route.snapshot.paramMap.get('templateId')!;
forkJoin({
sidebar: loadLoreSidebarData(this.loreId, this.loreService, this.templateService, this.pageService),
template: this.templateService.getById(this.templateId)
}).subscribe(({ sidebar, template }) => {
this.nodes = sidebar.nodes;
this.layoutService.show(buildLoreSidebarConfig(sidebar));
this.hydrate(template);
});
}
private hydrate(template: Template): void {
this.template = template;
this.fields = [...template.fields];
this.form.patchValue({
name: template.name,
description: template.description,
defaultNodeId: template.defaultNodeId ?? ''
});
this.pageTitleService.set(template.name);
}
addField(): void {
const name = this.newFieldName.trim();
if (!name || this.fields.includes(name)) return;
this.fields = [...this.fields, name];
this.newFieldName = '';
}
removeField(index: number): void {
this.fields = this.fields.filter((_, i) => i !== index);
}
save(): void {
if (this.form.invalid || !this.template) return;
const raw = this.form.value;
this.templateService.update(this.templateId, {
...this.template,
name: raw.name,
description: raw.description,
defaultNodeId: raw.defaultNodeId || null,
fields: this.fields
}).subscribe({
next: () => this.router.navigate(['/lore', this.loreId]),
error: () => console.error('Erreur lors de la sauvegarde du template')
});
}
delete(): void {
if (!confirm(`Supprimer le template "${this.template?.name}" ?`)) return;
this.templateService.delete(this.templateId).subscribe({
next: () => this.router.navigate(['/lore', this.loreId]),
error: () => console.error('Erreur lors de la suppression du template')
});
}
ngOnDestroy(): void {
this.layoutService.hide();
}
}