Fix : problème d'ascenseur en bas de la page au niveau des templates
Sélection du template par défaut lors de la création d'une page en fonction du dossier Passage v0.6.2
This commit is contained in:
@@ -87,7 +87,8 @@
|
||||
|
||||
&.selected {
|
||||
border-color: #6c63ff;
|
||||
background: #1e1c3a;
|
||||
background: #2a2558;
|
||||
box-shadow: 0 0 0 1px #6c63ff, 0 0 12px rgba(108, 99, 255, 0.35);
|
||||
}
|
||||
|
||||
.template-card-head {
|
||||
|
||||
@@ -94,8 +94,28 @@ export class PageCreateComponent implements OnInit, OnDestroy {
|
||||
if (this.preselectedNodeId) {
|
||||
this.form.patchValue({ nodeId: this.preselectedNodeId });
|
||||
this.form.get('nodeId')?.disable();
|
||||
this.autoSelectTemplateForNode(this.preselectedNodeId);
|
||||
} else {
|
||||
// Pas de nodeId dans l'URL : le <select> affiche visuellement la
|
||||
// première option mais la valeur du FormControl reste ''. On tente
|
||||
// l'auto-sélection inverse : si un seul template a un defaultNodeId
|
||||
// qui pointe sur un dossier existant, on le sélectionne et on
|
||||
// pré-remplit le dossier — sinon on laisse l'utilisateur choisir.
|
||||
const validNodeIds = new Set(this.nodes.map(n => n.id));
|
||||
const candidates = this.templates.filter(
|
||||
t => t.defaultNodeId && validNodeIds.has(t.defaultNodeId)
|
||||
);
|
||||
if (candidates.length === 1) {
|
||||
const tpl = candidates[0];
|
||||
this.selectedTemplateId = tpl.id!;
|
||||
this.form.patchValue({ nodeId: tpl.defaultNodeId });
|
||||
}
|
||||
}
|
||||
|
||||
this.form.get('nodeId')?.valueChanges.subscribe(nodeId => {
|
||||
this.autoSelectTemplateForNode(nodeId);
|
||||
});
|
||||
|
||||
this.restoreDraft();
|
||||
});
|
||||
}
|
||||
@@ -137,6 +157,18 @@ export class PageCreateComponent implements OnInit, OnDestroy {
|
||||
} catch { /* JSON corrompu : on ignore */ }
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-sélection du template dont defaultNodeId === nodeId courant.
|
||||
* Ne fait rien si l'utilisateur a déjà choisi un template manuellement
|
||||
* (on ne veut pas écraser un choix explicite).
|
||||
*/
|
||||
private autoSelectTemplateForNode(nodeId: string | null | undefined): void {
|
||||
if (!nodeId) return;
|
||||
if (this.selectedTemplateId) return;
|
||||
const matching = this.templates.find(t => t.defaultNodeId === nodeId);
|
||||
if (matching) this.selectedTemplateId = matching.id!;
|
||||
}
|
||||
|
||||
selectTemplate(template: Template): void {
|
||||
this.selectedTemplateId = template.id!;
|
||||
// Si pas de noeud pré-choisi par l'URL, on pré-remplit avec le defaultNodeId du template.
|
||||
|
||||
Reference in New Issue
Block a user