Correction de plusieurs anomalies : problème de switch entre 2 templates (par exemple si on était sur un template 1 et qu'on voulait passer directement au 2, ce dernier ne chargeait pas) ; correction du soucis d'apparition de la sidebar à gauche qui disparaissait sans explication ; problème de redirection : lorsqu'on terminait de créer un PJ / PNJ ; on arrivait sur l'accueil de la campagne au lieu de voir le résultat de la création. Problème de redirection également lors du clique sur un PNJ / PJ sur le coté : on arrivait sur l'édition au lieu de la présentation. Correction de la première lettre stylisée : tout est au même style comme ça plus de probleme de lecture. Nouveautées : stylisation des modales (notamment suppression, warning.....) avec en prime l'ajout d'un warning lors du changement de système pour avertir que les fiches persos ne sont pas conservées. Ajout d'une option pour créer un game system directement à la création d'une campagne afin de faciliter la mise en place de cette dernière. Ajout d'un bouton pour créer un nouveau template directement lorsqu'on créer une page : ça permet de créer un template et de revenir sur la page qu'on était en train de créer sans perdre le titre. Passage en bêta 0.8.4
98 lines
3.8 KiB
TypeScript
98 lines
3.8 KiB
TypeScript
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { forkJoin } from 'rxjs';
|
|
import { LucideAngularModule } from 'lucide-angular';
|
|
import { CampaignService } from '../../../services/campaign.service';
|
|
import { CharacterService } from '../../../services/character.service';
|
|
import { NpcService } from '../../../services/npc.service';
|
|
import { LayoutService } from '../../../services/layout.service';
|
|
import { loadCampaignTreeData, buildCampaignSidebarConfig } from '../../campaign-tree.helper';
|
|
import { IconPickerComponent } from '../../../shared/icon-picker/icon-picker.component';
|
|
import { CAMPAIGN_ICON_OPTIONS } from '../../campaign-icons';
|
|
|
|
/**
|
|
* Écran de création d'une nouvelle scène rattachée à un chapitre.
|
|
* Route : /campaigns/:campaignId/arcs/:arcId/chapters/:chapterId/scenes/create
|
|
*/
|
|
@Component({
|
|
selector: 'app-scene-create',
|
|
standalone: true,
|
|
imports: [CommonModule, ReactiveFormsModule, LucideAngularModule, IconPickerComponent],
|
|
templateUrl: './scene-create.component.html',
|
|
styleUrls: ['./scene-create.component.scss']
|
|
})
|
|
export class SceneCreateComponent implements OnInit, OnDestroy {
|
|
readonly campaignIconOptions = CAMPAIGN_ICON_OPTIONS;
|
|
selectedIcon: string | null = null;
|
|
|
|
form: FormGroup;
|
|
campaignId = '';
|
|
arcId = '';
|
|
chapterId = '';
|
|
chapterName = '';
|
|
private existingSceneCount = 0;
|
|
|
|
constructor(
|
|
private fb: FormBuilder,
|
|
private route: ActivatedRoute,
|
|
private router: Router,
|
|
private campaignService: CampaignService,
|
|
private characterService: CharacterService,
|
|
private npcService: NpcService,
|
|
private layoutService: LayoutService
|
|
) {
|
|
this.form = this.fb.group({
|
|
name: ['', Validators.required],
|
|
description: ['']
|
|
});
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.campaignId = this.route.snapshot.paramMap.get('campaignId')!;
|
|
this.arcId = this.route.snapshot.paramMap.get('arcId')!;
|
|
this.chapterId = this.route.snapshot.paramMap.get('chapterId')!;
|
|
this.loadLayout();
|
|
}
|
|
|
|
private loadLayout(): void {
|
|
forkJoin({
|
|
campaign: this.campaignService.getCampaignById(this.campaignId),
|
|
allCampaigns: this.campaignService.getAllCampaigns(),
|
|
treeData: loadCampaignTreeData(this.campaignService, this.campaignId, this.characterService, this.npcService)
|
|
}).subscribe(({ campaign, allCampaigns, treeData }) => {
|
|
const currentChapter = (treeData.chaptersByArc[this.arcId] ?? []).find(c => c.id === this.chapterId);
|
|
this.chapterName = currentChapter?.name ?? '';
|
|
this.existingSceneCount = treeData.scenesByChapter[this.chapterId]?.length ?? 0;
|
|
|
|
this.layoutService.show(buildCampaignSidebarConfig(campaign, allCampaigns, treeData, this.campaignId));
|
|
});
|
|
}
|
|
|
|
submit(): void {
|
|
if (this.form.invalid) return;
|
|
this.campaignService.createScene({
|
|
name: this.form.value.name,
|
|
description: this.form.value.description,
|
|
chapterId: this.chapterId,
|
|
order: this.existingSceneCount + 1,
|
|
icon: this.selectedIcon
|
|
}).subscribe({
|
|
next: (created) => this.router.navigate(['/campaigns', this.campaignId, 'arcs', this.arcId, 'chapters', this.chapterId, 'scenes', created.id]),
|
|
error: () => console.error('Erreur lors de la création de la scène')
|
|
});
|
|
}
|
|
|
|
cancel(): void {
|
|
this.router.navigate(['/campaigns', this.campaignId]);
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
// Volontairement vide : la sidebar reste prise en charge par le composant
|
|
// suivant (autre sous-route ou le composant detail parent) qui appellera
|
|
// show(). Eviter d'appeler hide() ici previent le clignotement / la
|
|
// disparition de la sidebar lors des navigations internes a la section.
|
|
}
|
|
}
|