diff --git a/web/src/app/campaigns/campaign-tree.helper.ts b/web/src/app/campaigns/campaign-tree.helper.ts index 109a20e..7631fc1 100644 --- a/web/src/app/campaigns/campaign-tree.helper.ts +++ b/web/src/app/campaigns/campaign-tree.helper.ts @@ -80,30 +80,30 @@ export function buildCampaignTree(campaignId: string, data: CampaignTreeData): T label: sc.name, route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/${ch.id}/scenes/${sc.id}` })); - sceneItems.push({ - id: `new-scene-${ch.id}`, - label: '+ Nouvelle scène', - isAction: true, - route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/${ch.id}/scenes/create` - }); return { id: `chapter-${ch.id}`, label: ch.name, children: sceneItems, - route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/${ch.id}` + route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/${ch.id}`, + createActions: [{ + id: `new-scene-${ch.id}`, + label: 'Nouvelle scène', + route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/${ch.id}/scenes/create`, + actionIcon: 'plus' + }] }; }); - chapterItems.push({ - id: `new-chapter-${arc.id}`, - label: '+ Nouveau chapitre', - isAction: true, - route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/create` - }); return { id: `arc-${arc.id}`, label: arc.name, children: chapterItems, - route: `/campaigns/${campaignId}/arcs/${arc.id}` + route: `/campaigns/${campaignId}/arcs/${arc.id}`, + createActions: [{ + id: `new-chapter-${arc.id}`, + label: 'Nouveau chapitre', + route: `/campaigns/${campaignId}/arcs/${arc.id}/chapters/create`, + actionIcon: 'plus' + }] }; }); } diff --git a/web/src/app/lore/lore-sidebar.helper.ts b/web/src/app/lore/lore-sidebar.helper.ts index b59e32b..874fc9b 100644 --- a/web/src/app/lore/lore-sidebar.helper.ts +++ b/web/src/app/lore/lore-sidebar.helper.ts @@ -75,19 +75,7 @@ export function buildLoreSidebarConfig(data: LoreSidebarData): SecondarySidebarC id: `page-${p.id}`, label: p.title, route: `/lore/${lore.id}/pages/${p.id}` - })), - { - id: `create-folder-${node.id}`, - label: '+ Nouveau dossier', - isAction: true, - route: `/lore/${lore.id}/folders/${node.id}/create` - }, - { - id: `create-page-${node.id}`, - label: '+ Nouvelle page', - isAction: true, - route: `/lore/${lore.id}/nodes/${node.id}/pages/create` - } + })) ]; // IDs préfixés par type — chaque entité a sa propre séquence IDENTITY en base, // donc node.id=1 et page.id=1 peuvent coexister et collisionner dans le @@ -98,7 +86,21 @@ export function buildLoreSidebarConfig(data: LoreSidebarData): SecondarySidebarC iconKey: node.icon ?? undefined, route: `/lore/${lore.id}/folders/${node.id}/edit`, meta: nodePages.length > 0 ? String(nodePages.length) : undefined, - children + children, + createActions: [ + { + id: `create-folder-${node.id}`, + label: 'Nouveau sous-dossier', + route: `/lore/${lore.id}/folders/${node.id}/create`, + actionIcon: 'folder-plus' + }, + { + id: `create-page-${node.id}`, + label: 'Nouvelle page', + route: `/lore/${lore.id}/nodes/${node.id}/pages/create`, + actionIcon: 'file-plus' + } + ] }; }; diff --git a/web/src/app/services/layout.service.ts b/web/src/app/services/layout.service.ts index 844a68e..2911ab3 100644 --- a/web/src/app/services/layout.service.ts +++ b/web/src/app/services/layout.service.ts @@ -11,6 +11,21 @@ export interface TreeItem { iconKey?: string; /** Petit badge affiché à droite (ex: "3" pour compter les pages d'un dossier). */ meta?: string; + /** + * Actions de creation contextuelles (ex: "+ Nouveau chapitre" sur un arc). + * Affichees comme boutons icone au survol du noeud (repli visuel), et en + * pleine largeur si le noeud est expanded sans aucun enfant reel + * (empty-state inline, meilleur des deux mondes). + */ + createActions?: TreeCreateAction[]; +} + +export interface TreeCreateAction { + id: string; + label: string; // tooltip au hover, texte complet en empty-state + route: string; + /** Cle d'icone cote sidebar (plus | folder-plus | file-plus). */ + actionIcon?: 'plus' | 'folder-plus' | 'file-plus'; } export interface GlobalItem { diff --git a/web/src/app/shared/secondary-sidebar/secondary-sidebar.component.html b/web/src/app/shared/secondary-sidebar/secondary-sidebar.component.html index 15b4c0a..e2a0523 100644 --- a/web/src/app/shared/secondary-sidebar/secondary-sidebar.component.html +++ b/web/src/app/shared/secondary-sidebar/secondary-sidebar.component.html @@ -30,7 +30,7 @@