From 996cafe9c5a9d00b17ec21329b71f252a2a166a0 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Thu, 12 Sep 2019 10:25:10 +0200
Subject: [PATCH 01/11] WIP: Filter resource with js.

---
 src/includes/entrepreneur/resources/list.pug | 48 ++++++++++----------
 src/scripts/coopstarter.js                   |  2 +-
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index 029edb1e..6cd839a3 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -12,7 +12,7 @@ include ../../components/widgets
 //It seems that we don't have likes and dislikes data : sould i ignore them for the moment?
 
 
-div.block_log.block_list
+.block_log.block_creat_count
     h2.title_form Search for a resource
     sib-form#search-by-keyword(
         data-src=`${endpoints.resources}`,
@@ -23,20 +23,31 @@ div.block_log.block_list
         widget-description='cs-display-property'
         widget-name_keyword='cs-display-property'
         widget-author='cs-display-property'
+
+        submit-button='Search'
+    )
+
+    sib-form(
+        data-src=`${endpoints.resources}`,
+        fields='instance_database_only'    
+
+        widget-instance_database_only='cs-display-checkbox'
+
+        class-instance_database_only = 'ss-list checkbox'
+        naked
     )
 
-    sib-form#circles-list(
+    sib-form(
         data-src=`${endpoints.resources}`,
-        fields='more_criterias( format, publication_year, country, language.name, fields, steps)'
+        fields='header_criterias, format, publication_year, country, language.name, fields, steps'
         
         label-header_criterias='More criterias'
-        label-format='Format'
+        label-format='Format:'
         label-publication_year='Year of publication'
         label-country='Country of publication'
         label-language.name='Language'
         label-fields='Field'
         label-steps='Step of : Staring up a cooperative business'
-        widget-instance_database_only='cs-display-checkbox'
         widget-header_criterias='cs-section_header'
 
         range-language.name=`${endpoints.languages}`
@@ -44,30 +55,21 @@ div.block_log.block_list
         range-steps=`${endpoints.steps}`
         range-format=`${endpoints.formats}`
 
-        multiple-language='sib-multiple-select'
-        widget-language='sib-form-auto-completion'
+        multiple-language.name='sib-multiple-select'
+        widget-language.name='sib-form-auto-completion'
 
-        multiple-field='sib-multiple-select'
-        widget-field='sib-form-auto-completion'
+        multiple-format='sib-multiple-select'
+        widget-format='sib-form-auto-completion'
 
-        multiple-step='sib-multiple-select'
-        widget-step='sib-form-auto-completion'
-                
-    
+        multiple-fields='sib-multiple-select'
+        widget-fields='sib-form-auto-completion'
 
+        multiple-steps='sib-multiple-select'
+        widget-steps='sib-form-auto-completion'
+                
         naked
     )
 
-//- form
-//-     div
-//-         label(for="name") Enter your name
-//-         input(type="text" name="name" id="name" )
-    
-//-     div
-//-         button(value="Search")
-
-
-
 
 #circles
     sib-display#circles-list(
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 48f0f3c8..e9084b23 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -69,7 +69,7 @@ jQuery(document).ready(function($) {
             hidden_fields.forEach(hidden_field => {
                 hidden_field.setAttribute("value", keyword_field.value)
                 console.log(hidden_fields)
-                console.log("element.value", hidden_field.value)
+                console.log("hidden_field.value", hidden_field.value)
                 console.log("keyword_field.value", keyword_field.value)
             }); 
         })     
-- 
GitLab


From 71c18906e620fcc0b15063e1161ebaeb38ddc1d6 Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Thu, 12 Sep 2019 11:18:17 +0200
Subject: [PATCH 02/11] Fix regression

