From f024db5cdcea2302e5124c260c16a9ffc017475d Mon Sep 17 00:00:00 2001
From: VIAUD Nathan <nathan.viaud@inria.fr>
Date: Tue, 5 Dec 2023 16:53:48 +0000
Subject: [PATCH] improvement: adding licence field to ePoc form

---
 package-lock.json                      | 10 +++++-----
 src/shared/classes/epoc-v1.ts          | 10 ++++++++--
 src/shared/data/forms/nodeForm.data.ts | 19 +++++++++++++++++++
 src/shared/services/graph.service.ts   |  9 ++++++++-
 4 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 8384fdc5..b91083d5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "epoc-editor",
-  "version": "0.1.5-beta",
+  "version": "0.1.6-beta",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "epoc-editor",
-      "version": "0.1.5-beta",
+      "version": "0.1.6-beta",
       "license": "CeCILL-B",
       "dependencies": {
         "@epoc/epoc-types": "git+https://gitlab.inria.fr/learninglab/epoc/epoc-types.git",
@@ -287,8 +287,8 @@
       }
     },
     "node_modules/@epoc/epoc-types": {
-      "version": "2.0.0-beta.7",
-      "resolved": "git+https://gitlab.inria.fr/learninglab/epoc/epoc-types.git#a5ba071f37736b019aa325fe88ad0f4e87eda22d",
+      "version": "2.0.0-beta.9",
+      "resolved": "git+https://gitlab.inria.fr/learninglab/epoc/epoc-types.git#45703d42f147b1abf80f217f958a65447de5aa36",
       "license": "CeCILL-B"
     },
     "node_modules/@esbuild/android-arm": {
@@ -13427,7 +13427,7 @@
       }
     },
     "@epoc/epoc-types": {
-      "version": "git+https://gitlab.inria.fr/learninglab/epoc/epoc-types.git#a5ba071f37736b019aa325fe88ad0f4e87eda22d",
+      "version": "git+https://gitlab.inria.fr/learninglab/epoc/epoc-types.git#45703d42f147b1abf80f217f958a65447de5aa36",
       "from": "@epoc/epoc-types@git+https://gitlab.inria.fr/learninglab/epoc/epoc-types.git"
     },
     "@esbuild/android-arm": {
diff --git a/src/shared/classes/epoc-v1.ts b/src/shared/classes/epoc-v1.ts
index f28f2e16..988e5739 100644
--- a/src/shared/classes/epoc-v1.ts
+++ b/src/shared/classes/epoc-v1.ts
@@ -1,7 +1,7 @@
 import { Chapter, Content, Epoc, html, Parameters, uid } from '@epoc/epoc-types/src/v1';
 import { Question } from '@epoc/epoc-types/src/v1/question';
 import { Author } from '@epoc/epoc-types/src/v1/author';
-import { Badge } from '@/src/shared/interfaces';
+import { Badge } from '@epoc/epoc-types/src/v1/badge';
 
 export class EpocV1 implements Epoc {
     id: string;
@@ -26,11 +26,16 @@ export class EpocV1 implements Epoc {
     questions: Record<uid, Question>;
     badges: Record<uid, Badge>;
     certificateBadgeCount: number;
+    license: {
+        name: string;
+        url: string;
+        content: string;
+    };
 
     constructor(
         id: string, title: string, image: string, objectives: string[], summary: html, teaser: string,
         thumbnail: string, edition: string, certificateScore: number, certificateBadgeCount: number, authors: Author[],
-        plugins: string[], chapterParameter: string, lastModif: string
+        plugins: string[], chapterParameter: string, lastModif: string, license: { name: string; url: string; content: string; }
     ) {
         this.version = '1';
         this.id = id;
@@ -53,6 +58,7 @@ export class EpocV1 implements Epoc {
         this.badges = {};
         this.questions = {};
         this.lastModif = lastModif;
+        this.license = license;
     }
 
     addChapter(id: uid, chapter: Chapter) {
diff --git a/src/shared/data/forms/nodeForm.data.ts b/src/shared/data/forms/nodeForm.data.ts
index f2210583..a5bfe337 100644
--- a/src/shared/data/forms/nodeForm.data.ts
+++ b/src/shared/data/forms/nodeForm.data.ts
@@ -310,6 +310,25 @@ export const epocForm: Form = {
                 }
             ]
         },
+        {
+            name: 'Licence',
+            inputs: [
+                {
+                    id: 'licenceName',
+                    type: 'text',
+                    label: 'Nom',
+                    placeholder: 'CC-BY 4.0',
+                    value: ''
+                },
+                {
+                    id: 'licenceUrl',
+                    type: 'text',
+                    label: 'URL',
+                    placeholder: 'https://creativecommons.org/licenses/by/4.0/deed',
+                    value: ''
+                }
+            ]
+        }
     ],
 };
 
diff --git a/src/shared/services/graph.service.ts b/src/shared/services/graph.service.ts
index dcbe4f64..0008146f 100644
--- a/src/shared/services/graph.service.ts
+++ b/src/shared/services/graph.service.ts
@@ -62,6 +62,8 @@ function createContentJSON() : EpocV1 {
     const validBadges = getValidBadges();
 
     const ePocValues = ePocNode.data.formValues;
+    
+    console.log('epocValues', ePocValues);
 
     const epoc = new EpocV1(
         ePocValues.id || 'E000XX',
@@ -77,7 +79,12 @@ function createContentJSON() : EpocV1 {
         ePocValues.authors || {},
         ePocValues.plugins,
         ePocValues.chapterParameter,
-        new Date().toISOString()
+        new Date().toISOString(),
+        {
+            name: ePocValues.licenceName || '',
+            url: ePocValues.licenceUrl || '',
+            content: ''
+        }
     );
 
     chapterNodes.forEach(chapter => {
-- 
GitLab