From e84e852f7087565460676cc3b71589f3385a3670 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 15 Nov 2019 09:36:05 +0100
Subject: [PATCH 1/7] WIP: add a sib-like component.

---
 src/includes/head.pug                     |  1 +
 src/includes/mentor/components/header.pug |  2 +-
 src/includes/mentor/resources/detail.pug  |  4 +-
 src/scripts/coopstarter.js                | 45 +++++++++++++++++++++++
 4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/src/includes/head.pug b/src/includes/head.pug
index 907cc5fc..5568626e 100644
--- a/src/includes/head.pug
+++ b/src/includes/head.pug
@@ -6,6 +6,7 @@ head
     script(type="module" src="https://unpkg.com/@startinblox/router")
     script(type="module" src="https://unpkg.com/@startinblox/oidc")
     script(type="module" src="https://unpkg.com/@startinblox/component-conversation")
+    script(type="module" src="../../sib-like/sib-like.js")
     script(src="https://kit.fontawesome.com/48014d2af3.js")
     script(src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous")
     script(src="/scripts/coopstarter.js")
diff --git a/src/includes/mentor/components/header.pug b/src/includes/mentor/components/header.pug
index 3e7b4a46..7ee39240 100644
--- a/src/includes/mentor/components/header.pug
+++ b/src/includes/mentor/components/header.pug
@@ -18,7 +18,7 @@
             )
             
             .dropdownWrapper
-                sib-display#mentor-account-picture.dropdownLabel(
+                sib-display#user-account-picture.dropdownLabel(
                     bind-user
                     fields='account.picture',
                     widget-account.picture='cs-account-picture'
diff --git a/src/includes/mentor/resources/detail.pug b/src/includes/mentor/resources/detail.pug
index cf20f6a7..b87da116 100644
--- a/src/includes/mentor/resources/detail.pug
+++ b/src/includes/mentor/resources/detail.pug
@@ -120,5 +120,7 @@ include ../../components/widgets
   )
 
 
-
+sib-like(
+  bind-resources,
+)
   
\ No newline at end of file
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 0312cf45..e72e1e96 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -343,6 +343,24 @@ function initFileUpload(){
   }
 }
 