---
 src/scripts/coopstarter.js | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index ebf57127..dd2af190 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -50,14 +50,20 @@ jQuery(document).ready(function($) {
     refreshList("refusal-dialog-form", "pending-resources");
     refreshList("improvement-dialog-form", "pending-resources");
 
-    const logoutButton = document.getElementById('logout-button');
-    logoutButton.addEventListener('click', function() {
-        window.dispatchEvent(
-            new CustomEvent('requestNavigation', { detail: { route: 'splash-index' } })
-        );
-        document.querySelector('sib-auth').logout();
-        setTimeout(function(){ location.reload(); }, 1000);
-    })
+    const logoutButtons = document.getElementsByClassName("logout-button");
+    for (var i = 0; i < logoutButtons.length; i++) {
+        logoutButtons[i].addEventListener("click", function() {
+            window.dispatchEvent(
+                new CustomEvent("requestNavigation", {
+                detail: { route: "splash-index" }
+                })
+            );
+            document.querySelector("sib-auth").logout();
+            setTimeout(function() {
+                location.reload();
+            }, 1000);
+        });
+    }
 
     //In the entrepreneur dashboard, we set data from the display form to the hidden ones.
     let keyword_form = document.getElementById('search-by-keyword');
-- 
GitLab


From 43a3f1ec50b999d2075b2882fa5f05832df4ee16 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 13 Sep 2019 11:01:16 +0200
Subject: [PATCH 03/11] WIP: More criterias filtering.

---
 src/includes/entrepreneur/resources/list.pug | 102 ++++------------
 src/scripts/coopstarter.js                   | 120 +++++++++++++++++--
 2 files changed, 132 insertions(+), 90 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index ae045d1c..92a2467c 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -4,14 +4,10 @@ div.container_min
         h2.title_lead.fd_bleu International index of resources for cooperative mentors and entrepreneurs
         button.button_dark.pull-right Watch the presentation
 
-//-Question : 
-//In my opinion, "multiple ressource" solution is closer to the wanted result than the "group-by" solution
+//-About : 
+//It will be great to have autocompletion on country
+//I'm waiting for a confirmation to suppress step field
 
-//Maybe we sould think from now how we gonna manage the type filter
-
-//What's the best way to retrieve the name of the format? By the resource we get a number. Sould we manage this with a 'switch/case' in js?
-
-//It seems that we don't have likes and dislikes data : sould i ignore them for the moment?
 
 
 .block_log.block_creat_count
@@ -42,7 +38,7 @@ div.container_min
         naked
     )
 
-    sib-form(
+    sib-form#more_criterias(
         data-src=`${endpoints.resources}`,
         fields='header_criterias, format, publication_year, country, language.name, fields, steps'
         
@@ -96,20 +92,16 @@ div.side-block.block_log
     sib-display#step1.resource_by_step(
         data-src=`${endpoints.steps}1/resources/`,
         fields='name, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), format, publication_year, country, language.name, field, steps',  
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
-        search-widget-format="hidden-widget"
-        search-widget-publication_year="hidden-widget"
-        search-widget-country="hidden-widget"
-        search-widget-language.name="hidden-widget"
-        search-widget-field="hidden-widget"
-        search-widget-steps="hidden-widget"
+        search-widget-more_criterias_hidden="hidden-widget"
  
-
         widget-name='cs-display-property'
+        widget-country='cs-display-property'
         widget-publication_year='cs-display-property'
         widget-description='cs-display-property'
+        widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="hidden-widget"
         widget-steps="hidden-widget"
@@ -133,20 +125,16 @@ div.side-block.block_log
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}2/resources/`,
         fields='name, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), format, publication_year, country, language.name, field, steps',  
+        search-fields='search_for_a_resource(name, description, author),  more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
-        search-widget-format="hidden-widget"
-        search-widget-publication_year="hidden-widget"
-        search-widget-country="hidden-widget"
-        search-widget-language.name="hidden-widget"
-        search-widget-field="hidden-widget"
-        search-widget-steps="hidden-widget"
- 
+        search-widget-more_criterias_hidden="hidden-widget"
 
         widget-name='cs-display-property'
+        widget-country='cs-display-property'
         widget-publication_year='cs-display-property'
         widget-description='cs-display-property'
+        widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="hidden-widget"
         widget-steps="hidden-widget"
@@ -171,20 +159,16 @@ div.side-block.block_log
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}3/resources/`,
         fields='name, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), format, publication_year, country, language.name, field, steps',  
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
-        search-widget-format="hidden-widget"
-        search-widget-publication_year="hidden-widget"
-        search-widget-country="hidden-widget"
-        search-widget-language.name="hidden-widget"
-        search-widget-field="hidden-widget"
-        search-widget-steps="hidden-widget"
- 
+        search-widget-more_criterias_hidden="hidden-widget"
 
         widget-name='cs-display-property'
+        widget-country='cs-display-property'
         widget-publication_year='cs-display-property'
         widget-description='cs-display-property'
+        widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="hidden-widget"
         widget-steps="hidden-widget"
@@ -209,20 +193,16 @@ div.side-block.block_log
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}4/resources/`,
         fields='name, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), format, publication_year, country, language.name, field, steps',  
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
-        search-widget-format="hidden-widget"
-        search-widget-publication_year="hidden-widget"
-        search-widget-country="hidden-widget"
-        search-widget-language.name="hidden-widget"
-        search-widget-field="hidden-widget"
-        search-widget-steps="hidden-widget"
- 
+        search-widget-more_criterias_hidden="hidden-widget"
 
         widget-name='cs-display-property'
+        widget-country='cs-display-property'
         widget-publication_year='cs-display-property'
         widget-description='cs-display-property'
+        widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="hidden-widget"
         widget-steps="hidden-widget"
@@ -246,20 +226,16 @@ div.side-block.block_log
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}5/resources/`,
         fields='name, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), format, publication_year, country, language.name, field, steps',  
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
-        search-widget-format="hidden-widget"
-        search-widget-publication_year="hidden-widget"
-        search-widget-country="hidden-widget"
-        search-widget-language.name="hidden-widget"
-        search-widget-field="hidden-widget"
-        search-widget-steps="hidden-widget"
- 
+        search-widget-more_criterias_hidden="hidden-widget"
 
         widget-name='cs-display-property'
+        widget-country='cs-display-property'
         widget-publication_year='cs-display-property'
         widget-description='cs-display-property'
+        widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="hidden-widget"
         widget-steps="hidden-widget"
@@ -269,33 +245,3 @@ div.side-block.block_log
 
         paginate-by="5"
     )
