Mentor d'écriture (M1-M3) : coach dans les champs, relecture d'éditeur, méthode guidée « Donjon en 5 salles »
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 13m48s
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 13m16s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 3m3s
Build & Push Images / build (core) (push) Successful in 4m50s
Build & Push Images / build (web) (push) Successful in 3m26s
Build & Push Images / build-switcher (push) Successful in 26s
Build & Push Images / build (brain) (push) Canceled after 1m5s
Qualité & Sécurité / MegaLinter (PMD · Ruff · Bandit · gitleaks · hadolint) (push) Successful in 13m48s
Qualité & Sécurité / Web (ESLint · angular-eslint + sonarjs) (push) Successful in 13m16s
Qualité & Sécurité / Trivy (CVE dépendances Maven / pip / npm) (push) Failing after 3m3s
Build & Push Images / build (core) (push) Successful in 4m50s
Build & Push Images / build (web) (push) Successful in 3m26s
Build & Push Images / build-switcher (push) Successful in 26s
Build & Push Images / build (brain) (push) Canceled after 1m5s
- M1 coach : bouton ampoule sur 17 champs narratifs (scène, chapitre, arc),
panneau de conseils (à quoi ça sert, questions, exemple, piège classique).
Contenu statique i18n fr/en, sans IA ; ampoule aussi dans l'en-tête des
sections repliables (input coachTopic d'expandable-section).
- M2 relecture d'éditeur : WritingReviewService + GET
/api/campaigns/{id}/writing-review, 10 règles déterministes WRITE-001 à 010
(couloir, faux choix, révélation à chemin unique, rythme monotone, enjeux
absents, narration trop longue ou qui décide à la place des PJ, combat sans
but, fin unique, scènes non typées). Le back renvoie ruleId + params, les
textes fr/en sont dans l'i18n. Panneau sur le hub, encart dans les éditeurs,
liens « Voir » avec ?focus= (nouveaux focus : narration, choices, stakes).
- M3 méthode guidée : POST /api/campaigns/{id}/guided-skeleton (arc existant
ou nouveau, chapitre, scènes typées, chaînage optionnel, transactionnel)
+ assistant pas à pas générique /campaigns/:id/guided/:method, première
méthode « Donjon en 5 salles ». Entrées sur le hub de campagne.
- Garde-fous vitest : complétude des textes fr/en du coach, de la relecture
(règles lues dans le Java) et des méthodes guidées.
Vérifié : core clean verify (1182 tests), web build + 299 tests vitest, lint
sans erreur, parcours testés dans l'appli (back Postgres de dev).
À redéployer : core (2 endpoints, aucune migration) + web.
This commit is contained in:
@@ -23,3 +23,4 @@
|
||||
|
||||
<app-global-search></app-global-search>
|
||||
<app-confirm-dialog-host></app-confirm-dialog-host>
|
||||
<app-writing-coach-panel></app-writing-coach-panel>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { SecondarySidebarComponent } from './shared/secondary-sidebar/secondary-
|
||||
import { GlobalSearchComponent } from './shared/global-search/global-search.component';
|
||||
import { UpdateBannerComponent } from './shared/update-banner/update-banner.component';
|
||||
import { ConfirmDialogHostComponent } from './shared/confirm-dialog/confirm-dialog-host.component';
|
||||
import { WritingCoachPanelComponent } from './shared/writing-coach/writing-coach-panel.component';
|
||||
import { LayoutService } from './services/layout.service';
|
||||
import { GlobalSearchService } from './services/global-search.service';
|
||||
import { VersionCheckerService } from './services/version-checker.service';
|
||||
@@ -19,6 +20,7 @@ import { VersionCheckerService } from './services/version-checker.service';
|
||||
GlobalSearchComponent,
|
||||
UpdateBannerComponent,
|
||||
ConfirmDialogHostComponent,
|
||||
WritingCoachPanelComponent,
|
||||
AsyncPipe
|
||||
],
|
||||
templateUrl: './app.component.html',
|
||||
|
||||
@@ -45,6 +45,7 @@ export const routes: Routes = [
|
||||
{ path: 'campaigns/:campaignId/random-tables/:tableId/edit', loadComponent: () => import('./campaigns/random-table/random-table-edit/random-table-edit.component').then(m => m.RandomTableEditComponent) },
|
||||
{ path: 'campaigns/:campaignId/random-tables/:tableId', loadComponent: () => import('./campaigns/random-table/random-table-view/random-table-view.component').then(m => m.RandomTableViewComponent) },
|
||||
{ path: 'campaigns/:campaignId/arcs/create', loadComponent: () => import('./campaigns/arc/arc-create/arc-create.component').then(m => m.ArcCreateComponent) },
|
||||
{ path: 'campaigns/:campaignId/guided/:method', loadComponent: () => import('./campaigns/guided/guided-wizard/guided-wizard.component').then(m => m.GuidedWizardComponent) },
|
||||
{ path: 'campaigns/:campaignId/arcs/:arcId', loadComponent: () => import('./campaigns/arc/arc-view/arc-view.component').then(m => m.ArcViewComponent) },
|
||||
{ path: 'campaigns/:campaignId/arcs/:arcId/edit', loadComponent: () => import('./campaigns/arc/arc-edit/arc-edit.component').then(m => m.ArcEditComponent) },
|
||||
{ path: 'campaigns/:campaignId/arcs/:arcId/chapters/create', loadComponent: () => import('./campaigns/chapter/chapter-create/chapter-create.component').then(m => m.ChapterCreateComponent) },
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<!-- Tout est optionnel sauf le titre : identité visible, le reste replié. -->
|
||||
<p class="optional-hint">{{ 'arcEdit.optionalHint' | translate }}</p>
|
||||
|
||||
<!-- Mentor d'écriture (M2) : conseils de relecture qui concernent cette entité. -->
|
||||
<app-writing-review-hints [campaignId]="campaignId" entityType="ARC" [entityId]="arcId"></app-writing-review-hints>
|
||||
|
||||
<!-- Co-création (Pilier A) : le co-MJ propose, validation champ par champ → remplit le formulaire. -->
|
||||
<app-entity-assist-panel
|
||||
[entityType]="'arc'" [entityId]="arcId" [campaignId]="campaignId"
|
||||
@@ -47,7 +50,10 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="arc-edit-description">{{ 'arcEdit.synopsisLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-description">{{ 'arcEdit.synopsisLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.synopsis"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-description"
|
||||
formControlName="description"
|
||||
@@ -89,10 +95,13 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Thèmes et enjeux -->
|
||||
<app-expandable-section [title]="'arcEdit.themesStakesSectionTitle' | translate" icon="🎭" [filled]="themesStakesFilled">
|
||||
<app-expandable-section [title]="'arcEdit.themesStakesSectionTitle' | translate" icon="🎭" [initiallyOpen]="focusSection === 'stakes'" [filled]="themesStakesFilled">
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="arc-edit-themes">{{ 'arcEdit.themesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-themes">{{ 'arcEdit.themesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.themes"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-themes"
|
||||
formControlName="themes"
|
||||
@@ -101,7 +110,10 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="arc-edit-stakes">{{ 'arcEdit.stakesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-stakes">{{ 'arcEdit.stakesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.stakes"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-stakes"
|
||||
formControlName="stakes"
|
||||
@@ -129,7 +141,10 @@
|
||||
<!-- Récompenses et dénouement -->
|
||||
<app-expandable-section [title]="'arcEdit.rewardsResolutionSectionTitle' | translate" icon="🎁" [filled]="rewardsResolutionFilled">
|
||||
<div class="field">
|
||||
<label for="arc-edit-rewards">{{ 'arcEdit.rewardsLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-rewards">{{ 'arcEdit.rewardsLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.rewards"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-rewards"
|
||||
formControlName="rewards"
|
||||
@@ -138,7 +153,10 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="arc-edit-resolution">{{ 'arcEdit.resolutionLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="arc-edit-resolution">{{ 'arcEdit.resolutionLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="arc.resolution"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="arc-edit-resolution"
|
||||
formControlName="resolution"
|
||||
|
||||
@@ -26,6 +26,8 @@ import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
|
||||
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
|
||||
import { EntityAssistPanelComponent } from '../../../shared/entity-assist-panel/entity-assist-panel.component';
|
||||
import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { WritingReviewHintsComponent } from '../../../shared/writing-review/writing-review-hints.component';
|
||||
|
||||
/**
|
||||
* Écran de détail/modification d'un Arc.
|
||||
@@ -38,7 +40,7 @@ import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-arc-edit',
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, LoreLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, ExpandableSectionComponent, EntityAssistPanelComponent, TranslatePipe],
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, LoreLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, ExpandableSectionComponent, EntityAssistPanelComponent, TranslatePipe, WritingCoachTriggerComponent, WritingReviewHintsComponent],
|
||||
templateUrl: './arc-edit.component.html',
|
||||
styleUrls: ['./arc-edit.component.scss']
|
||||
})
|
||||
@@ -74,6 +76,9 @@ export class ArcEditComponent implements OnInit {
|
||||
arcId = '';
|
||||
arc: Arc | null = null;
|
||||
|
||||
/** `?focus=stakes` (lien « Voir » de la relecture d'éditeur) → section dépliée d'office. */
|
||||
focusSection: string | null = null;
|
||||
|
||||
/** Pages disponibles pour le picker (vide si la campagne n'a pas de loreId). */
|
||||
availablePages: Page[] = [];
|
||||
/** ID du Lore associé à la campagne (null si campagne sans univers). */
|
||||
@@ -135,6 +140,7 @@ export class ArcEditComponent implements OnInit {
|
||||
if (newArcId !== this.arcId || newCampaignId !== this.campaignId) {
|
||||
this.campaignId = newCampaignId;
|
||||
this.arcId = newArcId;
|
||||
this.focusSection = this.route.snapshot.queryParamMap.get('focus');
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -62,6 +62,8 @@
|
||||
<!-- ============ Guidage co-MJ : « Prochaines étapes » (Pilier B) ============ -->
|
||||
@if (!editing && campaign.id) {
|
||||
<app-readiness-panel [campaignId]="campaign.id" [assessment]="readiness"></app-readiness-panel>
|
||||
<!-- Mentor d'écriture (M2) : conseils d'auteur sur la qualité, à côté de la complétude. -->
|
||||
<app-writing-review-panel [campaignId]="campaign.id"></app-writing-review-panel>
|
||||
}
|
||||
<!-- ============ Header : mode édition inline ============ -->
|
||||
@if (editing) {
|
||||
@@ -206,6 +208,11 @@
|
||||
<lucide-icon [img]="Plus" [size]="14"></lucide-icon>
|
||||
{{ 'campaignDetail.newArc' | translate }}
|
||||
</button>
|
||||
<!-- Mentor d'écriture (M3) : écrire une aventure question par question. -->
|
||||
<a class="btn-add btn-guided" [routerLink]="['/campaigns', campaign.id, 'guided', 'five-room']">
|
||||
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||
{{ 'guided.entry' | translate }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@if (arcs.length > 0 && !showQuickAddScene) {
|
||||
@@ -235,6 +242,10 @@
|
||||
<lucide-icon [img]="Plus" [size]="14"></lucide-icon>
|
||||
{{ 'campaignDetail.quickSceneFirst' | translate }}
|
||||
</button>
|
||||
<a class="btn-add-first btn-guided" [routerLink]="['/campaigns', campaign.id, 'guided', 'five-room']">
|
||||
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||
{{ 'guided.entryFirst' | translate }}
|
||||
</a>
|
||||
<button type="button" class="empty-alt-action" (click)="createArc()">
|
||||
{{ 'campaignDetail.organizeInArcs' | translate }}
|
||||
</button>
|
||||
|
||||
@@ -486,6 +486,18 @@
|
||||
&:hover { background: #5b52e0; }
|
||||
}
|
||||
|
||||
// Entrée « Méthode guidée » (Mentor d'écriture, M3) : un lien stylé en bouton,
|
||||
// accent ambré du mentor pour le distinguer des créations « à la main ».
|
||||
.btn-guided {
|
||||
text-decoration: none;
|
||||
background: rgba(251, 191, 36, 0.12);
|
||||
color: #fde68a;
|
||||
border: 1px solid rgba(251, 191, 36, 0.35);
|
||||
|
||||
&:hover { background: rgba(251, 191, 36, 0.2); }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; outline-offset: 2px; }
|
||||
}
|
||||
|
||||
// Action secondaire de l'état vide (« ou créer un arc ») — bouton texte discret.
|
||||
.empty-alt-action {
|
||||
background: none;
|
||||
|
||||
@@ -32,11 +32,12 @@ import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dia
|
||||
import { FolderGroup, groupByFolder, byOrder } from '../../../shared/folder-grouping.util';
|
||||
import { CampaignReadinessAssessment } from '../../../services/readiness.model';
|
||||
import { ReadinessPanelComponent } from '../../../shared/readiness-panel/readiness-panel.component';
|
||||
import { WritingReviewPanelComponent } from '../../../shared/writing-review/writing-review-panel.component';
|
||||
import { FoundryExportDialogComponent } from '../foundry-export-dialog/foundry-export-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-campaign-detail',
|
||||
imports: [FormsModule, LucideAngularModule, RouterLink, TranslatePipe, CdkDropList, CdkDrag, ReadinessPanelComponent, FoundryExportDialogComponent],
|
||||
imports: [FormsModule, LucideAngularModule, RouterLink, TranslatePipe, CdkDropList, CdkDrag, ReadinessPanelComponent, WritingReviewPanelComponent, FoundryExportDialogComponent],
|
||||
templateUrl: './campaign-detail.component.html',
|
||||
styleUrls: ['./campaign-detail.component.scss']
|
||||
})
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
<!-- Tout est optionnel sauf le titre : identité visible, le reste replié. -->
|
||||
<p class="optional-hint">{{ 'chapterEdit.optionalHint' | translate }}</p>
|
||||
|
||||
<!-- Mentor d'écriture (M2) : conseils de relecture qui concernent cette entité. -->
|
||||
<app-writing-review-hints [campaignId]="campaignId" entityType="CHAPTER" [entityId]="chapterId"></app-writing-review-hints>
|
||||
|
||||
<!-- Co-création (Pilier A) : le co-MJ propose, validation champ par champ → remplit le formulaire. -->
|
||||
<app-entity-assist-panel
|
||||
[entityType]="'chapter'" [entityId]="chapterId" [campaignId]="campaignId"
|
||||
@@ -53,7 +56,10 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="chapter-edit-description">{{ 'chapterEdit.synopsisLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="chapter-edit-description">{{ 'chapterEdit.synopsisLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="chapter.synopsis"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="chapter-edit-description"
|
||||
formControlName="description"
|
||||
@@ -93,10 +99,13 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Objectifs et enjeux -->
|
||||
<app-expandable-section [title]="'chapterEdit.objectivesStakesSectionTitle' | translate" icon="🎯" [filled]="objectivesStakesFilled">
|
||||
<app-expandable-section [title]="'chapterEdit.objectivesStakesSectionTitle' | translate" icon="🎯" [initiallyOpen]="focusSection === 'stakes'" [filled]="objectivesStakesFilled">
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="chapter-edit-player-objectives">{{ 'chapterEdit.playerObjectivesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="chapter-edit-player-objectives">{{ 'chapterEdit.playerObjectivesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="chapter.objectives"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="chapter-edit-player-objectives"
|
||||
formControlName="playerObjectives"
|
||||
@@ -105,7 +114,10 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="chapter-edit-narrative-stakes">{{ 'chapterEdit.narrativeStakesLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="chapter-edit-narrative-stakes">{{ 'chapterEdit.narrativeStakesLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="chapter.stakes"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="chapter-edit-narrative-stakes"
|
||||
formControlName="narrativeStakes"
|
||||
|
||||
@@ -27,6 +27,8 @@ import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dia
|
||||
import { EntityAssistPanelComponent } from '../../../shared/entity-assist-panel/entity-assist-panel.component';
|
||||
import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
import { SceneDraftPanelComponent } from '../../../shared/scene-draft-panel/scene-draft-panel.component';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { WritingReviewHintsComponent } from '../../../shared/writing-review/writing-review-hints.component';
|
||||
|
||||
/**
|
||||
* Écran d'édition d'un Chapitre. Donnée de SCÉNARIO uniquement.
|
||||
@@ -47,7 +49,8 @@ import { SceneDraftPanelComponent } from '../../../shared/scene-draft-panel/scen
|
||||
ExpandableSectionComponent,
|
||||
EntityAssistPanelComponent,
|
||||
SceneDraftPanelComponent,
|
||||
TranslatePipe
|
||||
TranslatePipe,
|
||||
WritingCoachTriggerComponent, WritingReviewHintsComponent
|
||||
],
|
||||
templateUrl: './chapter-edit.component.html',
|
||||
styleUrls: ['./chapter-edit.component.scss']
|
||||
@@ -88,6 +91,9 @@ export class ChapterEditComponent implements OnInit {
|
||||
/** `?assist=draft-scenes` (bouton « Corriger » du guidage) → panneau IA déployé d'office. */
|
||||
assistParam: string | null = null;
|
||||
|
||||
/** `?focus=stakes` (lien « Voir » de la relecture d'éditeur) → section dépliée d'office. */
|
||||
focusSection: string | null = null;
|
||||
|
||||
availablePages: Page[] = [];
|
||||
loreId: string | null = null;
|
||||
relatedPageIds: string[] = [];
|
||||
@@ -144,6 +150,7 @@ export class ChapterEditComponent implements OnInit {
|
||||
this.arcId = newArcId;
|
||||
this.chapterId = newChapterId;
|
||||
this.assistParam = this.route.snapshot.queryParamMap.get('assist');
|
||||
this.focusSection = this.route.snapshot.queryParamMap.get('focus');
|
||||
this.loadAll();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { GuidedChapterSpec, GuidedSceneSpec } from '../../services/guided-skeleton.model';
|
||||
|
||||
/**
|
||||
* Définition d'une méthode guidée (Mentor d'écriture, phases M3/M5). L'assistant
|
||||
* `guided-wizard` est générique : il affiche les étapes d'une méthode et lui délègue
|
||||
* la construction du squelette. Ajouter une méthode = un fichier de définition + ses
|
||||
* textes i18n (`guided.<i18nKey>.*`) + son entrée dans `GUIDED_METHODS`.
|
||||
*
|
||||
* Conventions i18n (préfixe `guided.<i18nKey>.`) :
|
||||
* - `name`, `tagline` : présentation de la méthode ;
|
||||
* - `steps.<stepId>.title|why|example` : chaque étape (pourquoi + exemple, posture mentor) ;
|
||||
* - `fields.<fieldKey>.label|placeholder` : chaque champ (`fieldKey` peut contenir des points) ;
|
||||
* - `options.<fieldKey>.<option>` : libellés des choix ;
|
||||
* - `defaults.<fieldKey>` : valeur proposée d'office (ex. nom d'une salle).
|
||||
*/
|
||||
|
||||
/** Réponses du MJ, par clé de champ. */
|
||||
export type GuidedAnswers = Record<string, string>;
|
||||
|
||||
export interface GuidedField {
|
||||
key: string;
|
||||
kind: 'text' | 'textarea' | 'choice';
|
||||
required?: boolean;
|
||||
/** Valeurs possibles d'un champ `choice` (la 1re est sélectionnée par défaut). */
|
||||
options?: string[];
|
||||
/** Pré-remplir avec `defaults.<key>` (traduit) à la première visite. */
|
||||
prefilled?: boolean;
|
||||
/** Sujet du coach d'écriture (💡) associé, ex. `scene.choices`. */
|
||||
coachTopic?: string;
|
||||
}
|
||||
|
||||
export interface GuidedStep {
|
||||
id: string;
|
||||
/** `placement` : où ranger l'aventure ; `form` : questions ; `review` : récapitulatif. */
|
||||
kind: 'placement' | 'form' | 'review';
|
||||
fields?: GuidedField[];
|
||||
}
|
||||
|
||||
/** Ce que la méthode produit à partir des réponses (le placement est ajouté par l'assistant). */
|
||||
export interface GuidedDraft {
|
||||
chapter: GuidedChapterSpec;
|
||||
scenes: GuidedSceneSpec[];
|
||||
}
|
||||
|
||||
export interface GuidedMethod {
|
||||
/** Identifiant d'URL (`/campaigns/:id/guided/:method`). */
|
||||
id: string;
|
||||
/** Préfixe i18n sous `guided.`. */
|
||||
i18nKey: string;
|
||||
steps: GuidedStep[];
|
||||
toDraft(answers: GuidedAnswers): GuidedDraft;
|
||||
}
|
||||
|
||||
/** Valeur nettoyée d'une réponse (chaîne vide → null). */
|
||||
export function answer(answers: GuidedAnswers, key: string): string | null {
|
||||
const value = answers[key]?.trim();
|
||||
return value ? value : null;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { GuidedField, GuidedStep } from './guided-method.model';
|
||||
import { GUIDED_METHODS } from './guided-methods';
|
||||
import { FIVE_ROOM_METHOD } from './methods/five-room.method';
|
||||
|
||||
/**
|
||||
* Garde-fous des méthodes guidées : chaque étape / champ / option / valeur par défaut
|
||||
* a son texte en fr ET en en (sinon l'assistant afficherait des clés brutes), et la
|
||||
* méthode « 5 salles » produit le bon squelette.
|
||||
*/
|
||||
const FRAGMENTS_DIR = join(process.cwd(), 'src/assets/i18n/fragments');
|
||||
|
||||
function i18n(lang: 'fr' | 'en'): Record<string, unknown> {
|
||||
return JSON.parse(readFileSync(join(FRAGMENTS_DIR, `guided.${lang}.json`), 'utf-8')).guided;
|
||||
}
|
||||
|
||||
function lookup(root: Record<string, unknown>, path: string): unknown {
|
||||
return path.split('.').reduce<unknown>((node, part) =>
|
||||
node && typeof node === 'object' ? (node as Record<string, unknown>)[part] : undefined, root);
|
||||
}
|
||||
|
||||
function fieldKeys(p: string, f: GuidedField): string[] {
|
||||
return [
|
||||
`${p}.fields.${f.key}.label`,
|
||||
...(f.kind === 'choice' ? [] : [`${p}.fields.${f.key}.placeholder`]),
|
||||
...(f.options ?? []).map(o => `${p}.options.${f.key}.${o}`),
|
||||
...(f.prefilled ? [`${p}.defaults.${f.key}`] : [])
|
||||
];
|
||||
}
|
||||
|
||||
function stepKeys(p: string, step: GuidedStep): string[] {
|
||||
return [
|
||||
`${p}.steps.${step.id}.title`,
|
||||
`${p}.steps.${step.id}.why`,
|
||||
...(step.kind === 'review' ? [] : [`${p}.steps.${step.id}.example`]),
|
||||
...(step.fields ?? []).flatMap(f => fieldKeys(p, f))
|
||||
];
|
||||
}
|
||||
|
||||
function requiredKeys(): string[] {
|
||||
return GUIDED_METHODS.flatMap(m => [`${m.i18nKey}.name`, ...m.steps.flatMap(s => stepKeys(m.i18nKey, s))]);
|
||||
}
|
||||
|
||||
describe('guided methods content', () => {
|
||||
const keys = requiredKeys();
|
||||
|
||||
for (const lang of ['fr', 'en'] as const) {
|
||||
it.each(keys)(`${lang}: guided.%s is a non-empty text`, key => {
|
||||
const value = lookup(i18n(lang), key);
|
||||
expect(typeof value === 'string' && value.trim().length > 0, `guided.${key} (${lang})`).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('has unique method ids and step ids', () => {
|
||||
expect(new Set(GUIDED_METHODS.map(m => m.id)).size).toBe(GUIDED_METHODS.length);
|
||||
for (const m of GUIDED_METHODS) {
|
||||
expect(new Set(m.steps.map(s => s.id)).size).toBe(m.steps.length);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('five-room method', () => {
|
||||
const answers = {
|
||||
title: ' Le reliquaire volé ',
|
||||
location: 'La crypte',
|
||||
hook: 'Le prêtre a disparu',
|
||||
objectives: 'Ramener la relique',
|
||||
stakes: '',
|
||||
'room1.name': "L'entrée gardée",
|
||||
'room1.nature': 'social',
|
||||
'room1.choices': 'Convaincre ou ruser',
|
||||
'room2.name': "L'épreuve",
|
||||
'room2.nature': 'puzzle',
|
||||
'room3.name': 'Le revers',
|
||||
'room4.name': 'Le climax',
|
||||
'room4.enemies': "L'envoûteuse",
|
||||
'room5.name': 'La récompense',
|
||||
'room5.secret': 'Le symbole de la confrérie'
|
||||
};
|
||||
|
||||
it('builds the chapter from the frame and stakes answers', () => {
|
||||
expect(FIVE_ROOM_METHOD.toDraft(answers).chapter).toEqual({
|
||||
name: 'Le reliquaire volé',
|
||||
description: 'Le prêtre a disparu',
|
||||
playerObjectives: 'Ramener la relique',
|
||||
narrativeStakes: null
|
||||
});
|
||||
});
|
||||
|
||||
it('builds five typed scenes in the same place', () => {
|
||||
const scenes = FIVE_ROOM_METHOD.toDraft(answers).scenes;
|
||||
expect(scenes.map(s => s.type)).toEqual(['NPC', 'LOCATION', 'EVENT', 'ENCOUNTER', 'REVELATION']);
|
||||
expect(scenes.every(s => s.location === 'La crypte')).toBe(true);
|
||||
expect(scenes[0].choicesConsequences).toBe('Convaincre ou ruser');
|
||||
expect(scenes[3].enemies).toBe("L'envoûteuse");
|
||||
expect(scenes[4].gmSecretNotes).toBe('Le symbole de la confrérie');
|
||||
});
|
||||
|
||||
it('defaults room 1 to a fight when no nature was chosen', () => {
|
||||
expect(FIVE_ROOM_METHOD.toDraft({}).scenes[0].type).toBe('ENCOUNTER');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { GuidedMethod } from './guided-method.model';
|
||||
import { FIVE_ROOM_METHOD } from './methods/five-room.method';
|
||||
|
||||
/** Méthodes guidées disponibles (M5 : préparation minimale, enquête, casse, bac à sable…). */
|
||||
export const GUIDED_METHODS: GuidedMethod[] = [FIVE_ROOM_METHOD];
|
||||
|
||||
export function findGuidedMethod(id: string | null): GuidedMethod | undefined {
|
||||
return GUIDED_METHODS.find(m => m.id === id);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
@if (method && step) {
|
||||
<div class="wizard">
|
||||
|
||||
<header class="wizard-top">
|
||||
<a class="wizard-back" [routerLink]="['/campaigns', campaignId]">
|
||||
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
|
||||
{{ 'guided.backToCampaign' | translate }}
|
||||
</a>
|
||||
<div class="wizard-method">
|
||||
<lucide-icon [img]="Sparkles" [size]="14"></lucide-icon>
|
||||
{{ k('name') | translate }}
|
||||
</div>
|
||||
<div class="wizard-progress" role="progressbar"
|
||||
[attr.aria-valuenow]="stepIndex + 1" aria-valuemin="1" [attr.aria-valuemax]="total"
|
||||
[attr.aria-label]="'guided.progress' | translate: { n: stepIndex + 1, total: total }">
|
||||
<span class="progress-text">{{ 'guided.progress' | translate: { n: stepIndex + 1, total: total } }}</span>
|
||||
<span class="progress-track"><span class="progress-fill" [style.width.%]="progress"></span></span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="wizard-step">
|
||||
<h1 #stepTitle tabindex="-1">{{ k('steps.' + step.id + '.title') | translate }}</h1>
|
||||
<p class="step-why">{{ k('steps.' + step.id + '.why') | translate }}</p>
|
||||
|
||||
@if (step.kind !== 'review') {
|
||||
<aside class="step-example">
|
||||
<span class="example-label">{{ 'guided.exampleLabel' | translate }}</span>
|
||||
<p>{{ k('steps.' + step.id + '.example') | translate }}</p>
|
||||
</aside>
|
||||
}
|
||||
|
||||
<!-- Où ranger l'aventure -->
|
||||
@if (step.kind === 'placement') {
|
||||
<fieldset class="placement">
|
||||
<legend class="sr-only">{{ k('steps.placement.title') | translate }}</legend>
|
||||
@if (linearArcs.length > 0) {
|
||||
<label class="option-card" [class.selected]="answers['placement.mode'] === 'existing'">
|
||||
<input type="radio" name="placement-mode" value="existing"
|
||||
[ngModel]="answers['placement.mode']" (ngModelChange)="setAnswer('placement.mode', $event)" />
|
||||
<span>{{ 'guided.placementExisting' | translate }}</span>
|
||||
</label>
|
||||
@if (answers['placement.mode'] === 'existing') {
|
||||
<div class="field nested">
|
||||
<label for="guided-arc">{{ 'guided.placementArcLabel' | translate }}</label>
|
||||
<select id="guided-arc" [ngModel]="answers['placement.arcId']"
|
||||
(ngModelChange)="setAnswer('placement.arcId', $event)">
|
||||
@for (arc of linearArcs; track arc.id) {
|
||||
<option [value]="arc.id">{{ arc.name }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
<label class="option-card" [class.selected]="answers['placement.mode'] === 'new'">
|
||||
<input type="radio" name="placement-mode" value="new"
|
||||
[ngModel]="answers['placement.mode']" (ngModelChange)="setAnswer('placement.mode', $event)" />
|
||||
<span>{{ 'guided.placementNew' | translate }}</span>
|
||||
</label>
|
||||
@if (answers['placement.mode'] === 'new') {
|
||||
<div class="field nested">
|
||||
<label for="guided-new-arc">{{ 'guided.placementNewArcLabel' | translate }} *</label>
|
||||
<input id="guided-new-arc" type="text" [ngModel]="answers['placement.newArcName']"
|
||||
(ngModelChange)="setAnswer('placement.newArcName', $event)"
|
||||
[placeholder]="'guided.placementNewArcPlaceholder' | translate" />
|
||||
</div>
|
||||
}
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
<!-- Questions de l'étape -->
|
||||
@if (step.kind === 'form') {
|
||||
<div class="step-fields">
|
||||
@for (field of step.fields; track field.key) {
|
||||
@if (field.kind === 'choice') {
|
||||
<fieldset class="field choice-field">
|
||||
<legend>{{ k('fields.' + field.key + '.label') | translate }}</legend>
|
||||
<div class="choice-row">
|
||||
@for (option of field.options; track option) {
|
||||
<label class="choice-chip" [class.selected]="answers[field.key] === option">
|
||||
<!-- attr.* : name/value doivent exister dans le DOM (groupe radio natif,
|
||||
navigation clavier) ; [value] seul est consommé par le ControlValueAccessor. -->
|
||||
<input type="radio" [attr.name]="fieldId(field)" [attr.value]="option" [value]="option"
|
||||
[ngModel]="answers[field.key]" (ngModelChange)="setAnswer(field.key, $event)" />
|
||||
{{ k('options.' + field.key + '.' + option) | translate }}
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
} @else {
|
||||
<div class="field">
|
||||
<div class="field-label-row">
|
||||
<label [for]="fieldId(field)">
|
||||
{{ k('fields.' + field.key + '.label') | translate }}@if (field.required) { * }
|
||||
</label>
|
||||
@if (field.coachTopic) {
|
||||
<app-writing-coach-trigger [topic]="field.coachTopic"></app-writing-coach-trigger>
|
||||
}
|
||||
</div>
|
||||
@if (field.kind === 'textarea') {
|
||||
<textarea [id]="fieldId(field)" rows="3"
|
||||
[ngModel]="answers[field.key]" (ngModelChange)="setAnswer(field.key, $event)"
|
||||
[placeholder]="k('fields.' + field.key + '.placeholder') | translate"></textarea>
|
||||
} @else {
|
||||
<input [id]="fieldId(field)" type="text"
|
||||
[ngModel]="answers[field.key]" (ngModelChange)="setAnswer(field.key, $event)"
|
||||
[placeholder]="k('fields.' + field.key + '.placeholder') | translate" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Récapitulatif -->
|
||||
@if (step.kind === 'review' && draft; as d) {
|
||||
<div class="review">
|
||||
<dl class="review-meta">
|
||||
<dt>{{ 'guided.reviewArc' | translate }}</dt>
|
||||
<dd>{{ placementLabel }}</dd>
|
||||
<dt>{{ 'guided.reviewChapter' | translate }}</dt>
|
||||
<dd>{{ d.chapter.name }}</dd>
|
||||
</dl>
|
||||
<ol class="review-scenes">
|
||||
@for (scene of d.scenes; track $index) {
|
||||
<li>
|
||||
<span class="scene-name">{{ scene.name }}</span>
|
||||
<span class="scene-type">{{ ('sceneType.' + scene.type) | translate }}</span>
|
||||
</li>
|
||||
}
|
||||
</ol>
|
||||
<label class="link-toggle">
|
||||
<input type="checkbox" [(ngModel)]="linkScenes" />
|
||||
{{ 'guided.linkScenes' | translate }}
|
||||
</label>
|
||||
<p class="review-after">{{ 'guided.reviewAfter' | translate }}</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (error) {
|
||||
<p class="wizard-error" role="alert">{{ error }}</p>
|
||||
}
|
||||
</main>
|
||||
|
||||
<footer class="wizard-nav">
|
||||
<button type="button" class="btn-secondary" (click)="previous()" [disabled]="stepIndex === 0">
|
||||
<lucide-icon [img]="ArrowLeft" [size]="14"></lucide-icon>
|
||||
{{ 'guided.previous' | translate }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost" (click)="restart()">
|
||||
<lucide-icon [img]="RotateCcw" [size]="14"></lucide-icon>
|
||||
{{ 'guided.restart' | translate }}
|
||||
</button>
|
||||
@if (isLast) {
|
||||
<button type="button" class="btn-primary" (click)="create()" [disabled]="submitting">
|
||||
<lucide-icon [img]="Check" [size]="14"></lucide-icon>
|
||||
{{ (submitting ? 'guided.creating' : 'guided.create') | translate }}
|
||||
</button>
|
||||
} @else {
|
||||
<button type="button" class="btn-primary" (click)="next()" [disabled]="!canProceed()">
|
||||
{{ 'guided.next' | translate }}
|
||||
<lucide-icon [img]="ArrowRight" [size]="14"></lucide-icon>
|
||||
</button>
|
||||
}
|
||||
</footer>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="wizard">
|
||||
<p class="wizard-error">{{ 'guided.unknownMethod' | translate }}</p>
|
||||
<a [routerLink]="['/campaigns', campaignId]">{{ 'guided.backToCampaign' | translate }}</a>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
// Une étape par écran, colonne unique et étroite : lisible sur ordinateur comme
|
||||
// sur téléphone (la barre de navigation reste collée en bas de l'écran).
|
||||
.wizard {
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
padding: 1.5rem 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.wizard-top {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.6rem 1rem;
|
||||
}
|
||||
|
||||
.wizard-back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover { color: #e5e7eb; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; outline-offset: 2px; border-radius: 4px; }
|
||||
}
|
||||
|
||||
.wizard-method {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
color: #fbbf24;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.wizard-progress {
|
||||
flex-basis: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.progress-text {
|
||||
flex-shrink: 0;
|
||||
font-size: 0.8rem;
|
||||
color: #9ca3af;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.progress-track {
|
||||
flex: 1;
|
||||
height: 6px;
|
||||
border-radius: 999px;
|
||||
background: #1f2937;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: #6c63ff;
|
||||
border-radius: 999px;
|
||||
transition: width 0.25s ease;
|
||||
}
|
||||
|
||||
.wizard-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.1rem;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
color: white;
|
||||
text-wrap: balance;
|
||||
|
||||
&:focus { outline: none; }
|
||||
}
|
||||
}
|
||||
|
||||
.step-why {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.6;
|
||||
color: #d1d5db;
|
||||
}
|
||||
|
||||
.step-example {
|
||||
padding: 0.85rem 1rem;
|
||||
border-radius: 8px;
|
||||
background: rgba(108, 99, 255, 0.08);
|
||||
border: 1px solid rgba(108, 99, 255, 0.25);
|
||||
|
||||
p {
|
||||
margin: 0.3rem 0 0;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.55;
|
||||
font-style: italic;
|
||||
color: #d1d5db;
|
||||
}
|
||||
}
|
||||
|
||||
.example-label {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #a5b4fc;
|
||||
}
|
||||
|
||||
.step-fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.1rem;
|
||||
}
|
||||
|
||||
// --- Placement & choix ---------------------------------------------------------------
|
||||
|
||||
.placement {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.option-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.7rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #374151;
|
||||
background: #111827;
|
||||
color: #e5e7eb;
|
||||
font-size: 0.92rem;
|
||||
cursor: pointer;
|
||||
|
||||
&.selected { border-color: #6c63ff; background: rgba(108, 99, 255, 0.1); }
|
||||
input { accent-color: #6c63ff; width: 18px; height: 18px; margin: 0; }
|
||||
}
|
||||
|
||||
.nested {
|
||||
margin: 0 0 0.4rem 1.6rem;
|
||||
}
|
||||
|
||||
.choice-field {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
|
||||
legend {
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #d1d5db;
|
||||
}
|
||||
}
|
||||
|
||||
.choice-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.choice-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
min-height: 44px;
|
||||
padding: 0 1rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #374151;
|
||||
background: #111827;
|
||||
color: #d1d5db;
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
|
||||
&.selected { border-color: #6c63ff; color: white; background: rgba(108, 99, 255, 0.15); }
|
||||
input { accent-color: #6c63ff; margin: 0; }
|
||||
&:focus-within { outline: 2px solid #6c63ff; outline-offset: 2px; }
|
||||
}
|
||||
|
||||
// --- Récapitulatif --------------------------------------------------------------------
|
||||
|
||||
.review {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.review-meta {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 0.4rem 1rem;
|
||||
margin: 0;
|
||||
|
||||
dt { color: #9ca3af; font-size: 0.85rem; }
|
||||
dd { margin: 0; color: #f3f4f6; font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
|
||||
}
|
||||
|
||||
.review-scenes {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
counter-reset: scene;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.45rem;
|
||||
|
||||
li {
|
||||
counter-increment: scene;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.7rem 0.9rem;
|
||||
border-radius: 8px;
|
||||
background: #111827;
|
||||
border: 1px solid #1f2937;
|
||||
|
||||
&::before {
|
||||
content: counter(scene);
|
||||
flex-shrink: 0;
|
||||
width: 1.6rem;
|
||||
height: 1.6rem;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: #1f2937;
|
||||
color: #a5b4fc;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scene-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: #f3f4f6;
|
||||
font-size: 0.9rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.scene-type {
|
||||
flex-shrink: 0;
|
||||
padding: 0.1rem 0.55rem;
|
||||
border-radius: 999px;
|
||||
background: #1f2937;
|
||||
color: #9ca3af;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.link-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
color: #d1d5db;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
|
||||
input { accent-color: #6c63ff; width: 18px; height: 18px; margin: 0; }
|
||||
}
|
||||
|
||||
.review-after {
|
||||
margin: 0;
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.wizard-error {
|
||||
margin: 0;
|
||||
color: #fca5a5;
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
// --- Navigation -------------------------------------------------------------------------
|
||||
|
||||
.wizard-nav {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
margin-top: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem 0;
|
||||
background: #0a0a14;
|
||||
border-top: 1px solid #1f2937;
|
||||
|
||||
.btn-primary { margin-left: auto; }
|
||||
|
||||
button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
padding: 0.6rem 0.8rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
font-size: 0.85rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover { color: #e5e7eb; background: #111827; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; }
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.wizard { padding-top: 1rem; }
|
||||
.wizard-step h1 { font-size: 1.3rem; }
|
||||
.wizard-nav {
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
|
||||
.btn-secondary,
|
||||
.btn-primary { flex: 1; padding-left: 0.75rem; padding-right: 0.75rem; }
|
||||
.btn-ghost { order: -1; flex-basis: 100%; justify-content: flex-start; padding-left: 0; }
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.progress-fill { transition: none; }
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
import { Component, DestroyRef, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
||||
import { LucideAngularModule, ArrowLeft, ArrowRight, Check, RotateCcw, Sparkles } from 'lucide-angular';
|
||||
|
||||
import { Arc } from '../../../services/campaign.model';
|
||||
import { CampaignService } from '../../../services/campaign.service';
|
||||
import { GuidedSkeletonService } from '../../../services/guided-skeleton.service';
|
||||
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { GuidedAnswers, GuidedDraft, GuidedField, GuidedMethod, GuidedStep, answer } from '../guided-method.model';
|
||||
import { findGuidedMethod } from '../guided-methods';
|
||||
|
||||
/** Clés de réponse réservées à l'assistant (placement + chaînage), communes à toutes les méthodes. */
|
||||
const PLACEMENT_MODE = 'placement.mode';
|
||||
const PLACEMENT_ARC = 'placement.arcId';
|
||||
const PLACEMENT_NEW_ARC = 'placement.newArcName';
|
||||
const LINK_SCENES = 'link';
|
||||
|
||||
/**
|
||||
* Assistant pas à pas d'une méthode guidée (Mentor d'écriture, phase M3) :
|
||||
* une étape par écran (lisible sur téléphone), chacune expliquée (pourquoi + exemple),
|
||||
* avec le coach 💡 sur les champs. Les réponses sont celles du MJ : rien n'est généré.
|
||||
* Le brouillon est gardé dans le navigateur pour pouvoir quitter et revenir.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-guided-wizard',
|
||||
imports: [FormsModule, RouterLink, TranslatePipe, LucideAngularModule, WritingCoachTriggerComponent],
|
||||
templateUrl: './guided-wizard.component.html',
|
||||
styleUrls: ['./guided-wizard.component.scss']
|
||||
})
|
||||
export class GuidedWizardComponent implements OnInit {
|
||||
readonly ArrowLeft = ArrowLeft;
|
||||
readonly ArrowRight = ArrowRight;
|
||||
readonly Check = Check;
|
||||
readonly RotateCcw = RotateCcw;
|
||||
readonly Sparkles = Sparkles;
|
||||
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly translate = inject(TranslateService);
|
||||
private readonly campaignService = inject(CampaignService);
|
||||
private readonly skeletonService = inject(GuidedSkeletonService);
|
||||
private readonly confirmDialog = inject(ConfirmDialogService);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
@ViewChild('stepTitle') stepTitle?: ElementRef<HTMLHeadingElement>;
|
||||
|
||||
campaignId = '';
|
||||
method: GuidedMethod | null = null;
|
||||
answers: GuidedAnswers = {};
|
||||
stepIndex = 0;
|
||||
/** Arcs linéaires de la campagne : seuls candidats pour y ranger l'aventure. */
|
||||
linearArcs: Arc[] = [];
|
||||
/** Le placement par défaut dépend des arcs : on attend leur chargement pour le choisir. */
|
||||
private arcsLoaded = false;
|
||||
submitting = false;
|
||||
error: string | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.paramMap.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(pm => {
|
||||
this.campaignId = pm.get('campaignId') ?? '';
|
||||
this.method = findGuidedMethod(pm.get('method')) ?? null;
|
||||
if (!this.method) return;
|
||||
this.restoreDraft();
|
||||
this.arcsLoaded = false;
|
||||
this.campaignService.getArcs(this.campaignId).subscribe(arcs => {
|
||||
this.linearArcs = arcs
|
||||
.filter(a => (a.type ?? 'LINEAR') === 'LINEAR')
|
||||
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
||||
this.arcsLoaded = true;
|
||||
this.applyDefaults();
|
||||
});
|
||||
this.applyDefaults();
|
||||
});
|
||||
}
|
||||
|
||||
// --- Navigation ------------------------------------------------------------------
|
||||
|
||||
get step(): GuidedStep | null {
|
||||
return this.method?.steps[this.stepIndex] ?? null;
|
||||
}
|
||||
|
||||
get total(): number {
|
||||
return this.method?.steps.length ?? 0;
|
||||
}
|
||||
|
||||
get progress(): number {
|
||||
return this.total ? Math.round(((this.stepIndex + 1) / this.total) * 100) : 0;
|
||||
}
|
||||
|
||||
get isLast(): boolean {
|
||||
return this.stepIndex === this.total - 1;
|
||||
}
|
||||
|
||||
next(): void {
|
||||
if (!this.canProceed() || this.isLast) return;
|
||||
this.goTo(this.stepIndex + 1);
|
||||
}
|
||||
|
||||
previous(): void {
|
||||
if (this.stepIndex > 0) this.goTo(this.stepIndex - 1);
|
||||
}
|
||||
|
||||
private goTo(index: number): void {
|
||||
this.stepIndex = index;
|
||||
this.error = null;
|
||||
this.applyDefaults();
|
||||
this.saveDraft();
|
||||
// Nouvelle étape = nouvel écran : on remonte et on place le focus sur son titre.
|
||||
setTimeout(() => {
|
||||
this.stepTitle?.nativeElement.focus();
|
||||
this.stepTitle?.nativeElement.scrollIntoView({ block: 'start' });
|
||||
});
|
||||
}
|
||||
|
||||
canProceed(): boolean {
|
||||
const step = this.step;
|
||||
if (!step) return false;
|
||||
if (step.kind === 'placement') {
|
||||
return this.answers[PLACEMENT_MODE] === 'existing'
|
||||
? !!this.answers[PLACEMENT_ARC]
|
||||
: !!answer(this.answers, PLACEMENT_NEW_ARC);
|
||||
}
|
||||
return (step.fields ?? []).every(f => !f.required || !!answer(this.answers, f.key));
|
||||
}
|
||||
|
||||
// --- Réponses ----------------------------------------------------------------------
|
||||
|
||||
/** Clé i18n de la méthode courante. */
|
||||
k(path: string): string {
|
||||
return `guided.${this.method?.i18nKey}.${path}`;
|
||||
}
|
||||
|
||||
fieldId(field: GuidedField): string {
|
||||
return `guided-${field.key.replace(/\./g, '-')}`;
|
||||
}
|
||||
|
||||
setAnswer(key: string, value: string): void {
|
||||
this.answers = { ...this.answers, [key]: value };
|
||||
this.saveDraft();
|
||||
}
|
||||
|
||||
/** Placement par défaut + valeurs pré-remplies + premier choix des champs `choice`. */
|
||||
private applyDefaults(): void {
|
||||
const a = { ...this.answers };
|
||||
if (this.arcsLoaded) this.applyPlacementDefaults(a);
|
||||
a[LINK_SCENES] ??= 'true';
|
||||
for (const field of this.step?.fields ?? []) {
|
||||
if (a[field.key] !== undefined) continue;
|
||||
if (field.kind === 'choice' && field.options?.length) a[field.key] = field.options[0];
|
||||
else if (field.prefilled) a[field.key] = this.translate.instant(this.k(`defaults.${field.key}`));
|
||||
}
|
||||
this.answers = a;
|
||||
}
|
||||
|
||||
/** Arc existant par défaut s'il y en a ; sinon (ou arc disparu) nouvel arc. */
|
||||
private applyPlacementDefaults(a: GuidedAnswers): void {
|
||||
a[PLACEMENT_MODE] ??= this.linearArcs.length > 0 ? 'existing' : 'new';
|
||||
if (a[PLACEMENT_MODE] === 'existing' && !this.linearArcs.some(arc => arc.id === a[PLACEMENT_ARC])) {
|
||||
a[PLACEMENT_ARC] = this.linearArcs[0]?.id ?? '';
|
||||
if (!a[PLACEMENT_ARC]) a[PLACEMENT_MODE] = 'new';
|
||||
}
|
||||
}
|
||||
|
||||
// --- Récapitulatif & création --------------------------------------------------------
|
||||
|
||||
get draft(): GuidedDraft | null {
|
||||
return this.method ? this.method.toDraft(this.answers) : null;
|
||||
}
|
||||
|
||||
get placementLabel(): string {
|
||||
if (this.answers[PLACEMENT_MODE] === 'existing') {
|
||||
return this.linearArcs.find(a => a.id === this.answers[PLACEMENT_ARC])?.name ?? '';
|
||||
}
|
||||
return answer(this.answers, PLACEMENT_NEW_ARC) ?? '';
|
||||
}
|
||||
|
||||
get linkScenes(): boolean {
|
||||
return this.answers[LINK_SCENES] !== 'false';
|
||||
}
|
||||
|
||||
set linkScenes(value: boolean) {
|
||||
this.setAnswer(LINK_SCENES, String(value));
|
||||
}
|
||||
|
||||
create(): void {
|
||||
const draft = this.draft;
|
||||
if (!draft || this.submitting) return;
|
||||
const existing = this.answers[PLACEMENT_MODE] === 'existing';
|
||||
this.submitting = true;
|
||||
this.error = null;
|
||||
this.skeletonService.create(this.campaignId, {
|
||||
arcId: existing ? this.answers[PLACEMENT_ARC] : null,
|
||||
newArcName: existing ? null : answer(this.answers, PLACEMENT_NEW_ARC),
|
||||
chapter: draft.chapter,
|
||||
scenes: draft.scenes,
|
||||
linkSequentially: this.linkScenes,
|
||||
linkLabel: this.translate.instant('guided.linkLabel')
|
||||
}).subscribe({
|
||||
next: result => {
|
||||
this.clearDraft();
|
||||
this.router.navigate(['/campaigns', this.campaignId, 'arcs', result.arcId, 'chapters', result.chapterId]);
|
||||
},
|
||||
error: () => {
|
||||
this.submitting = false;
|
||||
this.error = this.translate.instant('guided.createError');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async restart(): Promise<void> {
|
||||
const ok = await this.confirmDialog.confirm({
|
||||
title: this.translate.instant('guided.restartTitle'),
|
||||
message: this.translate.instant('guided.restartMessage'),
|
||||
confirmLabel: this.translate.instant('guided.restart')
|
||||
});
|
||||
if (!ok) return;
|
||||
this.clearDraft();
|
||||
this.answers = {};
|
||||
this.goTo(0);
|
||||
}
|
||||
|
||||
// --- Brouillon (confort par navigateur : jamais indispensable) -------------------------
|
||||
|
||||
private get storageKey(): string {
|
||||
return `loremind.guided.${this.campaignId}.${this.method?.id}`;
|
||||
}
|
||||
|
||||
private restoreDraft(): void {
|
||||
this.answers = {};
|
||||
this.stepIndex = 0;
|
||||
try {
|
||||
const raw = localStorage.getItem(this.storageKey);
|
||||
if (!raw) return;
|
||||
const saved = JSON.parse(raw) as { answers?: GuidedAnswers; step?: number };
|
||||
this.answers = saved.answers ?? {};
|
||||
this.stepIndex = Math.min(Math.max(saved.step ?? 0, 0), this.total - 1);
|
||||
} catch { /* brouillon illisible ou stockage bloqué : on repart de zéro */ }
|
||||
}
|
||||
|
||||
private saveDraft(): void {
|
||||
try {
|
||||
localStorage.setItem(this.storageKey, JSON.stringify({ answers: this.answers, step: this.stepIndex }));
|
||||
} catch { /* stockage indisponible : le brouillon n'est simplement pas gardé */ }
|
||||
}
|
||||
|
||||
private clearDraft(): void {
|
||||
try {
|
||||
localStorage.removeItem(this.storageKey);
|
||||
} catch { /* rien à nettoyer */ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { SceneType } from '../../../services/campaign.model';
|
||||
import { GuidedSceneSpec } from '../../../services/guided-skeleton.model';
|
||||
import { GuidedAnswers, GuidedField, GuidedMethod, answer } from '../guided-method.model';
|
||||
|
||||
/**
|
||||
* « Donjon en 5 salles » (méthode popularisée par Johnn Four ; textes écrits pour
|
||||
* LoreMind). Une aventure courte en cinq temps : un gardien à l'entrée, une épreuve
|
||||
* qui ne se règle pas à l'épée, un revers, le climax, puis la récompense ou la
|
||||
* révélation. Le « donjon » peut être n'importe quel lieu : manoir, navire, forêt…
|
||||
*
|
||||
* Produit 1 chapitre (accroche, objectifs, enjeux) + 5 scènes typées dans le même lieu.
|
||||
*/
|
||||
|
||||
/** Champs communs à chaque salle : nom (pré-rempli), ce qui s'y passe, choix, secret du MJ. */
|
||||
function roomFields(room: number, extra: GuidedField[] = []): GuidedField[] {
|
||||
return [
|
||||
{ key: `room${room}.name`, kind: 'text', required: true, prefilled: true },
|
||||
...extra.filter(f => f.kind === 'choice'),
|
||||
{ key: `room${room}.description`, kind: 'textarea', coachTopic: 'scene.description' },
|
||||
...extra.filter(f => f.kind !== 'choice'),
|
||||
{ key: `room${room}.choices`, kind: 'textarea', coachTopic: 'scene.choices' },
|
||||
{ key: `room${room}.secret`, kind: 'textarea', coachTopic: 'scene.gmNotes' }
|
||||
];
|
||||
}
|
||||
|
||||
/** Nature de la salle (choix du MJ) → type de scène, pour que la relecture juge le rythme. */
|
||||
const NATURE_TO_TYPE: Record<string, SceneType> = {
|
||||
combat: 'ENCOUNTER',
|
||||
social: 'NPC',
|
||||
obstacle: 'LOCATION',
|
||||
puzzle: 'LOCATION',
|
||||
exploration: 'LOCATION'
|
||||
};
|
||||
|
||||
export const FIVE_ROOM_METHOD: GuidedMethod = {
|
||||
id: 'five-room',
|
||||
i18nKey: 'fiveRoom',
|
||||
steps: [
|
||||
{ id: 'placement', kind: 'placement' },
|
||||
{
|
||||
id: 'frame', kind: 'form', fields: [
|
||||
{ key: 'title', kind: 'text', required: true },
|
||||
{ key: 'location', kind: 'text', coachTopic: 'scene.setting' },
|
||||
{ key: 'hook', kind: 'textarea', coachTopic: 'chapter.synopsis' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'stakes', kind: 'form', fields: [
|
||||
{ key: 'objectives', kind: 'textarea', coachTopic: 'chapter.objectives' },
|
||||
{ key: 'stakes', kind: 'textarea', coachTopic: 'chapter.stakes' }
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'room1', kind: 'form', fields: roomFields(1, [
|
||||
{ key: 'room1.nature', kind: 'choice', options: ['combat', 'social', 'obstacle'] },
|
||||
{ key: 'room1.enemies', kind: 'text' }
|
||||
])
|
||||
},
|
||||
{
|
||||
id: 'room2', kind: 'form', fields: roomFields(2, [
|
||||
{ key: 'room2.nature', kind: 'choice', options: ['puzzle', 'social', 'exploration'] }
|
||||
])
|
||||
},
|
||||
{ id: 'room3', kind: 'form', fields: roomFields(3) },
|
||||
{
|
||||
id: 'room4', kind: 'form', fields: roomFields(4, [
|
||||
{ key: 'room4.enemies', kind: 'text', coachTopic: 'scene.combat' }
|
||||
])
|
||||
},
|
||||
{ id: 'room5', kind: 'form', fields: roomFields(5) },
|
||||
{ id: 'review', kind: 'review' }
|
||||
],
|
||||
|
||||
toDraft(answers: GuidedAnswers) {
|
||||
const location = answer(answers, 'location');
|
||||
const room = (n: number, type: SceneType): GuidedSceneSpec => ({
|
||||
name: answer(answers, `room${n}.name`) ?? '',
|
||||
description: answer(answers, `room${n}.description`),
|
||||
type,
|
||||
location,
|
||||
choicesConsequences: answer(answers, `room${n}.choices`),
|
||||
gmSecretNotes: answer(answers, `room${n}.secret`),
|
||||
enemies: answer(answers, `room${n}.enemies`)
|
||||
});
|
||||
return {
|
||||
chapter: {
|
||||
name: answer(answers, 'title') ?? '',
|
||||
description: answer(answers, 'hook'),
|
||||
playerObjectives: answer(answers, 'objectives'),
|
||||
narrativeStakes: answer(answers, 'stakes')
|
||||
},
|
||||
scenes: [
|
||||
room(1, NATURE_TO_TYPE[answers['room1.nature']] ?? 'ENCOUNTER'),
|
||||
room(2, NATURE_TO_TYPE[answers['room2.nature']] ?? 'LOCATION'),
|
||||
room(3, 'EVENT'),
|
||||
room(4, 'ENCOUNTER'),
|
||||
room(5, 'REVELATION')
|
||||
]
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -30,6 +30,9 @@
|
||||
est dans des sections repliables avec pastille « rempli ». -->
|
||||
<p class="optional-hint">{{ 'sceneEdit.optionalHint' | translate }}</p>
|
||||
|
||||
<!-- Mentor d'écriture (M2) : conseils de relecture qui concernent cette entité. -->
|
||||
<app-writing-review-hints [campaignId]="campaignId" entityType="SCENE" [entityId]="sceneId"></app-writing-review-hints>
|
||||
|
||||
<!-- Co-création (Pilier A) : le co-MJ propose, l'utilisateur valide champ par champ.
|
||||
Les champs retenus remplissent le formulaire ; rien n'est enregistré avant la sauvegarde. -->
|
||||
<app-entity-assist-panel
|
||||
@@ -49,7 +52,10 @@
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="scene-edit-description">{{ 'sceneEdit.descriptionLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-description">{{ 'sceneEdit.descriptionLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.description"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="scene-edit-description"
|
||||
formControlName="description"
|
||||
@@ -65,7 +71,10 @@
|
||||
|
||||
<!-- Type narratif du nœud (Niveau 2 — graphe de nœuds typés) -->
|
||||
<div class="field">
|
||||
<label for="scene-edit-type">{{ 'sceneEdit.nodeTypeLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-type">{{ 'sceneEdit.nodeTypeLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.nodeType"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<select id="scene-edit-type" formControlName="type">
|
||||
@for (opt of sceneTypeOptions; track opt) {
|
||||
<option [value]="opt">{{ 'sceneType.' + opt | translate }}</option>
|
||||
@@ -181,7 +190,10 @@
|
||||
<app-expandable-section [title]="'sceneEdit.contextSectionTitle' | translate" icon="📍" [initiallyOpen]="true" [filled]="contextFilled">
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label for="scene-edit-location">{{ 'sceneEdit.locationLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-location">{{ 'sceneEdit.locationLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.setting"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<input id="scene-edit-location" type="text" formControlName="location" [placeholder]="'sceneEdit.locationPlaceholder' | translate" />
|
||||
</div>
|
||||
<div class="field">
|
||||
@@ -190,7 +202,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="scene-edit-atmosphere">{{ 'sceneEdit.atmosphereLabel' | translate }}</label>
|
||||
<div class="field-label-row">
|
||||
<label for="scene-edit-atmosphere">{{ 'sceneEdit.atmosphereLabel' | translate }}</label>
|
||||
<app-writing-coach-trigger topic="scene.atmosphere"></app-writing-coach-trigger>
|
||||
</div>
|
||||
<textarea
|
||||
id="scene-edit-atmosphere"
|
||||
formControlName="atmosphere"
|
||||
@@ -201,7 +216,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Narration pour les joueurs -->
|
||||
<app-expandable-section [title]="'sceneEdit.narrationSectionTitle' | translate" icon="📖" [filled]="narrationFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.narrationSectionTitle' | translate" coachTopic="scene.narration" icon="📖" [initiallyOpen]="focusSection === 'narration'" [filled]="narrationFilled">
|
||||
<div class="field">
|
||||
<textarea
|
||||
formControlName="playerNarration"
|
||||
@@ -213,7 +228,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Notes et secrets du MJ (privé) -->
|
||||
<app-expandable-section [title]="'sceneEdit.gmNotesSectionTitle' | translate" icon="🔒" variant="private" [filled]="gmNotesFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.gmNotesSectionTitle' | translate" coachTopic="scene.gmNotes" icon="🔒" variant="private" [filled]="gmNotesFilled">
|
||||
<div class="field">
|
||||
<textarea
|
||||
formControlName="gmSecretNotes"
|
||||
@@ -225,7 +240,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Choix et conséquences -->
|
||||
<app-expandable-section [title]="'sceneEdit.choicesSectionTitle' | translate" icon="🔀" [filled]="choicesFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.choicesSectionTitle' | translate" coachTopic="scene.choices" icon="🔀" [initiallyOpen]="focusSection === 'choices'" [filled]="choicesFilled">
|
||||
<div class="field">
|
||||
<textarea
|
||||
formControlName="choicesConsequences"
|
||||
@@ -236,7 +251,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Branches narratives (graphe intra-chapitre) -->
|
||||
<app-expandable-section [title]="'sceneEdit.branchesSectionTitle' | translate" icon="🌿" [initiallyOpen]="focusSection === 'branches'" [filled]="branchesFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.branchesSectionTitle' | translate" coachTopic="scene.branches" icon="🌿" [initiallyOpen]="focusSection === 'branches'" [filled]="branchesFilled">
|
||||
@if (siblingScenes.length === 0) {
|
||||
<div class="branches-hint">
|
||||
<small class="field-hint">
|
||||
@@ -307,7 +322,7 @@
|
||||
</app-expandable-section>
|
||||
|
||||
<!-- Section : Combat ou rencontre -->
|
||||
<app-expandable-section [title]="'sceneEdit.combatSectionTitle' | translate" icon="⚔️" [initiallyOpen]="focusSection === 'combat'" [filled]="combatFilled">
|
||||
<app-expandable-section [title]="'sceneEdit.combatSectionTitle' | translate" coachTopic="scene.combat" icon="⚔️" [initiallyOpen]="focusSection === 'combat'" [filled]="combatFilled">
|
||||
<div class="field">
|
||||
<label for="scene-edit-combat-difficulty">{{ 'sceneEdit.combatDifficultyLabel' | translate }}</label>
|
||||
<input id="scene-edit-combat-difficulty" type="text" formControlName="combatDifficulty" [placeholder]="'sceneEdit.combatDifficultyPlaceholder' | translate" />
|
||||
|
||||
@@ -31,6 +31,8 @@ import { FieldProposal } from '../../../services/entity-assist.model';
|
||||
import { FileDropDirective } from '../../../shared/file-drop.directive';
|
||||
import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
|
||||
import { ConfirmDialogService } from '../../../shared/confirm-dialog/confirm-dialog.service';
|
||||
import { WritingCoachTriggerComponent } from '../../../shared/writing-coach/writing-coach-trigger.component';
|
||||
import { WritingReviewHintsComponent } from '../../../shared/writing-review/writing-review-hints.component';
|
||||
|
||||
/**
|
||||
* État d'édition d'UNE battlemap de la scène (une carte par variante : Jour, Nuit,
|
||||
@@ -63,7 +65,7 @@ interface BattlemapEdit {
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-scene-edit',
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, ExpandableSectionComponent, LoreLinkPickerComponent, EnemyLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, RoomsEditorComponent, EntityAssistPanelComponent, FileDropDirective, TranslatePipe],
|
||||
imports: [ReactiveFormsModule, LucideAngularModule, ExpandableSectionComponent, LoreLinkPickerComponent, EnemyLinkPickerComponent, AiChatDrawerComponent, ImageGalleryComponent, IconPickerComponent, RoomsEditorComponent, EntityAssistPanelComponent, FileDropDirective, TranslatePipe, WritingCoachTriggerComponent, WritingReviewHintsComponent],
|
||||
templateUrl: './scene-edit.component.html',
|
||||
styleUrls: ['./scene-edit.component.scss']
|
||||
})
|
||||
@@ -95,7 +97,7 @@ export class SceneEditComponent implements OnInit {
|
||||
scene: Scene | null = null;
|
||||
|
||||
/**
|
||||
* Section à déplier d'office (query param `?focus=combat|branches|rooms`) — posé par
|
||||
* Section à déplier d'office (query param `?focus=combat|branches|rooms|narration|choices`) — posé par
|
||||
* le bouton « Corriger » du guidage pour atterrir directement sur l'outil fautif.
|
||||
*/
|
||||
focusSection: string | null = null;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { WritingRemark } from '../services/writing-review.model';
|
||||
import { GapAction } from './gap-action.helper';
|
||||
|
||||
/**
|
||||
* Lien « Voir » d'une remarque de relecture : ouvre l'éditeur concerné avec la
|
||||
* section en cause dépliée (`?focus=…`), comme le « Corriger » du readiness.
|
||||
*/
|
||||
export function remarkAction(remark: WritingRemark, campaignId: string): GapAction {
|
||||
const base = ['/campaigns', campaignId];
|
||||
const focus = FOCUS_BY_RULE[remark.ruleId];
|
||||
const queryParams = focus ? { focus } : undefined;
|
||||
switch (remark.entityType) {
|
||||
case 'SCENE':
|
||||
return {
|
||||
link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.chapterId ?? '', 'scenes', remark.entityId, 'edit'],
|
||||
queryParams
|
||||
};
|
||||
case 'CHAPTER':
|
||||
// Couloir / rythme : c'est l'enchaînement des scènes qu'il faut voir (vue du chapitre).
|
||||
if (!focus) return { link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.entityId] };
|
||||
return { link: [...base, 'arcs', remark.arcId ?? '', 'chapters', remark.entityId, 'edit'], queryParams };
|
||||
case 'ARC':
|
||||
return { link: [...base, 'arcs', remark.entityId, 'edit'], queryParams };
|
||||
default:
|
||||
return { link: base };
|
||||
}
|
||||
}
|
||||
|
||||
/** Section de l'éditeur à déplier selon la règle (clé = ruleId complet). */
|
||||
const FOCUS_BY_RULE: Record<string, string> = {
|
||||
'WRITE-002-FAKE-CHOICE': 'branches',
|
||||
'WRITE-003-SINGLE-CLUE': 'branches',
|
||||
'WRITE-005-NO-STAKES': 'stakes',
|
||||
'WRITE-006-LONG-NARRATION': 'narration',
|
||||
'WRITE-007-NARRATION-DECIDES': 'narration',
|
||||
'WRITE-008-COMBAT-NO-PURPOSE': 'combat',
|
||||
'WRITE-009-SINGLE-ENDING': 'choices'
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
import { SceneType } from './campaign.model';
|
||||
|
||||
/**
|
||||
* Squelette d'aventure produit par une méthode guidée (Mentor d'écriture, phase M3),
|
||||
* envoyé à POST /api/campaigns/{id}/guided-skeleton. Miroir du record Java `GuidedSkeleton`.
|
||||
*/
|
||||
export interface GuidedChapterSpec {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
playerObjectives?: string | null;
|
||||
narrativeStakes?: string | null;
|
||||
}
|
||||
|
||||
export interface GuidedSceneSpec {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
type: SceneType;
|
||||
location?: string | null;
|
||||
choicesConsequences?: string | null;
|
||||
gmSecretNotes?: string | null;
|
||||
enemies?: string | null;
|
||||
}
|
||||
|
||||
export interface GuidedSkeleton {
|
||||
/** Arc linéaire existant… */
|
||||
arcId?: string | null;
|
||||
/** …ou nom du nouvel arc (exactement l'un des deux). */
|
||||
newArcName?: string | null;
|
||||
chapter: GuidedChapterSpec;
|
||||
scenes: GuidedSceneSpec[];
|
||||
linkSequentially: boolean;
|
||||
linkLabel?: string | null;
|
||||
}
|
||||
|
||||
export interface GuidedSkeletonResult {
|
||||
arcId: string;
|
||||
chapterId: string;
|
||||
sceneIds: string[];
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { GuidedSkeleton, GuidedSkeletonResult } from './guided-skeleton.model';
|
||||
|
||||
/** Service HTTP des méthodes guidées (Mentor d'écriture, phase M3). */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GuidedSkeletonService {
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
create(campaignId: string, skeleton: GuidedSkeleton): Observable<GuidedSkeletonResult> {
|
||||
return this.http.post<GuidedSkeletonResult>(`/api/campaigns/${campaignId}/guided-skeleton`, skeleton);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ReadinessEntityType } from './readiness.model';
|
||||
|
||||
/**
|
||||
* Modèles de la relecture d'éditeur (Mentor d'écriture, phase M2) renvoyés par
|
||||
* GET /api/campaigns/{id}/writing-review. Le back renvoie la règle et ses paramètres ;
|
||||
* le texte (observation / pourquoi / question) vient de l'i18n `writingReview.rules.<ruleId>`.
|
||||
*/
|
||||
|
||||
export type WritingRemarkCategory = 'AGENCY' | 'PACING' | 'STAKES' | 'NARRATION';
|
||||
|
||||
export interface WritingRemark {
|
||||
entityType: ReadinessEntityType;
|
||||
entityId: string;
|
||||
entityName?: string | null;
|
||||
ruleId: string;
|
||||
category: WritingRemarkCategory;
|
||||
/** Valeurs injectées dans le texte i18n (count, phrase, target…). */
|
||||
params: Record<string, string>;
|
||||
arcId?: string | null;
|
||||
chapterId?: string | null;
|
||||
}
|
||||
|
||||
export interface WritingReviewReport {
|
||||
campaignId: string;
|
||||
remarks: WritingRemark[];
|
||||
}
|
||||
|
||||
/** Ordre d'affichage des familles de remarques. */
|
||||
export const WRITING_REMARK_CATEGORIES: WritingRemarkCategory[] = ['AGENCY', 'STAKES', 'PACING', 'NARRATION'];
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { WritingReviewReport } from './writing-review.model';
|
||||
|
||||
/**
|
||||
* Service HTTP de la relecture d'éditeur (Mentor d'écriture, phase M2).
|
||||
* Read-model pur, déterministe, sans effet de bord.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class WritingReviewService {
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getReview(campaignId: string): Observable<WritingReviewReport> {
|
||||
return this.http.get<WritingReviewReport>(`/api/campaigns/${campaignId}/writing-review`);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,22 @@
|
||||
<div class="expandable-section" [class.private]="variant === 'private'">
|
||||
|
||||
<button type="button" class="section-header" (click)="toggle()">
|
||||
<span class="section-title">
|
||||
@if (icon) {
|
||||
<span class="section-icon">{{ icon }}</span>
|
||||
}
|
||||
{{ title }}
|
||||
@if (filled) {
|
||||
<span class="section-dot" aria-hidden="true"></span>
|
||||
}
|
||||
</span>
|
||||
<lucide-icon [img]="isOpen ? ChevronUp : ChevronDown" [size]="16"></lucide-icon>
|
||||
</button>
|
||||
<div class="section-header-row">
|
||||
<button type="button" class="section-header" (click)="toggle()">
|
||||
<span class="section-title">
|
||||
@if (icon) {
|
||||
<span class="section-icon">{{ icon }}</span>
|
||||
}
|
||||
{{ title }}
|
||||
@if (filled) {
|
||||
<span class="section-dot" aria-hidden="true"></span>
|
||||
}
|
||||
</span>
|
||||
<lucide-icon [img]="isOpen ? ChevronUp : ChevronDown" [size]="16"></lucide-icon>
|
||||
</button>
|
||||
@if (coachTopic) {
|
||||
<app-writing-coach-trigger class="section-coach" [topic]="coachTopic"></app-writing-coach-trigger>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (isOpen) {
|
||||
<div class="section-content">
|
||||
|
||||
@@ -9,12 +9,25 @@
|
||||
&.private {
|
||||
border-color: #7f1d1d;
|
||||
|
||||
.section-header { background: rgba(127, 29, 29, 0.12); }
|
||||
.section-header-row { background: rgba(127, 29, 29, 0.12); }
|
||||
.section-title { color: #fca5a5; }
|
||||
}
|
||||
}
|
||||
|
||||
// En-tête = bouton de repli + éventuel 💡 du coach d'écriture (bouton frère :
|
||||
// pas de bouton imbriqué dans un bouton).
|
||||
.section-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.section-coach {
|
||||
margin-right: 0.6rem;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
|
||||
import { LucideAngularModule, ChevronDown, ChevronUp } from 'lucide-angular';
|
||||
import { WritingCoachTriggerComponent } from '../writing-coach/writing-coach-trigger.component';
|
||||
|
||||
/**
|
||||
* Section repliable avec titre (icône + texte) et contenu projeté via ng-content.
|
||||
@@ -13,7 +14,7 @@ import { LucideAngularModule, ChevronDown, ChevronUp } from 'lucide-angular';
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-expandable-section',
|
||||
imports: [LucideAngularModule],
|
||||
imports: [LucideAngularModule, WritingCoachTriggerComponent],
|
||||
templateUrl: './expandable-section.component.html',
|
||||
styleUrls: ['./expandable-section.component.scss']
|
||||
})
|
||||
@@ -31,6 +32,11 @@ export class ExpandableSectionComponent implements OnInit {
|
||||
* sans avoir à les ouvrir une à une. Le parent calcule l'état.
|
||||
*/
|
||||
@Input() filled = false;
|
||||
/**
|
||||
* Sujet du coach d'écriture (ex. `scene.choices`) : affiche un 💡 dans l'en-tête
|
||||
* qui ouvre les conseils. Pour les sections qui n'ont pas de libellé par champ.
|
||||
*/
|
||||
@Input() coachTopic: string | null = null;
|
||||
|
||||
isOpen = false;
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
/**
|
||||
* Garde-fou du contenu du coach d'écriture : chaque sujet référencé dans un
|
||||
* template (`topic="…"` ou `coachTopic="…"`) doit exister en fr ET en en, avec
|
||||
* ses 4 rubriques renseignées. Sinon le 💡 ouvrirait un panneau vide.
|
||||
*/
|
||||
const APP_DIR = join(process.cwd(), 'src/app');
|
||||
const FRAGMENTS_DIR = join(process.cwd(), 'src/assets/i18n/fragments');
|
||||
|
||||
function htmlFiles(dir: string): string[] {
|
||||
return readdirSync(dir).flatMap(name => {
|
||||
const path = join(dir, name);
|
||||
if (statSync(path).isDirectory()) return htmlFiles(path);
|
||||
return name.endsWith('.html') ? [path] : [];
|
||||
});
|
||||
}
|
||||
|
||||
function referencedTopics(): string[] {
|
||||
const topics = new Set<string>();
|
||||
for (const file of htmlFiles(APP_DIR)) {
|
||||
const html = readFileSync(file, 'utf-8');
|
||||
for (const m of html.matchAll(/<app-writing-coach-trigger[^>]*\stopic="([^"]+)"/g)) topics.add(m[1]);
|
||||
for (const m of html.matchAll(/\scoachTopic="([^"]+)"/g)) topics.add(m[1]);
|
||||
}
|
||||
return [...topics].sort();
|
||||
}
|
||||
|
||||
function topicsOf(lang: 'fr' | 'en'): Record<string, Record<string, Record<string, unknown>>> {
|
||||
const json = JSON.parse(readFileSync(join(FRAGMENTS_DIR, `writing-coach.${lang}.json`), 'utf-8'));
|
||||
return json.writingCoach.topics;
|
||||
}
|
||||
|
||||
function lookup(lang: 'fr' | 'en', key: string): Record<string, unknown> | undefined {
|
||||
const [entity, field] = key.split('.');
|
||||
return topicsOf(lang)[entity]?.[field];
|
||||
}
|
||||
|
||||
describe('writing coach content', () => {
|
||||
const topics = referencedTopics();
|
||||
|
||||
it('is referenced by the editors', () => {
|
||||
expect(topics.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
for (const lang of ['fr', 'en'] as const) {
|
||||
it.each(topics)(`${lang}: topic %s is complete`, key => {
|
||||
const topic = lookup(lang, key);
|
||||
expect(topic, `writingCoach.topics.${key} manquant (${lang})`).toBeDefined();
|
||||
for (const field of ['title', 'purpose', 'example', 'pitfall']) {
|
||||
expect(typeof topic![field] === 'string' && (topic![field] as string).trim().length > 0,
|
||||
`${key}.${field} vide (${lang})`).toBe(true);
|
||||
}
|
||||
const questions = topic!['questions'];
|
||||
expect(Array.isArray(questions) && questions.length >= 2, `${key}.questions < 2 (${lang})`).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('has the same topics in fr and en', () => {
|
||||
const keys = (lang: 'fr' | 'en') => Object.entries(topicsOf(lang))
|
||||
.flatMap(([entity, fields]) => Object.keys(fields).map(f => `${entity}.${f}`)).sort();
|
||||
expect(keys('en')).toEqual(keys('fr'));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
<aside class="coach-panel" [class.open]="!!topic()"
|
||||
role="complementary"
|
||||
[attr.aria-hidden]="!topic()"
|
||||
[attr.aria-label]="'writingCoach.panelLabel' | translate">
|
||||
|
||||
@if (content(); as c) {
|
||||
<header class="coach-header">
|
||||
<div class="coach-heading">
|
||||
<span class="coach-kicker">
|
||||
<lucide-icon [img]="Lightbulb" [size]="14"></lucide-icon>
|
||||
{{ 'writingCoach.kicker' | translate }}
|
||||
</span>
|
||||
<h2>{{ c.title }}</h2>
|
||||
</div>
|
||||
<button type="button" class="coach-close" (click)="close()"
|
||||
[title]="'common.close' | translate" [attr.aria-label]="'common.close' | translate">
|
||||
<lucide-icon [img]="X" [size]="16"></lucide-icon>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="coach-body">
|
||||
<section class="coach-block">
|
||||
<h3>{{ 'writingCoach.purposeTitle' | translate }}</h3>
|
||||
<p>{{ c.purpose }}</p>
|
||||
</section>
|
||||
|
||||
@if (c.questions.length) {
|
||||
<section class="coach-block">
|
||||
<h3>{{ 'writingCoach.questionsTitle' | translate }}</h3>
|
||||
<ul class="coach-questions">
|
||||
@for (q of c.questions; track q) {
|
||||
<li>{{ q }}</li>
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (c.example) {
|
||||
<section class="coach-block coach-example">
|
||||
<h3>{{ 'writingCoach.exampleTitle' | translate }}</h3>
|
||||
<p>{{ c.example }}</p>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (c.pitfall) {
|
||||
<section class="coach-block coach-pitfall">
|
||||
<h3>{{ 'writingCoach.pitfallTitle' | translate }}</h3>
|
||||
<p>{{ c.pitfall }}</p>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
<footer class="coach-footer">
|
||||
<p>{{ 'writingCoach.footer' | translate }}</p>
|
||||
</footer>
|
||||
}
|
||||
</aside>
|
||||
@@ -0,0 +1,154 @@
|
||||
:host {
|
||||
// Le panneau gère lui-même son positionnement fixed.
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.coach-panel {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: min(380px, 100vw);
|
||||
height: 100vh;
|
||||
background: #0f0f1a;
|
||||
border-left: 1px solid #1e1e3a;
|
||||
box-shadow: -12px 0 32px rgba(0, 0, 0, 0.35);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transform: translateX(100%);
|
||||
visibility: hidden;
|
||||
transition: transform 0.25s ease, visibility 0s linear 0.25s;
|
||||
// Au-dessus du drawer de chat IA (1000) : c'est le dernier ouvert qui compte.
|
||||
z-index: 1001;
|
||||
|
||||
&.open {
|
||||
transform: translateX(0);
|
||||
visibility: visible;
|
||||
transition: transform 0.25s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.coach-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
padding: 1.1rem 1.25rem 1rem;
|
||||
border-bottom: 1px solid #1e1e3a;
|
||||
flex-shrink: 0;
|
||||
|
||||
h2 {
|
||||
margin: 0.35rem 0 0;
|
||||
font-size: 1.05rem;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.coach-kicker {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #fbbf24;
|
||||
}
|
||||
|
||||
.coach-close {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover { background: #1f2937; color: white; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; }
|
||||
}
|
||||
|
||||
.coach-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.1rem 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.coach-block {
|
||||
h3 {
|
||||
margin: 0 0 0.45rem;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.55;
|
||||
color: #e5e7eb;
|
||||
// Les exemples peuvent contenir des retours à la ligne (puces).
|
||||
white-space: pre-line;
|
||||
}
|
||||
}
|
||||
|
||||
.coach-questions {
|
||||
margin: 0;
|
||||
padding-left: 1.1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
li {
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.5;
|
||||
color: #e5e7eb;
|
||||
|
||||
&::marker { color: #6c63ff; }
|
||||
}
|
||||
}
|
||||
|
||||
.coach-example {
|
||||
padding: 0.85rem 1rem;
|
||||
border-radius: 8px;
|
||||
background: rgba(108, 99, 255, 0.08);
|
||||
border: 1px solid rgba(108, 99, 255, 0.25);
|
||||
|
||||
p { font-style: italic; color: #d1d5db; }
|
||||
}
|
||||
|
||||
.coach-pitfall {
|
||||
padding: 0.85rem 1rem;
|
||||
border-radius: 8px;
|
||||
background: rgba(251, 191, 36, 0.06);
|
||||
border: 1px solid rgba(251, 191, 36, 0.25);
|
||||
|
||||
h3 { color: #fbbf24; }
|
||||
}
|
||||
|
||||
.coach-footer {
|
||||
flex-shrink: 0;
|
||||
padding: 0.85rem 1.25rem;
|
||||
border-top: 1px solid #1e1e3a;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.5;
|
||||
color: #6b7280;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.coach-panel,
|
||||
.coach-panel.open { transition: none; }
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { Component, DestroyRef, HostListener, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed, toObservable, toSignal } from '@angular/core/rxjs-interop';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
||||
import { filter, map, of, switchMap } from 'rxjs';
|
||||
import { LucideAngularModule, Lightbulb, X } from 'lucide-angular';
|
||||
|
||||
import { WritingCoachService } from './writing-coach.service';
|
||||
|
||||
/** Fiche de conseils d'un champ, telle que rangée dans `writingCoach.topics.<clé>`. */
|
||||
export interface WritingCoachTopic {
|
||||
title: string;
|
||||
purpose: string;
|
||||
questions: string[];
|
||||
example: string;
|
||||
pitfall: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Panneau latéral du coach d'écriture, monté une seule fois dans le shell
|
||||
* (comme `app-confirm-dialog-host`). Non modal : on peut continuer à écrire
|
||||
* dans le formulaire pendant qu'il est ouvert.
|
||||
*
|
||||
* Posture « mentor d'abord » : il explique et questionne, il n'écrit jamais
|
||||
* à la place du MJ (l'IA qui écrit reste le bouton « Étoffer avec l'IA »).
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-writing-coach-panel',
|
||||
imports: [LucideAngularModule, TranslatePipe],
|
||||
templateUrl: './writing-coach-panel.component.html',
|
||||
styleUrls: ['./writing-coach-panel.component.scss']
|
||||
})
|
||||
export class WritingCoachPanelComponent {
|
||||
readonly Lightbulb = Lightbulb;
|
||||
readonly X = X;
|
||||
|
||||
private readonly coach = inject(WritingCoachService);
|
||||
private readonly translate = inject(TranslateService);
|
||||
|
||||
readonly topic = this.coach.topic;
|
||||
|
||||
/** Contenu du sujet ouvert, re-résolu au changement de langue. */
|
||||
readonly content = toSignal(
|
||||
toObservable(this.coach.topic).pipe(
|
||||
switchMap(key => key
|
||||
? this.translate.stream(`writingCoach.topics.${key}`).pipe(map(value => toTopic(value)))
|
||||
: of(null))
|
||||
),
|
||||
{ initialValue: null }
|
||||
);
|
||||
|
||||
constructor() {
|
||||
// Changer d'écran ferme le panneau : ses conseils concernaient l'ancien formulaire.
|
||||
inject(Router).events
|
||||
.pipe(filter(e => e instanceof NavigationStart), takeUntilDestroyed(inject(DestroyRef)))
|
||||
.subscribe(() => this.coach.close());
|
||||
}
|
||||
|
||||
@HostListener('document:keydown.escape')
|
||||
onEscape(): void {
|
||||
if (this.coach.topic()) this.coach.close();
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.coach.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** Clé absente → ngx-translate renvoie la clé elle-même (string) : on n'affiche rien. */
|
||||
function toTopic(value: unknown): WritingCoachTopic | null {
|
||||
if (!value || typeof value !== 'object') return null;
|
||||
const t = value as Partial<WritingCoachTopic>;
|
||||
return {
|
||||
title: t.title ?? '',
|
||||
purpose: t.purpose ?? '',
|
||||
questions: Array.isArray(t.questions) ? t.questions : [],
|
||||
example: t.example ?? '',
|
||||
pitfall: t.pitfall ?? ''
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Component, Input, computed, inject, signal } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { LucideAngularModule, Lightbulb } from 'lucide-angular';
|
||||
|
||||
import { WritingCoachService } from './writing-coach.service';
|
||||
|
||||
/**
|
||||
* Petit bouton 💡 posé à côté d'un libellé de champ : ouvre le panneau de
|
||||
* conseils d'écriture sur le sujet donné.
|
||||
*
|
||||
* Usage :
|
||||
* <div class="field-label-row">
|
||||
* <label for="x">Enjeux</label>
|
||||
* <app-writing-coach-trigger topic="chapter.stakes"></app-writing-coach-trigger>
|
||||
* </div>
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-writing-coach-trigger',
|
||||
imports: [LucideAngularModule, TranslatePipe],
|
||||
template: `
|
||||
<button type="button" class="coach-trigger"
|
||||
[class.active]="active()"
|
||||
[attr.aria-pressed]="active()"
|
||||
[title]="'writingCoach.triggerTitle' | translate"
|
||||
[attr.aria-label]="'writingCoach.triggerTitle' | translate"
|
||||
(click)="onClick($event)">
|
||||
<lucide-icon [img]="Lightbulb" [size]="14"></lucide-icon>
|
||||
</button>
|
||||
`,
|
||||
styles: [`
|
||||
:host { display: inline-flex; }
|
||||
.coach-trigger {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: #6b7280;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s, background 0.15s, border-color 0.15s;
|
||||
}
|
||||
.coach-trigger:hover { color: #fbbf24; background: rgba(251, 191, 36, 0.08); }
|
||||
.coach-trigger:focus-visible { outline: 2px solid #6c63ff; outline-offset: 1px; }
|
||||
.coach-trigger.active {
|
||||
color: #fbbf24;
|
||||
background: rgba(251, 191, 36, 0.12);
|
||||
border-color: rgba(251, 191, 36, 0.4);
|
||||
}
|
||||
`]
|
||||
})
|
||||
export class WritingCoachTriggerComponent {
|
||||
readonly Lightbulb = Lightbulb;
|
||||
private readonly coach = inject(WritingCoachService);
|
||||
private readonly topicKey = signal('');
|
||||
|
||||
@Input({ required: true }) set topic(value: string) { this.topicKey.set(value); }
|
||||
|
||||
readonly active = computed(() => this.coach.topic() === this.topicKey());
|
||||
|
||||
onClick(event: MouseEvent): void {
|
||||
// Peut vivre dans l'en-tête d'une section repliable : ne pas la replier/déplier.
|
||||
event.stopPropagation();
|
||||
this.coach.toggle(this.topicKey());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
|
||||
/**
|
||||
* Coach d'écriture (Mentor d'écriture, phase M1 — voir docs/conception-mentor-ecriture.md).
|
||||
*
|
||||
* État global du panneau de conseils : un seul sujet ouvert à la fois, identifié
|
||||
* par une clé « entité.champ » (ex. `scene.choices`) qui pointe vers
|
||||
* `writingCoach.topics.<clé>` dans les fichiers i18n. Contenu 100 % statique :
|
||||
* pas d'IA, pas d'appel réseau.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class WritingCoachService {
|
||||
private readonly current = signal<string | null>(null);
|
||||
|
||||
/** Sujet actuellement affiché, ou null si le panneau est fermé. */
|
||||
readonly topic = this.current.asReadonly();
|
||||
|
||||
open(topic: string): void {
|
||||
this.current.set(topic);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.current.set(null);
|
||||
}
|
||||
|
||||
/** Re-cliquer sur le 💡 du sujet ouvert referme le panneau. */
|
||||
toggle(topic: string): void {
|
||||
this.current.set(this.current() === topic ? null : topic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { Component, Input, inject } from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { TranslatePipe, TranslateService } from '@ngx-translate/core';
|
||||
import { LucideAngularModule, ArrowRight } from 'lucide-angular';
|
||||
|
||||
import { WritingRemark } from '../../services/writing-review.model';
|
||||
import { remarkAction } from '../../campaigns/writing-remark-action.helper';
|
||||
import { GapAction } from '../../campaigns/gap-action.helper';
|
||||
|
||||
/**
|
||||
* Une remarque de relecture, en posture « mentor » : ce que j'observe, pourquoi
|
||||
* ça compte, puis une question pour faire réfléchir (jamais de réécriture).
|
||||
* Le texte vient de l'i18n `writingReview.rules.<ruleId>` ; le back fournit les paramètres.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-writing-remark-card',
|
||||
imports: [RouterLink, TranslatePipe, LucideAngularModule],
|
||||
template: `
|
||||
<article class="remark">
|
||||
<p class="remark-observation">{{ key('observation') | translate: textParams }}</p>
|
||||
<p class="remark-why">{{ key('why') | translate: textParams }}</p>
|
||||
<p class="remark-question">{{ key('question') | translate: textParams }}</p>
|
||||
@if (showLink) {
|
||||
<a class="remark-link" [routerLink]="action.link" [queryParams]="action.queryParams ?? null">
|
||||
{{ 'writingReview.see' | translate }}
|
||||
<lucide-icon [img]="ArrowRight" [size]="13"></lucide-icon>
|
||||
</a>
|
||||
}
|
||||
</article>
|
||||
`,
|
||||
styles: [`
|
||||
.remark {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
padding: 0.8rem 0.95rem;
|
||||
border-radius: 8px;
|
||||
background: #111827;
|
||||
border: 1px solid #1f2937;
|
||||
border-left: 3px solid #fbbf24;
|
||||
}
|
||||
p { margin: 0; line-height: 1.5; }
|
||||
.remark-observation { font-size: 0.88rem; font-weight: 600; color: #f3f4f6; }
|
||||
.remark-why { font-size: 0.84rem; color: #9ca3af; }
|
||||
.remark-question { font-size: 0.86rem; font-style: italic; color: #fcd34d; }
|
||||
.remark-link {
|
||||
align-self: flex-start;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
margin-top: 0.2rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #a5b4fc;
|
||||
text-decoration: none;
|
||||
}
|
||||
.remark-link:hover { color: #c7d2fe; text-decoration: underline; }
|
||||
.remark-link:focus-visible { outline: 2px solid #6c63ff; outline-offset: 2px; border-radius: 4px; }
|
||||
`]
|
||||
})
|
||||
export class WritingRemarkCardComponent {
|
||||
readonly ArrowRight = ArrowRight;
|
||||
private readonly translate = inject(TranslateService);
|
||||
|
||||
@Input({ required: true }) remark!: WritingRemark;
|
||||
@Input() campaignId = '';
|
||||
/** Lien vers l'éditeur concerné (inutile quand on est déjà dans cet éditeur). */
|
||||
@Input() showLink = true;
|
||||
|
||||
key(part: 'observation' | 'why' | 'question'): string {
|
||||
return `writingReview.rules.${this.remark.ruleId}.${part}`;
|
||||
}
|
||||
|
||||
get action(): GapAction {
|
||||
return remarkAction(this.remark, this.campaignId);
|
||||
}
|
||||
|
||||
/** Paramètres du texte : ceux du back + le nom de l'entité + le genre de scène traduit. */
|
||||
get textParams(): Record<string, string> {
|
||||
const params: Record<string, string> = { ...this.remark.params, entity: this.remark.entityName ?? '' };
|
||||
const kind = this.remark.params['kind'];
|
||||
if (kind) {
|
||||
params['kind'] = this.translate.instant(kind === 'COMBAT' ? 'writingReview.kindCombat' : `sceneType.${kind}`);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { remarkAction } from '../../campaigns/writing-remark-action.helper';
|
||||
import { WritingRemark } from '../../services/writing-review.model';
|
||||
|
||||
/**
|
||||
* Garde-fou de la relecture d'éditeur : chaque règle émise par le Core
|
||||
* (WritingReviewService.java) doit avoir ses 3 textes en fr ET en en, sinon la
|
||||
* carte afficherait des clés brutes.
|
||||
*/
|
||||
const SERVICE = join(process.cwd(), '../core/src/main/java/com/loremind/application/campaigncontext/WritingReviewService.java');
|
||||
const FRAGMENTS_DIR = join(process.cwd(), 'src/assets/i18n/fragments');
|
||||
|
||||
function emittedRules(): string[] {
|
||||
const java = readFileSync(SERVICE, 'utf-8');
|
||||
return [...new Set([...java.matchAll(/"(WRITE-\d{3}-[A-Z-]+)"/g)].map(m => m[1]))].sort();
|
||||
}
|
||||
|
||||
function rulesOf(lang: 'fr' | 'en'): Record<string, Record<string, string>> {
|
||||
return JSON.parse(readFileSync(join(FRAGMENTS_DIR, `writing-review.${lang}.json`), 'utf-8')).writingReview.rules;
|
||||
}
|
||||
|
||||
describe('writing review content', () => {
|
||||
const rules = emittedRules();
|
||||
|
||||
it('finds the rules emitted by the core', () => {
|
||||
expect(rules).toHaveLength(10);
|
||||
});
|
||||
|
||||
for (const lang of ['fr', 'en'] as const) {
|
||||
it.each(rules)(`${lang}: rule %s has its three texts`, ruleId => {
|
||||
const texts = rulesOf(lang)[ruleId];
|
||||
expect(texts, `${ruleId} manquant (${lang})`).toBeDefined();
|
||||
for (const part of ['observation', 'why', 'question']) {
|
||||
expect(texts[part]?.trim().length ?? 0, `${ruleId}.${part} vide (${lang})`).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it('has no orphan rule text', () => {
|
||||
expect(Object.keys(rulesOf('fr')).sort()).toEqual(rules);
|
||||
expect(Object.keys(rulesOf('en')).sort()).toEqual(rules);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remarkAction', () => {
|
||||
const base: WritingRemark = {
|
||||
entityType: 'SCENE', entityId: 's1', ruleId: 'WRITE-007-NARRATION-DECIDES',
|
||||
category: 'NARRATION', params: {}, arcId: 'a1', chapterId: 'c1'
|
||||
};
|
||||
|
||||
it('opens the scene editor on the faulty section', () => {
|
||||
expect(remarkAction(base, 'camp')).toEqual({
|
||||
link: ['/campaigns', 'camp', 'arcs', 'a1', 'chapters', 'c1', 'scenes', 's1', 'edit'],
|
||||
queryParams: { focus: 'narration' }
|
||||
});
|
||||
});
|
||||
|
||||
it('opens the chapter view for a corridor, the chapter editor for missing stakes', () => {
|
||||
const chapter = { ...base, entityType: 'CHAPTER' as const, entityId: 'c1' };
|
||||
expect(remarkAction({ ...chapter, ruleId: 'WRITE-001-CORRIDOR' }, 'camp').link)
|
||||
.toEqual(['/campaigns', 'camp', 'arcs', 'a1', 'chapters', 'c1']);
|
||||
expect(remarkAction({ ...chapter, ruleId: 'WRITE-005-NO-STAKES' }, 'camp')).toEqual({
|
||||
link: ['/campaigns', 'camp', 'arcs', 'a1', 'chapters', 'c1', 'edit'],
|
||||
queryParams: { focus: 'stakes' }
|
||||
});
|
||||
});
|
||||
|
||||
it('falls back to the campaign hub for campaign-wide remarks', () => {
|
||||
const r = { ...base, entityType: 'CAMPAIGN' as const, entityId: 'camp', ruleId: 'WRITE-010-UNTYPED-SCENES' };
|
||||
expect(remarkAction(r, 'camp').link).toEqual(['/campaigns', 'camp']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
import { Component, Input, OnChanges, SimpleChanges, inject } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { LucideAngularModule, ChevronDown, ChevronRight, Lightbulb } from 'lucide-angular';
|
||||
|
||||
import { ReadinessEntityType } from '../../services/readiness.model';
|
||||
import { WritingRemark } from '../../services/writing-review.model';
|
||||
import { WritingReviewService } from '../../services/writing-review.service';
|
||||
import { WritingRemarkCardComponent } from './writing-remark-card.component';
|
||||
|
||||
/**
|
||||
* Encart « Conseils de relecture » d'un éditeur (scène / chapitre / arc) : les remarques
|
||||
* de la relecture d'éditeur qui concernent l'entité ouverte. Invisible s'il n'y en a pas.
|
||||
*
|
||||
* La relecture porte sur la version ENREGISTRÉE : après une sauvegarde, l'encart se met
|
||||
* à jour au prochain chargement de l'éditeur.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-writing-review-hints',
|
||||
imports: [TranslatePipe, LucideAngularModule, WritingRemarkCardComponent],
|
||||
template: `
|
||||
@if (remarks.length > 0) {
|
||||
<section class="hints">
|
||||
<button type="button" class="hints-header" (click)="open = !open" [attr.aria-expanded]="open">
|
||||
<lucide-icon [img]="open ? ChevronDown : ChevronRight" [size]="15"></lucide-icon>
|
||||
<lucide-icon [img]="Lightbulb" [size]="15" class="hints-icon"></lucide-icon>
|
||||
<span>{{ 'writingReview.hintsTitle' | translate: { n: remarks.length } }}</span>
|
||||
</button>
|
||||
@if (open) {
|
||||
<div class="hints-list">
|
||||
@for (remark of remarks; track remark.ruleId) {
|
||||
<app-writing-remark-card [remark]="remark" [campaignId]="campaignId" [showLink]="false">
|
||||
</app-writing-remark-card>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
`,
|
||||
styles: [`
|
||||
.hints {
|
||||
background: rgba(251, 191, 36, 0.04);
|
||||
border: 1px solid rgba(251, 191, 36, 0.25);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.hints-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.7rem 0.95rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
color: #fde68a;
|
||||
font-size: 0.88rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
.hints-header:hover { background: rgba(251, 191, 36, 0.06); }
|
||||
.hints-header:focus-visible { outline: 2px solid #6c63ff; outline-offset: -2px; }
|
||||
.hints-icon { color: #fbbf24; }
|
||||
.hints-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0 0.95rem 0.95rem;
|
||||
}
|
||||
`]
|
||||
})
|
||||
export class WritingReviewHintsComponent implements OnChanges {
|
||||
readonly ChevronDown = ChevronDown;
|
||||
readonly ChevronRight = ChevronRight;
|
||||
readonly Lightbulb = Lightbulb;
|
||||
|
||||
private readonly reviewService = inject(WritingReviewService);
|
||||
|
||||
@Input({ required: true }) campaignId = '';
|
||||
@Input({ required: true }) entityType: ReadinessEntityType = 'SCENE';
|
||||
@Input({ required: true }) entityId = '';
|
||||
|
||||
remarks: WritingRemark[] = [];
|
||||
open = true;
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (!this.campaignId || !this.entityId) return;
|
||||
if (changes['campaignId'] || changes['entityId'] || changes['entityType']) {
|
||||
this.remarks = [];
|
||||
const { entityType, entityId } = this;
|
||||
this.reviewService.getReview(this.campaignId).subscribe({
|
||||
next: report => {
|
||||
this.remarks = report.remarks.filter(r => r.entityType === entityType && r.entityId === entityId);
|
||||
},
|
||||
error: () => { this.remarks = []; }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
@if (report) {
|
||||
<section class="review-panel">
|
||||
<button type="button" class="review-header" (click)="toggle()" [attr.aria-expanded]="!collapsed">
|
||||
<lucide-icon [img]="collapsed ? ChevronRight : ChevronDown" [size]="16"></lucide-icon>
|
||||
<lucide-icon [img]="Lightbulb" [size]="16" class="review-icon"></lucide-icon>
|
||||
<span class="review-title">{{ 'writingReview.title' | translate }}</span>
|
||||
@if (total > 0) {
|
||||
<span class="review-count">{{ 'writingReview.countN' | translate: { n: total } }}</span>
|
||||
}
|
||||
</button>
|
||||
|
||||
@if (!collapsed) {
|
||||
<div class="review-body">
|
||||
@if (total === 0) {
|
||||
<p class="review-empty">{{ 'writingReview.allGood' | translate }}</p>
|
||||
} @else {
|
||||
<p class="review-intro">{{ 'writingReview.intro' | translate }}</p>
|
||||
@for (group of groups; track group.category) {
|
||||
<div class="review-group">
|
||||
<h3>{{ ('writingReview.categories.' + group.category) | translate }}</h3>
|
||||
<div class="review-list">
|
||||
@for (remark of visible(group); track remark.ruleId + remark.entityId) {
|
||||
<app-writing-remark-card [remark]="remark" [campaignId]="campaignId"></app-writing-remark-card>
|
||||
}
|
||||
</div>
|
||||
@if (group.remarks.length > perGroup && !expanded.has(group.category)) {
|
||||
<button type="button" class="review-more" (click)="showAll(group.category)">
|
||||
{{ 'writingReview.showMore' | translate: { n: group.remarks.length - perGroup } }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// Même gabarit que « Prochaines étapes » (readiness-panel), accent ambré du mentor.
|
||||
.review-panel {
|
||||
margin: 0 0 1.25rem;
|
||||
background: #0d1117;
|
||||
border: 1px solid #1f2937;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.review-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
width: 100%;
|
||||
padding: 0.7rem 0.9rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #e5e7eb;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
|
||||
&:hover { background: #111827; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; outline-offset: -2px; }
|
||||
|
||||
.review-icon { color: #fbbf24; }
|
||||
}
|
||||
|
||||
.review-title {
|
||||
font-weight: 600;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.review-count {
|
||||
margin-left: auto;
|
||||
padding: 0.1rem 0.5rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 500;
|
||||
background: #3a2e1a;
|
||||
color: #fcd34d;
|
||||
}
|
||||
|
||||
.review-body {
|
||||
padding: 0 0.9rem 0.9rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.review-intro,
|
||||
.review-empty {
|
||||
margin: 0;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.5;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.review-empty { color: #86efac; }
|
||||
|
||||
.review-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: #6b7280;
|
||||
}
|
||||
}
|
||||
|
||||
.review-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.review-more {
|
||||
align-self: flex-start;
|
||||
padding: 0.2rem 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: #a5b4fc;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover { text-decoration: underline; }
|
||||
&:focus-visible { outline: 2px solid #6c63ff; border-radius: 4px; }
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { Component, Input, OnChanges, SimpleChanges, inject } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { LucideAngularModule, ChevronDown, ChevronRight, Lightbulb } from 'lucide-angular';
|
||||
|
||||
import { WritingReviewService } from '../../services/writing-review.service';
|
||||
import {
|
||||
WRITING_REMARK_CATEGORIES, WritingRemark, WritingRemarkCategory, WritingReviewReport
|
||||
} from '../../services/writing-review.model';
|
||||
import { WritingRemarkCardComponent } from './writing-remark-card.component';
|
||||
|
||||
interface RemarkGroup {
|
||||
category: WritingRemarkCategory;
|
||||
remarks: WritingRemark[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Panneau « Relecture d'éditeur » du hub campagne (Mentor d'écriture, phase M2) :
|
||||
* le pendant « qualité » de « Prochaines étapes ». Conseils regroupés par famille,
|
||||
* chacun avec son lien vers l'éditeur concerné. Purement indicatif.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-writing-review-panel',
|
||||
imports: [TranslatePipe, LucideAngularModule, WritingRemarkCardComponent],
|
||||
templateUrl: './writing-review-panel.component.html',
|
||||
styleUrls: ['./writing-review-panel.component.scss']
|
||||
})
|
||||
export class WritingReviewPanelComponent implements OnChanges {
|
||||
readonly ChevronDown = ChevronDown;
|
||||
readonly ChevronRight = ChevronRight;
|
||||
readonly Lightbulb = Lightbulb;
|
||||
|
||||
/** Remarques visibles par famille avant « voir les autres ». */
|
||||
readonly perGroup = 3;
|
||||
|
||||
private static readonly STORAGE_KEY = 'loremind.writingReview.collapsed';
|
||||
private readonly reviewService = inject(WritingReviewService);
|
||||
|
||||
@Input({ required: true }) campaignId = '';
|
||||
|
||||
report: WritingReviewReport | null = null;
|
||||
groups: RemarkGroup[] = [];
|
||||
expanded = new Set<WritingRemarkCategory>();
|
||||
collapsed = readCollapsed();
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['campaignId'] && this.campaignId) {
|
||||
this.reviewService.getReview(this.campaignId).subscribe({
|
||||
next: report => {
|
||||
this.report = report;
|
||||
this.groups = WRITING_REMARK_CATEGORIES
|
||||
.map(category => ({ category, remarks: report.remarks.filter(r => r.category === category) }))
|
||||
.filter(g => g.remarks.length > 0);
|
||||
},
|
||||
// Conseil facultatif : en cas d'erreur, le panneau ne s'affiche simplement pas.
|
||||
error: () => { this.report = null; }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get total(): number {
|
||||
return this.report?.remarks.length ?? 0;
|
||||
}
|
||||
|
||||
toggle(): void {
|
||||
this.collapsed = !this.collapsed;
|
||||
try {
|
||||
localStorage.setItem(WritingReviewPanelComponent.STORAGE_KEY, this.collapsed ? '1' : '0');
|
||||
} catch { /* stockage indisponible : préférence non mémorisée */ }
|
||||
}
|
||||
|
||||
visible(group: RemarkGroup): WritingRemark[] {
|
||||
return this.expanded.has(group.category) ? group.remarks : group.remarks.slice(0, this.perGroup);
|
||||
}
|
||||
|
||||
showAll(category: WritingRemarkCategory): void {
|
||||
this.expanded.add(category);
|
||||
}
|
||||
}
|
||||
|
||||
function readCollapsed(): boolean {
|
||||
try {
|
||||
return localStorage.getItem('loremind.writingReview.collapsed') === '1';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user