diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug index ae045d1c4a2eaaacca516ba2bd16bda84bdcd5db..92a2467cb44d6d450305a11443e6e91aa9a9ed13 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 654f04c07ef01158ed255919a1cc3d4ccf1c06ce..4fea36a6f9782d6eeb1d774adb03c8ddd67b22e7 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 + ); }); });