-       
-//- search-fields="keyword, instance_database_only,\
-//-         more_criterias(header_criterias, format, publication_year, country, language, field, step)"
-//-         search-label-keyword="Search by author, name..."
-//-         search-label-header_criterias='More criterias'
-//-         search-label-format='Format'
-//-         search-label-publication_year='Year of publication'
-//-         search-label-country='Country of publication'
-//-         search-label-language='Language'
-//-         search-label-field='Field'
-//-         search-label-step='Step of : Staring up a cooperative business'
-//-         search-widget-keyword="sib-form-placeholder-text"
-//-         search-widget-instance_database_only='cs-display-checkbox'
-//-         search-widget-header_criterias='cs-section_header'
-
-//-         search-range-language=`${endpoints.languages}`
-//-         search-range-field=`${endpoints.fields}`
-//-         search-range-step=`${endpoints.step}`
-
-//-         search-multiple-language='sib-multiple-select'
-//-         search-widget-language='sib-form-auto-completion'
-
-//-         search-multiple-field='sib-multiple-select'
-//-         search-widget-field='sib-form-auto-completion'
-
-//-         search-multiple-step='sib-multiple-select'
-//-         search-widget-step='sib-form-auto-completion'
-                
-//-         widget-description='cs-display-property'
-//-         widget-name='cs-display-property'
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 654f04c0..4fea36a6 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -68,27 +68,123 @@ jQuery(document).ready(function($) {
 
   //In the entrepreneur dashboard, we set data from the display form to the hidden ones.
   var forms = document.querySelectorAll(".resource_by_step");
+
   forms.forEach(form => {
-    form.addEventListener("populate", e => {
-      let keyword_form = document.getElementById("search-by-keyword");
-    //   keyword_form.addEventListener("populate", event => {
+    form.addEventListener(
+      "populate",
+      e => {
+        //To retrieve keyword
+        let keyword_form = document.getElementById("search-by-keyword");
         let keyword_field = keyword_form.querySelector(`input[name="keyword"]`);
+
         let keyword_submit = document.getElementById(`keyword_submit`);
-        let hidden_fields = document.querySelectorAll(
+        let keyword_hidden_fields = document.querySelectorAll(
           'hidden-widget[name="search_for_a_resource"] input'
         );
-        console.log(keyword_field);
-        console.log(hidden_fields);
+
         keyword_submit.addEventListener("click", function() {
-          hidden_fields.forEach(hidden_field => {
+          keyword_hidden_fields.forEach(hidden_field => {
             hidden_field.setAttribute("value", keyword_field.value);
             form.querySelector("sib-form").component.inputChange();
-            console.log(hidden_fields);
-            console.log("hidden_field.value", hidden_field.value);
-            console.log("keyword_field.value", keyword_field.value);
           });
         });
-      });
-    // });
+
+        //MORE CRITERIAS
+        //TODO: Refactor this section ?
+        const more_criterias_form = document.getElementById("more_criterias");
+
+        // https://git.happy-dev.fr/startinblox/framework/sib-core/issues/453
+        window.setTimeout(() => {
+
+          //To retrieve format
+          let format_field_search = more_criterias_form.querySelector(
+            `select[name="format"]`
+          );
+          format_hidden_fields = document.querySelectorAll(
+            'hidden-widget[name="more_criterias_hidden"] input[name="format"]'
+          );
+
+          format_field_search.onchange = function() {
+            format_hidden_fields.forEach(format_field => {
+              format_field.setAttribute(
+                "value",
+                format_field_search.options[format_field_search.selectedIndex]
+                  .text
+              );
+              form.querySelector("sib-form").component.inputChange();
+            });
+          };
+
+          //To retrieve language
+          let language_field_search = more_criterias_form.querySelector(
+            `select[name="language.name"]`
+          );
+          language_hidden_fields = document.querySelectorAll(
+            'hidden-widget[name="more_criterias_hidden"] input[name="language.name"]'
+          );
+
+          language_field_search.onchange = function() {
+            language_hidden_fields.forEach(language_field => {
+              language_field.setAttribute(
+                "value",
+                language_field_search.options[language_field_search.selectedIndex]
+                  .text
+              );
+              form.querySelector("sib-form").component.inputChange();
+            });
+          };
+
+          // //To retrieve step, but I think it's gonna disapear
+          // let step_field_search = more_criterias_form.querySelector(
+          //   `select[name="step"]`
+          // );
+          // step_hidden_fields = document.querySelectorAll(
+          //   'hidden-widget[name="more_criterias_hidden"] input[name="step"]'
+          // );
+
+          // step_field_search.onchange = function() {
+          //   step_hidden_fields.forEach(step_field => {
+          //     step_field.setAttribute(
+          //       "value",
+          //       step_field_search.options[step_field_search.selectedIndex]
+          //         .text
+          //     );
+          //     form.querySelector("sib-form").component.inputChange();
+          //   });
+          // };
+
+          //To retrieve year of publication
+          let year_field_search = more_criterias_form.querySelector(
+            `input[name="publication_year"]`
+          );
+          let year_hidden_fields = document.querySelectorAll(
+            'hidden-widget[name="more_criterias_hidden"] input[name="publication_year"]'
+          );
+
+          year_field_search.addEventListener("input", function() {
+            year_hidden_fields.forEach(year_field => {
+              year_field.setAttribute("value", year_field_search.value);
+              form.querySelector("sib-form").component.inputChange();
+            });
+          });
+
+          //To retrieve the country
+          let country_field_search = more_criterias_form.querySelector(
+            `input[name="country"]`
+          );
+          let country_hidden_fields = document.querySelectorAll(
+            'hidden-widget[name="more_criterias_hidden"] input[name="country"]'
+          );
+
+          country_field_search.addEventListener("input", function() {
+            country_hidden_fields.forEach(country_field => {
+              country_field.setAttribute("value", countryr_field_search.value);
+              form.querySelector("sib-form").component.inputChange();
+            });
+          });
+        });
+      },
+      2000
+    );
   });
 });
-- 
GitLab


From b7daa15a34fd962a2bc51ac2c4722656944bb7bb Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 13 Sep 2019 11:51:53 +0200
Subject: [PATCH 04/11] WIP: More criterias filtering.

---
 src/includes/entrepreneur/resources/list.pug | 23 ++++++++++----------
 src/scripts/coopstarter.js                   | 12 +++++++---
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index 92a2467c..3cb4aab1 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -23,7 +23,7 @@ div.container_min
         widget-author='cs-display-property'
 
         naked    
-        )
+    )
 
     div#keyword_submit.button__actions
         div.button_base.ico_gauche Search
@@ -35,6 +35,7 @@ div.container_min
         widget-instance_database_only='cs-display-checkbox'
 
         class-instance_database_only = 'ss-list checkbox'
+        
         naked
     )
 
@@ -91,7 +92,7 @@ div.side-block.block_log
 
     sib-display#step1.resource_by_step(
         data-src=`${endpoints.steps}1/resources/`,
-        fields='name, format, publication_year, description,  country, language.name, field, steps',
+        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
@@ -103,7 +104,7 @@ div.side-block.block_log
         widget-description='cs-display-property'
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
-        widget-author="hidden-widget"
+        widget-author="cs-display-property"
         widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
@@ -124,7 +125,7 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}2/resources/`,
-        fields='name, format, publication_year, description,  country, language.name, field, steps',
+        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
         search-fields='search_for_a_resource(name, description, author),  more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
@@ -136,7 +137,7 @@ div.side-block.block_log
         widget-description='cs-display-property'
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
-        widget-author="hidden-widget"
+        widget-author="cs-display-property"
         widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
@@ -158,7 +159,7 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}3/resources/`,
-        fields='name, format, publication_year, description,  country, language.name, field, steps',
+        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
@@ -170,7 +171,7 @@ div.side-block.block_log
         widget-description='cs-display-property'
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
-        widget-author="hidden-widget"
+        widget-author="cs-display-property"
         widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
@@ -192,7 +193,7 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}4/resources/`,
-        fields='name, format, publication_year, description,  country, language.name, field, steps',
+        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
@@ -204,7 +205,7 @@ div.side-block.block_log
         widget-description='cs-display-property'
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
-        widget-author="hidden-widget"
+        widget-author="cs-display-property"
         widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
@@ -225,7 +226,7 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}5/resources/`,
-        fields='name, format, publication_year, description,  country, language.name, field, steps',
+        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
 
         search-widget-search_for_a_resource="hidden-widget"
