From f5ac57d073346a0b6ea27e0ad59873a338d062a8 Mon Sep 17 00:00:00 2001
From: VIAUD Nathan <nathan.viaud@inria.fr>
Date: Thu, 24 Apr 2025 16:24:04 +0200
Subject: [PATCH] improvement: remove chapter label

---
 package-lock.json                             |  8 ++---
 package.json                                  |  2 +-
 src/features/ePocFlow/nodes/ChapterNode.vue   | 34 +++++++++++--------
 src/shared/classes/epoc-v1.ts                 |  4 ---
 src/shared/data/forms/nodeForm.data.ts        | 14 ++++----
 src/shared/interfaces/form/input.interface.ts |  2 +-
 src/shared/services/graph.service.ts          |  2 +-
 7 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index f6ed32fd..b6dcfcb3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,7 @@
             "license": "CeCILL-B",
             "dependencies": {
                 "@electron/notarize": "^1.2.2",
-                "@epoc/epoc-types": "^2.0.0-beta.19",
+                "@epoc/epoc-types": "^2.0.0-beta.20",
                 "@meforma/vue-toaster": "^1.3.0",
                 "@tinymce/tinymce-vue": "^6.1.0",
                 "@vue-flow/core": "^1.41.2",
@@ -765,9 +765,9 @@
             }
         },
         "node_modules/@epoc/epoc-types": {
-            "version": "2.0.0-beta.19",
-            "resolved": "https://registry.npmjs.org/@epoc/epoc-types/-/epoc-types-2.0.0-beta.19.tgz",
-            "integrity": "sha512-jBaBCHMFF6q6Cp2/ujmKArLW7hXIwB5jmXc5OR8zSHI1dborPkRQao+zAPa4ogMon/v2MBn4YX9hf3VUYboTwg==",
+            "version": "2.0.0-beta.20",
+            "resolved": "https://registry.npmjs.org/@epoc/epoc-types/-/epoc-types-2.0.0-beta.20.tgz",
+            "integrity": "sha512-6t5Q2o2IMbUNdFQdI/01ZhJSj+GDkrkikfnpfJHAQHjprwhug9sRyEQBby1Og2KW4FAC4tV8+GsB7xSp94d4yw==",
             "license": "CeCILL-B"
         },
         "node_modules/@esbuild/aix-ppc64": {
diff --git a/package.json b/package.json
index b9f106e0..6787a76b 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
     },
     "dependencies": {
         "@electron/notarize": "^1.2.2",
-        "@epoc/epoc-types": "^2.0.0-beta.19",
+        "@epoc/epoc-types": "^2.0.0-beta.20",
         "@meforma/vue-toaster": "^1.3.0",
         "@tinymce/tinymce-vue": "^6.1.0",
         "@vue-flow/core": "^1.41.2",
diff --git a/src/features/ePocFlow/nodes/ChapterNode.vue b/src/features/ePocFlow/nodes/ChapterNode.vue
index 40db90e7..251d0787 100644
--- a/src/features/ePocFlow/nodes/ChapterNode.vue
+++ b/src/features/ePocFlow/nodes/ChapterNode.vue
@@ -17,14 +17,6 @@ const { findNode, nodes, edges } = useVueFlow('main');
 
 const currentNode = findNode(props.id);
 
-const subtitle = computed(() => {
-    const epocNode = findNode('1');
-    const chapterParameter = epocNode?.data?.formValues?.chapterParameter || t('global.chapter');
-    const label = chapterParameter.length > 8 ? chapterParameter.substring(0, 7) + '...' : chapterParameter;
-
-    return `${label} ${currentNode.data.index}`;
-});
-
 const isSource = computed(() => getConnectedEdges([currentNode], edges.value).some((edge) => edge.source === props.id));
 
 const classList = {
@@ -68,12 +60,6 @@ const connectedBadges = computed(() => getConnectedBadges(currentNode.data.conte
                 <small>{{ connectedBadges.length }}</small>
             </div>
 
-            <p
-                class="node-title"
-                :class="{ active: editorStore.openedElementId ? editorStore.openedElementId === props.id : false }"
-            >
-                {{ currentNode.data.formValues.title }}
-            </p>
             <ContentButton
                 :id="currentNode.data.contentId"
                 :data-testid="`chapter-${currentNode.data.index}`"
@@ -81,7 +67,8 @@ const connectedBadges = computed(() => getConnectedBadges(currentNode.data.conte
                 :is-draggable="false"
                 :class-list="classList"
                 :is-active="editorStore.openedElementId ? editorStore.openedElementId === currentNode.id : false"
-                :subtitle="subtitle"
+                :subtitle="currentNode.data.formValues.title || t('global.chapter')"
+                class="chapter-node"
                 @click="openForm()"
                 @mousedown="mouseDown"
                 @contextmenu="onContextMenu"
@@ -98,3 +85,20 @@ const connectedBadges = computed(() => getConnectedBadges(currentNode.data.conte
         />
     </div>
 </template>
+
+<style lang="scss">
+.chapter-node > .text {
+    overflow: hidden;
+    padding: 0.25rem;
+    width: 100%;
+    box-sizing: border-box;
+
+    & > span {
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        width: 100%;
+        text-align: center;
+    }
+}
+</style>
diff --git a/src/shared/classes/epoc-v1.ts b/src/shared/classes/epoc-v1.ts
index 4ecddd03..67eb7075 100644
--- a/src/shared/classes/epoc-v1.ts
+++ b/src/shared/classes/epoc-v1.ts
@@ -46,7 +46,6 @@ export class EpocV1 implements Epoc {
         certificateBadgeCount: number,
         authors: Author[],
         plugins: string[],
-        chapterParameter: string,
         chapterDuration: number,
         lastModif: string,
         lang: string,
@@ -66,9 +65,6 @@ export class EpocV1 implements Epoc {
         this.certificateBadgeCount = certificateBadgeCount;
         this.authors = authors;
         this.plugins = plugins;
-        this.parameters = {
-            chapterParameter,
-        };
         this.chapterDuration = chapterDuration;
         this.chapters = {};
         this.contents = {};
diff --git a/src/shared/data/forms/nodeForm.data.ts b/src/shared/data/forms/nodeForm.data.ts
index 9f364299..5bd405cd 100644
--- a/src/shared/data/forms/nodeForm.data.ts
+++ b/src/shared/data/forms/nodeForm.data.ts
@@ -118,6 +118,13 @@ export const chapterForm: ComputedRef<Form> = computed(() => ({
                     value: '',
                     placeholder: i18n.global.t('forms.type'),
                 },
+                {
+                    id: 'subtitle',
+                    type: 'text',
+                    label: i18n.global.t('forms.node.subtitle'),
+                    value: '',
+                    placeholder: i18n.global.t('forms.type'),
+                },
                 {
                     id: 'duration',
                     type: 'score',
@@ -286,13 +293,6 @@ export const epocForm: ComputedRef<Form> = computed(() => ({
                     value: 10,
                     hint: i18n.global.t('forms.node.certificateScoreHint'),
                 },
-                {
-                    id: 'chapterParameter',
-                    type: 'text',
-                    label: i18n.global.t('forms.node.chapterLabel'),
-                    value: '',
-                    placeholder: i18n.global.t('forms.type'),
-                },
                 {
                     id: 'chapterDuration',
                     type: 'score',
diff --git a/src/shared/interfaces/form/input.interface.ts b/src/shared/interfaces/form/input.interface.ts
index 28b0bc88..a1880035 100644
--- a/src/shared/interfaces/form/input.interface.ts
+++ b/src/shared/interfaces/form/input.interface.ts
@@ -23,7 +23,7 @@ export interface Input {
     icon?: string;
     inputs?: Input[];
     addButton?: boolean;
-    options?: string[];
+    options?: string[] | { value: string; label: string }[];
     linkedOptions?: string;
     targetDirectory?: string;
     hint?: string;
diff --git a/src/shared/services/graph.service.ts b/src/shared/services/graph.service.ts
index 6af44144..3f316bb1 100644
--- a/src/shared/services/graph.service.ts
+++ b/src/shared/services/graph.service.ts
@@ -89,7 +89,6 @@ function createContentJSON(): EpocV1 {
         ePocValues.certificateBadgeCount || 1,
         ePocValues.authors || {},
         plugins,
-        ePocValues.chapterParameter,
         ePocValues.chapterDuration,
         new Date().toISOString(),
         ePocValues.lang,
@@ -105,6 +104,7 @@ function createContentJSON(): EpocV1 {
         const chapterValues = chapter.data.formValues;
         epoc.addChapter(chapter.data.contentId, {
             title: chapterValues.title || '',
+            subtitle: chapterValues.subtitle || '',
             objectives: chapterValues.objectives || [],
             contents: [],
             duration: chapterValues.duration || 0,
-- 
GitLab