+/**
+ * Manage the like sender hidden form
+ * @param {*} event 
+ * @param {*} userWhoSubmitLike 
+ * @param {*} formSenderLike 
+ */
+function fillSenderLike(userWhoSubmitLike, formSenderLike, currentResource) {
+  console.log("userWhoSubmitLike", userWhoSubmitLike)
+  console.log("formSenderLike", formSenderLike)
+  formSenderLike.querySelector(
+    "input[name='sender']"
+  ).value = JSON.stringify({ "@id": userWhoSubmitLike });
+  formSenderLike.querySelector(
+    "input[name='receiver_object_id']"
+  ).value = JSON.stringify({ "@id": currentResource });
+  receiver_object_id
+}
+
 /**
  * For entrepreneur dashboard only :
  * As we cannot have multiple imbricated filtering with the native sib-display, we manage it manually.
@@ -545,6 +563,8 @@ jQuery(document).ready(function($) {
   linkDatasetToField(userAccountDataSrc, "improvement-dialog-form", "reviewer");
   linkDatasetToField(userAccountDataSrc, "refusal-dialog-form", "reviewer");
   linkDatasetToField(userAccountDataSrc, "change_status_request", "reviewer");
+  // linkDatasetToField(userAccountDataSrc, "add-like", "sender");
+  // linkDatasetToField(userAccountDataSrc, "add-dislike", "sender");
 
   //On form submission, we sometime have to refresh a list.
   refreshList("resource-creation-form", "resources-history");
@@ -600,6 +620,31 @@ jQuery(document).ready(function($) {
       var userWhoSubmitReport =  userAccountDataSrc.dataset.src
       var formBrokenLink = document.getElementById("report-broken-link-mentor");
       fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink);
+      //fillSenderLike(userWhoSubmitReport, formSenderLike, currentResource);
+      document.querySelector('sib-auth').getUser().then(data=> {
+        console.log("Le user : ", data )
+        let targetForm = document.getElementById('add-like');
+        targetForm.addEventListener("populate", event => {
+          let resourceField = targetForm.querySelector(`input[name="sender"]`);
+          let test = targetForm.querySelector(`input[name="receiver_object_id"]`)
+          let sibLike= document.querySelector('sib-like')
+          test.value = JSON.stringify({ "@id": sibLike.dataset.src })
+          test.setAttribute(
+              "value",
+              JSON.stringify({ "@id": sibLike.dataset.src })
+            );
+          if (resourceField) {
+            resourceField.value = JSON.stringify(data);
+            resourceField.setAttribute(
+              "value",
+              JSON.stringify(data)
+            );
+            console.log("l'id_receveer : ", test.value )
+          }
+        });
+        
+      })
+      
     });
 
     //Init the form file behaviour
-- 
GitLab


From dd1e2d951558dd0812e6f7a25027ace1a7419e80 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 15 Nov 2019 14:11:42 +0100
Subject: [PATCH 2/7] change reciever id by interger id.

---
 src/scripts/coopstarter.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index e72e1e96..f482a40a 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -628,10 +628,11 @@ jQuery(document).ready(function($) {
           let resourceField = targetForm.querySelector(`input[name="sender"]`);
           let test = targetForm.querySelector(`input[name="receiver_object_id"]`)
           let sibLike= document.querySelector('sib-like')
-          test.value = JSON.stringify({ "@id": sibLike.dataset.src })
+          // test.value = JSON.stringify({ "@id": sibLike.dataset.src })
+          test.value = 1
           test.setAttribute(
               "value",
-              JSON.stringify({ "@id": sibLike.dataset.src })
+              1
             );
           if (resourceField) {
             resourceField.value = JSON.stringify(data);
-- 
GitLab


From b8af0aa48a01d1715cb2752e434e562aa3574f7a Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Mon, 18 Nov 2019 19:29:57 +0100
Subject: [PATCH 3/7] wip

---
 src/includes/head.pug      |  1 +
 src/scripts/coopstarter.js | 26 ++++++++++++++------------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/includes/head.pug b/src/includes/head.pug
index 5568626e..9556d615 100644
--- a/src/includes/head.pug
+++ b/src/includes/head.pug
@@ -11,3 +11,4 @@ head
     script(src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous")
     script(src="/scripts/coopstarter.js")
     link(rel="stylesheet" href="/styles/index.css")
+    link(rel="stylesheet" href="../../sib-like/css/main.css")
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index f482a40a..4ce908d9 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -620,27 +620,29 @@ jQuery(document).ready(function($) {
       var userWhoSubmitReport =  userAccountDataSrc.dataset.src
       var formBrokenLink = document.getElementById("report-broken-link-mentor");
       fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink);
-      //fillSenderLike(userWhoSubmitReport, formSenderLike, currentResource);
+
+      // Fill the hidden like-form
       document.querySelector('sib-auth').getUser().then(data=> {
-        console.log("Le user : ", data )
-        let targetForm = document.getElementById('add-like');
-        targetForm.addEventListener("populate", event => {
-          let resourceField = targetForm.querySelector(`input[name="sender"]`);
-          let test = targetForm.querySelector(`input[name="receiver_object_id"]`)
-          let sibLike= document.querySelector('sib-like')
-          // test.value = JSON.stringify({ "@id": sibLike.dataset.src })
-          test.value = 1
-          test.setAttribute(
+        let targetFormLike = document.getElementById('add-like');
+        targetFormLike.addEventListener("populate", event => {
+          let resourceField = targetFormLike.querySelector(`input[name="sender"]`);
+          if (resourceField) {
+            resourceField.value = JSON.stringify(data);
+            resourceField.setAttribute(
               "value",
-              1
+              JSON.stringify(data)
             );
+          }
+        });
+        let targetFormDislike = document.getElementById('add-dislike');
+        targetFormDislike.addEventListener("populate", event => {
+          let resourceField = targetFormDislike.querySelector(`input[name="sender"]`);
           if (resourceField) {
             resourceField.value = JSON.stringify(data);
             resourceField.setAttribute(
               "value",
               JSON.stringify(data)
             );
-            console.log("l'id_receveer : ", test.value )
           }
         });
         
-- 
GitLab


From 13b44a50a23c6dd3cc856e407d849defa798106a Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Tue, 19 Nov 2019 16:53:08 +0100
Subject: [PATCH 4/7] The like functionality is set but miss integration.

---
 src/includes/head.pug                    |  2 +-
 src/includes/mentor/resources/detail.pug | 24 +++---------------------
 2 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/src/includes/head.pug b/src/includes/head.pug
index 9556d615..4dde5b02 100644
--- a/src/includes/head.pug
+++ b/src/includes/head.pug
@@ -2,7 +2,7 @@ head
     title CoopStarter
     meta(charset="utf-8")
     script(src="https://unpkg.com/@webcomponents/webcomponentsjs@1.2.7/webcomponents-loader.js")
-    script(type="module" src="https://unpkg.com/@startinblox/core@0.8")
+    script(type="module" src="https://unpkg.com/@startinblox/core")
     script(type="module" src="https://unpkg.com/@startinblox/router")
     script(type="module" src="https://unpkg.com/@startinblox/oidc")
     script(type="module" src="https://unpkg.com/@startinblox/component-conversation")
diff --git a/src/includes/mentor/resources/detail.pug b/src/includes/mentor/resources/detail.pug
index b87da116..ca54360b 100644
--- a/src/includes/mentor/resources/detail.pug
+++ b/src/includes/mentor/resources/detail.pug
@@ -74,24 +74,8 @@ include ../../components/widgets
     action-broken='resource-report-broken-link-mentor'
   )
 
-  //TODO: implement likes here
-  //- <div class="like">
-  //-   <p class="backlink"><i class='far fa-thumbs-up'></i>18</p>
-  //-   <p class="backlink"><i class='far fa-thumbs-down'></i>3</p>
-  //- </div>
-
-  sib-display(
-    bind-resources
-    fields=""
-    nested-field="likes"
-    counter-template="<p><i class='fas fa-thumbs-up'></i>${counter}</p>"
-  )
-
-  sib-display(
-    bind-resources
-    fields=""
-    nested-field="dislikes"
-    counter-template="<p><i class='fas fa-thumbs-down'></i>${counter}</p>"
+  sib-like(
+    bind-resources,
   )
 
   sib-display(
@@ -120,7 +104,5 @@ include ../../components/widgets
   )
 
 
-sib-like(
-  bind-resources,
-)
+
   
\ No newline at end of file
-- 
GitLab


From d18ef4bc879e6aa553e9fe934fe57803c6c77cb8 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Thu, 21 Nov 2019 11:27:56 +0100
Subject: [PATCH 5/7] Fix the version

---
 src/includes/head.pug | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/includes/head.pug b/src/includes/head.pug
index 4dde5b02..187d1c89 100644
--- a/src/includes/head.pug
+++ b/src/includes/head.pug
@@ -2,10 +2,10 @@ head
     title CoopStarter
     meta(charset="utf-8")
     script(src="https://unpkg.com/@webcomponents/webcomponentsjs@1.2.7/webcomponents-loader.js")
-    script(type="module" src="https://unpkg.com/@startinblox/core")
-    script(type="module" src="https://unpkg.com/@startinblox/router")
-    script(type="module" src="https://unpkg.com/@startinblox/oidc")
-    script(type="module" src="https://unpkg.com/@startinblox/component-conversation")
+    script(type="module" src="https://unpkg.com/@startinblox/core@0.9")
+    script(type="module" src="https://unpkg.com/@startinblox/router@0.7")
+    script(type="module" src="https://unpkg.com/@startinblox/oidc@0.8")
+    script(type="module" src="https://unpkg.com/@startinblox/component-conversation@0.4")
     script(type="module" src="../../sib-like/sib-like.js")
     script(src="https://kit.fontawesome.com/48014d2af3.js")
     script(src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous")
-- 
GitLab


From 2aac630235b2d74258bc2eefe57b51f0c6e777b9 Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Sat, 23 Nov 2019 18:16:02 +0100
Subject: [PATCH 6/7] Fix footer

---
 src/styles/index.scss | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/styles/index.scss b/src/styles/index.scss
index 44dfb453..4cb69b47 100644
--- a/src/styles/index.scss
+++ b/src/styles/index.scss
@@ -768,7 +768,6 @@ footer#footer{
     background:var(--bg-block);
     height: auto;
     box-shadow: 0 2px 10px 0 rgba(0,0,0,0.14);
-    position: absolute;
     padding-top: 2rem;
     bottom: 0;
     width: 100%;
-- 
GitLab


From d62b29fea98981be28f9222d32328d27f3a878d3 Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Sat, 23 Nov 2019 18:20:32 +0100
Subject: [PATCH 7/7] Fix version

---
 src/scripts/coopstarter.js | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index ddc72adf..56f1a243 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -381,8 +381,6 @@ function initFileUpload(){
  * @param {*} formSenderLike 
  */
 function fillSenderLike(userWhoSubmitLike, formSenderLike, currentResource) {
-  console.log("userWhoSubmitLike", userWhoSubmitLike)
-  console.log("formSenderLike", formSenderLike)
   formSenderLike.querySelector(
     "input[name='sender']"
   ).value = JSON.stringify({ "@id": userWhoSubmitLike });
@@ -420,11 +418,6 @@ function addProperFilterToSearchComponents(targetId) {
         `input[name="name_keyword"]`
       );
 
-      let keyword_submit = baseElement.querySelectorAll(" .keyword_submit")[0];
-      let keyword_hidden_fields = baseElement.querySelectorAll(
-        'hidden-widget[name="search_for_a_resource"] input'
-      );
-
       if (keyword_field) {
         let keyword_submit = baseElement.querySelectorAll(" .keyword_submit")[0];
         let keyword_hidden_fields = baseElement.querySelectorAll(
-- 
GitLab