@@ -237,7 +238,7 @@ div.side-block.block_log
         widget-description='cs-display-property'
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
-        widget-author="hidden-widget"
+        widget-author="cs-display-property"
         widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 4fea36a6..b343d81f 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -51,7 +51,6 @@ jQuery(document).ready(function($) {
   refreshList("improvement-dialog-form", "pending-resources");
 
   const logoutButtons = document.getElementsByClassName("logout-button");
-  console.log(logoutButtons);
   for (var i = 0; i < logoutButtons.length; i++) {
     logoutButtons[i].addEventListener("click", function() {
       window.dispatchEvent(
@@ -74,6 +73,8 @@ jQuery(document).ready(function($) {
       "populate",
       e => {
         //To retrieve keyword
+        //https://git.happy-dev.fr/startinblox/framework/sib-core/issues/379
+        //TODO: Wait for a solution to filter with multiple value with "OR" instead of "AND".
         let keyword_form = document.getElementById("search-by-keyword");
         let keyword_field = keyword_form.querySelector(`input[name="keyword"]`);
 
@@ -97,6 +98,8 @@ jQuery(document).ready(function($) {
         window.setTimeout(() => {
 
           //To retrieve format
+          //TODO: How we should filled the hidden field with multiple value?
+          //TODO: The hidden search field set with one value doesn't work
           let format_field_search = more_criterias_form.querySelector(
             `select[name="format"]`
           );
@@ -116,6 +119,7 @@ jQuery(document).ready(function($) {
           };
 
           //To retrieve language
+          //TODO: How we should filled the hidden field?
           let language_field_search = more_criterias_form.querySelector(
             `select[name="language.name"]`
           );
@@ -154,6 +158,8 @@ jQuery(document).ready(function($) {
           // };
 
           //To retrieve year of publication
+          //WARNING: If the user want to select "20" to get 21century made, he will get no result. 
+          //I think it is a UX problem.
           let year_field_search = more_criterias_form.querySelector(
             `input[name="publication_year"]`
           );
@@ -178,13 +184,13 @@ jQuery(document).ready(function($) {
 
           country_field_search.addEventListener("input", function() {
             country_hidden_fields.forEach(country_field => {
-              country_field.setAttribute("value", countryr_field_search.value);
+              country_field.setAttribute("value", country_field_search.value);
               form.querySelector("sib-form").component.inputChange();
             });
           });
         });
       },
-      2000
+      4000
     );
   });
 });
-- 
GitLab


From b539c0478dffb45c89d394336086961f93bd5002 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 13 Sep 2019 14:57:59 +0200
Subject: [PATCH 05/11] Bug: Refresh the user data on validation of the form
 creation profile.

---
 src/includes/entrepreneur/profile/create.pug | 2 +-
 src/includes/entrepreneur/profile/detail.pug | 4 ++--
 src/includes/mentor/profile/create.pug       | 2 +-
 src/includes/mentor/profile/detail.pug       | 6 +++---
 src/scripts/coopstarter.js                   | 5 +++++
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/includes/entrepreneur/profile/create.pug b/src/includes/entrepreneur/profile/create.pug
index 8eb14484..ce0cb42c 100644
--- a/src/includes/entrepreneur/profile/create.pug
+++ b/src/includes/entrepreneur/profile/create.pug
@@ -10,7 +10,7 @@ figure.logo.img_log
 
 h2.title_create Complete your entrepreneur account
 
-sib-form.block_log.block_creat_count(
+sib-form#entrepreneur_profile_creation.block_log.block_creat_count(
     bind-user
     fields="last_name, first_name, entrepreneur_profile.organisation, username"
     
diff --git a/src/includes/entrepreneur/profile/detail.pug b/src/includes/entrepreneur/profile/detail.pug
index a597bd0c..72c63291 100644
--- a/src/includes/entrepreneur/profile/detail.pug
+++ b/src/includes/entrepreneur/profile/detail.pug
@@ -23,7 +23,7 @@ div.block_list.flex
         sib-link(next='entrepreneur-account-edit')
             button.button_edit Edit
 
-        sib-display(
+        sib-display#entrepreneur_info(
             bind-user
             fields='name, entrepreneur_profile.organisation.name, registered_on'
             widget-name='cs-display-property'
@@ -31,7 +31,7 @@ div.block_list.flex
             widget-entrepreneur_profile.registered_on='cs-display-property'
         )
 
-        sib-display(
+        sib-display#entrepreneur_contact(
             bind-user
             fields='email'
             label-email='Email:'
diff --git a/src/includes/mentor/profile/create.pug b/src/includes/mentor/profile/create.pug
index 96049e4f..17f7c8f7 100644
--- a/src/includes/mentor/profile/create.pug
+++ b/src/includes/mentor/profile/create.pug
@@ -10,7 +10,7 @@ figure.logo.img_log
 
 h2.title_create Complete your mentor account
 
-sib-form.block_log.block_creat_count(
+sib-form#mentor_profile_creation.block_log.block_creat_count(
     bind-user
     fields="account_information(last_name, first_name, mentor_profile.organisation,\
             mentor_profile.phone, mentor_profile.languages, mentor_profile.fields),\
diff --git a/src/includes/mentor/profile/detail.pug b/src/includes/mentor/profile/detail.pug
index 00a95bf8..92892b7d 100644
--- a/src/includes/mentor/profile/detail.pug
+++ b/src/includes/mentor/profile/detail.pug
@@ -27,7 +27,7 @@ div.block_list.flex
         sib-link(next='mentor-account-edit')
             button.button_edit Edit
 
-        sib-display(
+        sib-display#mentor_info(
             bind-user
             fields='account.picture, name, mentor_profile.headline, mentor_profile.city, mentor_profile.country, registered_on'
             widget-account.picture='cs-profile-picture'
@@ -45,7 +45,7 @@ div.block_list.flex
             bind-user
         )
 
-        sib-display(
+        sib-display#mentor_complementary(
             bind-user
             fields='biography_label, mentor_profile.biography, skills_label, mentor_profile.skills'
             widget-biography_label='cs-display-label'
@@ -56,7 +56,7 @@ div.block_list.flex
             widget-mentor_profile.biography='cs-display-property'
         )
 
-        sib-display(
+        sib-display#mentor_contact(
             bind-user
             fields='email, mentor_profile.phone, mentor_profile.linkedin, mentor_profile.twitter'
             label-email='Email:'
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index b343d81f..295fe98d 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -49,6 +49,11 @@ jQuery(document).ready(function($) {
   refreshList("validation-form", "pending-resources");
   refreshList("refusal-dialog-form", "pending-resources");
   refreshList("improvement-dialog-form", "pending-resources");
+  refreshList("entrepreneur_profile_creation", "entrepreneur_info");
+  refreshList("entrepreneur_profile_creation", "entrepreneur_contact");
+  refreshList("mentor_profile_creation", "mentor_info");
+  refreshList("mentor_profile_creation", "mentor_complementary");
+  refreshList("mentor_profile_creation", "mentor_contact");
 
   const logoutButtons = document.getElementsByClassName("logout-button");
   for (var i = 0; i < logoutButtons.length; i++) {
-- 
GitLab


From 1b4d3fff6500312292a5c04f800fb04ecbea972e Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 13 Sep 2019 14:59:43 +0200
Subject: [PATCH 06/11] Remove steps' filter in 'more criterias'.

---
 src/includes/entrepreneur/resources/list.pug | 43 ++++++++------------
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index 3cb4aab1..44bcc1fb 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -6,16 +6,15 @@ div.container_min
 
 //-About : 
 //It will be great to have autocompletion on country
-//I'm waiting for a confirmation to suppress step field
-
-
 
 .block_log.block_creat_count
     h2.title_form Search for a resource
     sib-form#search-by-keyword(
         data-src=`${endpoints.resources}`,
-        fields='keyword(name_keyword, description, author)'    
+        fields='keyword(name_keyword, description, author)' 
+           
         label-keyword="Search by author, name..."
+
         widget-keyword="sib-form-placeholder-text"
 
         widget-description='cs-display-property'
@@ -28,20 +27,20 @@ div.container_min
     div#keyword_submit.button__actions
         div.button_base.ico_gauche Search
 
-    sib-form(
+    sib-form#instance_database_only(
         data-src=`${endpoints.resources}`,
         fields='instance_database_only'    
 
         widget-instance_database_only='cs-display-checkbox'
 
         class-instance_database_only = 'ss-list checkbox'
-        
+
         naked
     )
 
     sib-form#more_criterias(
         data-src=`${endpoints.resources}`,
-        fields='header_criterias, format, publication_year, country, language.name, fields, steps'
+        fields='header_criterias, format, publication_year, country, language.name, fields'
         
         label-header_criterias='More criterias'
         label-format='Format:'
@@ -49,12 +48,10 @@ div.container_min
         label-country='Country of publication'
         label-language.name='Language'
         label-fields='Field'
-        label-steps='Step of : Staring up a cooperative business'
         widget-header_criterias='cs-section_header'
 
         range-language.name=`${endpoints.languages}`
         range-fields=`${endpoints.fields}`
-        range-steps=`${endpoints.steps}`
         range-format=`${endpoints.formats}`
 
         multiple-language.name='sib-multiple-select'
@@ -65,9 +62,6 @@ div.container_min
 
         multiple-fields='sib-multiple-select'
         widget-fields='sib-form-auto-completion'
-
-        multiple-steps='sib-multiple-select'
-        widget-steps='sib-form-auto-completion'
                 
         naked
     )
@@ -92,8 +86,8 @@ div.side-block.block_log
 
     sib-display#step1.resource_by_step(
         data-src=`${endpoints.steps}1/resources/`,
-        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
+        fields='name, author, format, publication_year, description,  country, language.name, field',
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
@@ -105,7 +99,6 @@ div.side-block.block_log
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="cs-display-property"
-        widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
         multiple-format
@@ -125,8 +118,8 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}2/resources/`,
-        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author),  more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
+        fields='name, author, format, publication_year, description,  country, language.name, field',
+        search-fields='search_for_a_resource(name, description, author),  more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
@@ -138,7 +131,6 @@ div.side-block.block_log
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="cs-display-property"
-        widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
         multiple-format
@@ -159,8 +151,8 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}3/resources/`,
-        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
+        fields='name, author, format, publication_year, description,  country, language.name, field',
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
@@ -172,7 +164,6 @@ div.side-block.block_log
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="cs-display-property"
-        widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
         multiple-format
@@ -193,8 +184,8 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}4/resources/`,
-        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
+        fields='name, author, format, publication_year, description,  country, language.name, field',
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
@@ -206,7 +197,6 @@ div.side-block.block_log
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="cs-display-property"
-        widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
         multiple-format
@@ -226,8 +216,8 @@ div.side-block.block_log
 
     sib-display.resource_by_step(
         data-src=`${endpoints.steps}5/resources/`,
-        fields='name, author, format, publication_year, description,  country, language.name, field, steps',
-        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field, steps)',  
+        fields='name, author, format, publication_year, description,  country, language.name, field',
+        search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
@@ -239,7 +229,6 @@ div.side-block.block_log
         widget-field='cs-display-property'
         widget-language.name="hidden-widget"
         widget-author="cs-display-property"
-        widget-steps="hidden-widget"
         widget-format='cs-display-multiple-property'
         label-format=''
         multiple-format
-- 
GitLab


From 83ffe1870f94bf8d991360bc5f288e6eaf468253 Mon Sep 17 00:00:00 2001
From: Alice <alice.poggioli@hotmail.fr>
Date: Fri, 13 Sep 2019 16:18:44 +0200
Subject: [PATCH 07/11] WIP: TRy with sib-form-dropdown.

---
 src/includes/entrepreneur/resources/list.pug |  24 +-
 src/scripts/coopstarter.js                   | 229 ++++++++++---------
 2 files changed, 137 insertions(+), 116 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index 44bcc1fb..e5075b67 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -57,7 +57,7 @@ div.container_min
         multiple-language.name='sib-multiple-select'
         widget-language.name='sib-form-auto-completion'
 
-        multiple-format='sib-multiple-select'
+        multiple-format='sib-form-dropdown'
         widget-format='sib-form-auto-completion'
 
         multiple-fields='sib-multiple-select'
@@ -88,9 +88,13 @@ div.side-block.block_log
         data-src=`${endpoints.steps}1/resources/`,
         fields='name, author, format, publication_year, description,  country, language.name, field',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
+        search-range-format=`${endpoints.formats}`
 
         search-widget-search_for_a_resource="hidden-widget"
-        search-widget-more_criterias_hidden="hidden-widget"
+
+ 
+        search-multiple-format='sib-form-dropdown'
+        search-widget-format='sib-form-auto-completion'
  
         widget-name='cs-display-property'
         widget-country='cs-display-property'
@@ -121,8 +125,12 @@ div.side-block.block_log
         fields='name, author, format, publication_year, description,  country, language.name, field',
         search-fields='search_for_a_resource(name, description, author),  more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
+        search-range-format=`${endpoints.formats}`
+
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
+        search-multiple-format='sib-form-dropdown'
+        search-widget-format='sib-form-auto-completion'
 
         widget-name='cs-display-property'
         widget-country='cs-display-property'
@@ -154,8 +162,12 @@ div.side-block.block_log
         fields='name, author, format, publication_year, description,  country, language.name, field',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
+        search-range-format=`${endpoints.formats}`
+
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
+        search-multiple-format='sib-form-dropdown'
+        search-widget-format='sib-form-auto-completion'
 
         widget-name='cs-display-property'
         widget-country='cs-display-property'
@@ -187,8 +199,12 @@ div.side-block.block_log
         fields='name, author, format, publication_year, description,  country, language.name, field',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
+        search-range-format=`${endpoints.formats}`
+
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
+        search-multiple-format='sib-form-dropdown'
+        search-widget-format='sib-form-auto-completion'
 
         widget-name='cs-display-property'
         widget-country='cs-display-property'
@@ -219,8 +235,12 @@ div.side-block.block_log
         fields='name, author, format, publication_year, description,  country, language.name, field',
         search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language.name, field)',  
 
+        search-range-format=`${endpoints.formats}`
+
         search-widget-search_for_a_resource="hidden-widget"
         search-widget-more_criterias_hidden="hidden-widget"
+        search-multiple-format='sib-form-dropdown'
+        search-widget-format='sib-form-auto-completion'
 
         widget-name='cs-display-property'
         widget-country='cs-display-property'
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 295fe98d..551622dd 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -70,132 +70,133 @@ jQuery(document).ready(function($) {
     });
   }
 
+  //ENTREPRENEUR DASHBOARD*************************************************************
   //In the entrepreneur dashboard, we set data from the display form to the hidden ones.
   var forms = document.querySelectorAll(".resource_by_step");
 
   forms.forEach(form => {
-    form.addEventListener(
-      "populate",
-      e => {
-        //To retrieve keyword
-        //https://git.happy-dev.fr/startinblox/framework/sib-core/issues/379
-        //TODO: Wait for a solution to filter with multiple value with "OR" instead of "AND".
-        let keyword_form = document.getElementById("search-by-keyword");
-        let keyword_field = keyword_form.querySelector(`input[name="keyword"]`);
-
-        let keyword_submit = document.getElementById(`keyword_submit`);
-        let keyword_hidden_fields = document.querySelectorAll(
-          'hidden-widget[name="search_for_a_resource"] input'
+    form.addEventListener("populate", e => {
+      //SEARCH BY KEYWORD
+      //To retrieve keyword
+      //https://git.happy-dev.fr/startinblox/framework/sib-core/issues/379
+      //TODO: Wait for a solution to filter with multiple value with "OR" instead of "AND".
+      let keyword_form = document.getElementById("search-by-keyword");
+      let keyword_field = keyword_form.querySelector(`input[name="keyword"]`);
+
+      let keyword_submit = document.getElementById(`keyword_submit`);
+      let keyword_hidden_fields = document.querySelectorAll(
+        'hidden-widget[name="search_for_a_resource"] input'
+      );
+
+      keyword_submit.addEventListener("click", function() {
+        keyword_hidden_fields.forEach(hidden_field => {
+          hidden_field.setAttribute("value", keyword_field.value);
+          form.querySelector("sib-form").component.inputChange();
+        });
+      });
+
+      //SEARCH IN DATABASE INSTANCE ONLY
+      let instance_only = document.getElementById("instance_database_only");
+      let checkbox_instance_only = instance_only.querySelector("input");
+
+      checkbox_instance_only.onclick = function() {
+        if (this.checked) {
+          //We have to retrieve all data-scr needed to make them pointed only on the instance.
+          //How to?
+        }
+      };
+
+      //MORE CRITERIAS
+      //TODO: Refactor this section ?
+      const more_criterias_form = document.getElementById("more_criterias");
+
+      // https://git.happy-dev.fr/startinblox/framework/sib-core/issues/453
+      window.setTimeout(() => {
+        //To retrieve format
+        //TODO: How we should filled the hidden field with multiple value?
+        //TODO: The hidden search field set with one value doesn't work
+        let format_field_search = more_criterias_form.querySelector(
+          `select[name="format"]`
+        );
+        format_hidden_field = document.querySelectorAll(
+          'hidden-widget[name="more_criterias_hidden"] select[name="format"]'
+        );
+
+
+
+        format_field_search.onchange = function() {
+          console.log("format_field_search", format_field_search);
+          format_hidden_field.forEach(function(select_hidden) {
+            options_hidden = select_hidden.getElementsByTagName("option");
+
+            for (let option_hidden of options_hidden) {
+
+              option_selected = format_field_search.querySelector(
+                "option:checked"
+              );
+
+              if (option_hidden.value == option_selected.value) {
+                console.log("option_selected", option_selected )
+                option_hidden.setAttribute("checked", "checked");
+                console.log("option_hidden", option_hidden )
+              }
+              
+            }
+          });
+        };
+
+        //To retrieve language
+        //TODO: How we should filled the hidden field?
+        let language_field_search = more_criterias_form.querySelector(
+          `select[name="language.name"]`
+        );
+        language_hidden_fields = document.querySelectorAll(
+          'hidden-widget[name="more_criterias_hidden"] input[name="language.name"]'
         );
 
-        keyword_submit.addEventListener("click", function() {
-          keyword_hidden_fields.forEach(hidden_field => {
-            hidden_field.setAttribute("value", keyword_field.value);
+        language_field_search.onchange = function() {
+          language_hidden_fields.forEach(language_field => {
+            language_field.setAttribute(
+              "value",
+              language_field_search.options[language_field_search.selectedIndex]
+                .text
+            );
             form.querySelector("sib-form").component.inputChange();
           });
-        });
+        };
 
-        //MORE CRITERIAS
-        //TODO: Refactor this section ?
-        const more_criterias_form = document.getElementById("more_criterias");
-
-        // https://git.happy-dev.fr/startinblox/framework/sib-core/issues/453
-        window.setTimeout(() => {
-
-          //To retrieve format
-          //TODO: How we should filled the hidden field with multiple value?
-          //TODO: The hidden search field set with one value doesn't work
-          let format_field_search = more_criterias_form.querySelector(
-            `select[name="format"]`
-          );
-          format_hidden_fields = document.querySelectorAll(
-            'hidden-widget[name="more_criterias_hidden"] input[name="format"]'
-          );
-
-          format_field_search.onchange = function() {
-            format_hidden_fields.forEach(format_field => {
-              format_field.setAttribute(
-                "value",
-                format_field_search.options[format_field_search.selectedIndex]
-                  .text
-              );
-              form.querySelector("sib-form").component.inputChange();
-            });
-          };
-
-          //To retrieve language
-          //TODO: How we should filled the hidden field?
-          let language_field_search = more_criterias_form.querySelector(
-            `select[name="language.name"]`
-          );
-          language_hidden_fields = document.querySelectorAll(
-            'hidden-widget[name="more_criterias_hidden"] input[name="language.name"]'
-          );
-
-          language_field_search.onchange = function() {
-            language_hidden_fields.forEach(language_field => {
-              language_field.setAttribute(
-                "value",
-                language_field_search.options[language_field_search.selectedIndex]
-                  .text
-              );
-              form.querySelector("sib-form").component.inputChange();
-            });
-          };
-
-          // //To retrieve step, but I think it's gonna disapear
-          // let step_field_search = more_criterias_form.querySelector(
-          //   `select[name="step"]`
-          // );
-          // step_hidden_fields = document.querySelectorAll(
-          //   'hidden-widget[name="more_criterias_hidden"] input[name="step"]'
-          // );
-
-          // step_field_search.onchange = function() {
-          //   step_hidden_fields.forEach(step_field => {
-          //     step_field.setAttribute(
-          //       "value",
-          //       step_field_search.options[step_field_search.selectedIndex]
-          //         .text
-          //     );
-          //     form.querySelector("sib-form").component.inputChange();
-          //   });
-          // };
-
-          //To retrieve year of publication
-          //WARNING: If the user want to select "20" to get 21century made, he will get no result. 
-          //I think it is a UX problem.
-          let year_field_search = more_criterias_form.querySelector(
-            `input[name="publication_year"]`
-          );
-          let year_hidden_fields = document.querySelectorAll(
-            'hidden-widget[name="more_criterias_hidden"] input[name="publication_year"]'
-          );
-
-          year_field_search.addEventListener("input", function() {
-            year_hidden_fields.forEach(year_field => {
-              year_field.setAttribute("value", year_field_search.value);
-              form.querySelector("sib-form").component.inputChange();
-            });
+        //To retrieve year of publication
+        //WARNING: If the user want to select "20" to get 21century made, he will get no result.
+        //I think it is a UX problem.
+        let year_field_search = more_criterias_form.querySelector(
+          `input[name="publication_year"]`
+        );
+        let year_hidden_fields = document.querySelectorAll(
+          'hidden-widget[name="more_criterias_hidden"] input[name="publication_year"]'
+        );
+
+        year_field_search.addEventListener("input", function() {
+          year_hidden_fields.forEach(year_field => {
+            year_field.setAttribute("value", year_field_search.value);
+            form.querySelector("sib-form").component.inputChange();
           });
+        });
 
-          //To retrieve the country
-          let country_field_search = more_criterias_form.querySelector(
-            `input[name="country"]`
-          );
-          let country_hidden_fields = document.querySelectorAll(
-            'hidden-widget[name="more_criterias_hidden"] input[name="country"]'
-          );
-
-          country_field_search.addEventListener("input", function() {
-            country_hidden_fields.forEach(country_field => {
-              country_field.setAttribute("value", country_field_search.value);
-              form.querySelector("sib-form").component.inputChange();
-            });
+        //To retrieve the country
+        let country_field_search = more_criterias_form.querySelector(
+          `input[name="country"]`
+        );
+        let country_hidden_fields = document.querySelectorAll(
+          'hidden-widget[name="more_criterias_hidden"] input[name="country"]'
+        );
+
+        country_field_search.addEventListener("input", function() {
+          country_hidden_fields.forEach(country_field => {
+            country_field.setAttribute("value", country_field_search.value);
+            form.querySelector("sib-form").component.inputChange();
           });
         });
-      },
-      4000
-    );
+      }, 4000);
+    });
   });
 });
-- 
GitLab


From 692fe6ac2d7640a9d36019573ef3e521847de1bc Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Fri, 13 Sep 2019 16:23:16 +0200
Subject: [PATCH 08/11] Adding proper watching script

---
 package.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index 1fea6aeb..c51b7fa7 100644
--- a/package.json
+++ b/package.json
@@ -10,8 +10,8 @@
     "copy-js": "cp ./src/scripts/*.js  ./www/scripts/",
     "copy-fonts": "cp -R ./src/fonts  ./www",
     "copy-images": "cp -R ./src/images  ./www",
-    "watch-js": "onchange -i -k './src/scrips/*.js' -- npm run",
-    "watch": "run-p scss pug copy-fonts copy-images copy-js watch-js",
+    "watch-js": "onchange 'src/scripts/*.js' -- run-s copy-js",
+    "watch": "run-p scss pug watch-js copy-fonts copy-images",
     "serve": "node server.js"
   },
   "devDependencies": {
-- 
GitLab


From f32c8052b8d9737590cd98cc225585e76f8e0504 Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Fri, 13 Sep 2019 16:27:18 +0200
Subject: [PATCH 09/11] Fix previous

---
 src/includes/entrepreneur/resources/list.pug | 30 ++------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index 0b451730..3a340d5c 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -94,35 +94,9 @@ container.block_list.flex.flex_espace
 
         multiple-fields='sib-multiple-select'
         widget-fields='sib-form-auto-completion'
-                
-                label-header_criterias='More criterias'
-                label-format='Format:'
-                label-publication_year='Year of publication'
-                label-country='Country of publication'
-                label-language.name='Language'
-                label-fields='Field'
-                label-steps='Step of : Staring up a cooperative business'
-                widget-header_criterias='cs-section_header'
-
-                range-language.name=`${endpoints.languages}`
-                range-fields=`${endpoints.fields}`
-                range-steps=`${endpoints.steps}`
-                range-format=`${endpoints.formats}`
-
-                multiple-language.name='sib-multiple-select'
-                widget-language.name='sib-form-auto-completion'
-
-                multiple-format='sib-multiple-select'
-                widget-format='sib-form-auto-completion'
-
-                multiple-fields='sib-multiple-select'
-                widget-fields='sib-form-auto-completion'
-
-                multiple-steps='sib-multiple-select'
-                widget-steps='sib-form-auto-completion'
                         
-                naked
-            )
+        naked
+    )
 
     div.w_25
         div.block_aside_entre
-- 
GitLab


From 409bf8a26e74dc192d0654cf611e20b2d4fe6fbf Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Fri, 13 Sep 2019 16:33:33 +0200
Subject: [PATCH 10/11] Fix previous

---
 src/includes/entrepreneur/resources/list.pug | 85 +++++++-------------
 1 file changed, 27 insertions(+), 58 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index 3a340d5c..e7cb36de 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -39,64 +39,33 @@ container.block_list.flex.flex_espace
                 naked
             )
 
-.block_log.block_creat_count
-    h2.title_form Search for a resource
-    sib-form#search-by-keyword(
-        data-src=`${endpoints.resources}`,
-        fields='keyword(name_keyword, description, author)' 
-           
-        label-keyword="Search by author, name..."
-
-        widget-keyword="sib-form-placeholder-text"
-
-        widget-description='cs-display-property'
-        widget-name_keyword='cs-display-property'
-        widget-author='cs-display-property'
-
-        naked    
-    )
-
-    div#keyword_submit.button__actions
-        div.button_base.ico_gauche Search
-
-    sib-form#instance_database_only(
-        data-src=`${endpoints.resources}`,
-        fields='instance_database_only'    
-
-        widget-instance_database_only='cs-display-checkbox'
-
-        class-instance_database_only = 'ss-list checkbox'
-
-        naked
-    )
-
-    sib-form#more_criterias(
-        data-src=`${endpoints.resources}`,
-        fields='header_criterias, format, publication_year, country, language.name, fields'
-        
-        label-header_criterias='More criterias'
-        label-format='Format:'
-        label-publication_year='Year of publication'
-        label-country='Country of publication'
-        label-language.name='Language'
-        label-fields='Field'
-        widget-header_criterias='cs-section_header'
-
-        range-language.name=`${endpoints.languages}`
-        range-fields=`${endpoints.fields}`
-        range-format=`${endpoints.formats}`
-
-        multiple-language.name='sib-multiple-select'
-        widget-language.name='sib-form-auto-completion'
-
-        multiple-format='sib-form-dropdown'
-        widget-format='sib-form-auto-completion'
-
-        multiple-fields='sib-multiple-select'
-        widget-fields='sib-form-auto-completion'
-                        
-        naked
-    )
+        sib-form#more_criterias(
+            data-src=`${endpoints.resources}`,
+            fields='header_criterias, format, publication_year, country, language.name, fields'
+            
+            label-header_criterias='More criterias'
+            label-format='Format:'
+            label-publication_year='Year of publication'
+            label-country='Country of publication'
+            label-language.name='Language'
+            label-fields='Field'
+            widget-header_criterias='cs-section_header'
+
+            range-language.name=`${endpoints.languages}`
+            range-fields=`${endpoints.fields}`
+            range-format=`${endpoints.formats}`
+
+            multiple-language.name='sib-multiple-select'
+            widget-language.name='sib-form-auto-completion'
+
+            multiple-format='sib-form-dropdown'
+            widget-format='sib-form-auto-completion'
+
+            multiple-fields='sib-multiple-select'
+            widget-fields='sib-form-auto-completion'
+                            
+            naked
+        )
 
     div.w_25
         div.block_aside_entre
-- 
GitLab


From 25c8ff51400401ce8ed4ffb085db5a4f9614409f Mon Sep 17 00:00:00 2001
From: Benoit Alessandroni <benoit@happy-dev.fr>
Date: Fri, 13 Sep 2019 17:23:18 +0200
Subject: [PATCH 11/11] Fixing the format filter

---
 src/includes/entrepreneur/resources/list.pug |  6 ++--
 src/scripts/coopstarter.js                   | 30 ++++++++++++--------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug
index e7cb36de..a91cde02 100644
--- a/src/includes/entrepreneur/resources/list.pug
+++ b/src/includes/entrepreneur/resources/list.pug
@@ -94,10 +94,8 @@ container.block_list.flex.flex_espace
         search-range-format=`${endpoints.formats}`
 
         search-widget-search_for_a_resource="hidden-widget"
-
- 
-        search-multiple-format='sib-form-dropdown'
-        search-widget-format='sib-form-auto-completion'
+        search-widget-more_criterias_hidden="hidden-widget"
+        search-widget-format='sib-form-dropdown'
  
         widget-name='cs-display-property'
         widget-country='cs-display-property'
diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js
index 551622dd..aef0b5ff 100644
--- a/src/scripts/coopstarter.js
+++ b/src/scripts/coopstarter.js
@@ -123,24 +123,30 @@ jQuery(document).ready(function($) {
         );
 
 
-
+        //TODO: Every time the format field in the search form changes
+        //Iterate through all 5 filters form associated with the sib-displays
+        //Iterate through their inputs to get the format one
+        //Change the value and the selected option of this field
+        //Reload the component to trigger the filter 
         format_field_search.onchange = function() {
-          console.log("format_field_search", format_field_search);
+          let option_selected = format_field_search.querySelector(
+            "option:checked"
+          );
+
           format_hidden_field.forEach(function(select_hidden) {
             options_hidden = select_hidden.getElementsByTagName("option");
-
             for (let option_hidden of options_hidden) {
-
-              option_selected = format_field_search.querySelector(
-                "option:checked"
-              );
-
+              //Removing the selected attribute from previous selection
+              option_hidden.removeAttribute("selected");
               if (option_hidden.value == option_selected.value) {
-                console.log("option_selected", option_selected )
-                option_hidden.setAttribute("checked", "checked");
-                console.log("option_hidden", option_hidden )
+                //Actually selecting the option if it is the good one
+                option_hidden.setAttribute("selected", "selected");
+                select_hidden.setAttribute('value', option_selected.value)
               }
-              
+
+              //Trigerring a reload of the associated form
+              let parent_form = select_hidden.closest('sib-form');
+              parent_form.component.inputChange();
             }
           });
         };
-- 
GitLab