diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug index ef0085d2c9a4322fd091aaf50fa63f95986a58ca..b901bcde8939a9b2161f18fbf2d8140ae25c2674 100644 --- a/src/includes/entrepreneur/resources/list.pug +++ b/src/includes/entrepreneur/resources/list.pug @@ -41,18 +41,18 @@ container.block_list.flex.flex_espace sib-form#more_criterias( data-src=`${endpoints.resources}`, - fields='header_criterias, format, publication_year, country, language, fields' + fields='header_criterias, format, publication_year, country, language, field' label-header_criterias='More criterias' label-format='Format:' label-publication_year='Year of publication' label-country='Country of publication' label-language='Language' - label-fields='Field' + label-field='Field' widget-header_criterias='cs-section_header' range-language=`${endpoints.languages}` - range-fields=`${endpoints.fields}` + range-field=`${endpoints.fields}` range-format=`${endpoints.formats}` multiple-language='sib-form-dropdown' @@ -61,8 +61,8 @@ container.block_list.flex.flex_espace multiple-format='sib-form-dropdown' widget-format='sib-form-auto-completion' - multiple-fields='sib-form-dropdown' - widget-fields='sib-form-auto-completion' + multiple-field='sib-form-dropdown' + widget-field='sib-form-auto-completion' naked ) @@ -95,6 +95,7 @@ container.block_list.flex.flex_espace search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language, field)', search-range-format=`${endpoints.formats}` search-range-language=`${endpoints.languages}` + search-range-field=`${endpoints.fields}` search-widget-search_for_a_resource="hidden-widget" @@ -103,6 +104,8 @@ container.block_list.flex.flex_espace search-widget-format='sib-form-auto-completion' search-multiple-language='sib-form-dropdown' search-widget-language='sib-form-auto-completion' + search-multiple-field='sib-form-dropdown' + search-widget-field='sib-form-auto-completion' widget-name='cs-display-property' @@ -117,6 +120,8 @@ container.block_list.flex.flex_espace multiple-format label-language='' multiple-language + label-field='' + multiple-field paginate-by="5" ) @@ -138,6 +143,7 @@ container.block_list.flex.flex_espace search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language, field)', search-range-format=`${endpoints.formats}` search-range-language=`${endpoints.languages}` + search-range-field=`${endpoints.fields}` search-widget-search_for_a_resource="hidden-widget" @@ -146,6 +152,8 @@ container.block_list.flex.flex_espace search-widget-format='sib-form-auto-completion' search-multiple-language='sib-form-dropdown' search-widget-language='sib-form-auto-completion' + search-multiple-field='sib-form-dropdown' + search-widget-field='sib-form-auto-completion' widget-name='cs-display-property' @@ -160,6 +168,8 @@ container.block_list.flex.flex_espace multiple-format label-language='' multiple-language + label-field='' + multiple-field paginate-by="5" ) @@ -178,10 +188,11 @@ container.block_list.flex.flex_espace sib-display.resource_by_step( data-src=`${endpoints.steps}3/resources/`, - fields='name, author, format, publication_year, description, country, language, field', + fields='name, author, format, publication_year, description, country, language, field', search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language, field)', search-range-format=`${endpoints.formats}` search-range-language=`${endpoints.languages}` + search-range-field=`${endpoints.fields}` search-widget-search_for_a_resource="hidden-widget" @@ -190,6 +201,8 @@ container.block_list.flex.flex_espace search-widget-format='sib-form-auto-completion' search-multiple-language='sib-form-dropdown' search-widget-language='sib-form-auto-completion' + search-multiple-field='sib-form-dropdown' + search-widget-field='sib-form-auto-completion' widget-name='cs-display-property' @@ -204,6 +217,8 @@ container.block_list.flex.flex_espace multiple-format label-language='' multiple-language + label-field='' + multiple-field paginate-by="5" ) @@ -226,14 +241,17 @@ container.block_list.flex.flex_espace search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language, field)', search-range-format=`${endpoints.formats}` search-range-language=`${endpoints.languages}` - + search-range-field=`${endpoints.fields}` 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' search-multiple-language='sib-form-dropdown' search-widget-language='sib-form-auto-completion' + search-multiple-field='sib-form-dropdown' + search-widget-field='sib-form-auto-completion' widget-name='cs-display-property' @@ -248,6 +266,8 @@ container.block_list.flex.flex_espace multiple-format label-language='' multiple-language + label-field='' + multiple-field paginate-by="5" ) @@ -269,6 +289,7 @@ container.block_list.flex.flex_espace search-fields='search_for_a_resource(name, description, author), more_criterias_hidden(format, publication_year, country, language, field)', search-range-format=`${endpoints.formats}` search-range-language=`${endpoints.languages}` + search-range-field=`${endpoints.fields}` search-widget-search_for_a_resource="hidden-widget" @@ -277,6 +298,8 @@ container.block_list.flex.flex_espace search-widget-format='sib-form-auto-completion' search-multiple-language='sib-form-dropdown' search-widget-language='sib-form-auto-completion' + search-multiple-field='sib-form-dropdown' + search-widget-field='sib-form-auto-completion' widget-name='cs-display-property' @@ -291,6 +314,8 @@ container.block_list.flex.flex_espace multiple-format label-language='' multiple-language + label-field='' + multiple-field paginate-by="5" ) diff --git a/src/scripts/coopstarter.js b/src/scripts/coopstarter.js index accc0103bfbe238184e2c1c1759002e4a3be037f..684630dab557a561a388419fb36a88fed53341d7 100644 --- a/src/scripts/coopstarter.js +++ b/src/scripts/coopstarter.js @@ -142,7 +142,6 @@ jQuery(document).ready(function($) { 'hidden-widget[name="more_criterias_hidden"] select[name="format"]' ); - //TODO: The first time the event is not call. format_field_search.onchange = function() { let option_selected = format_field_search.querySelector( @@ -181,7 +180,7 @@ jQuery(document).ready(function($) { let option_selected = language_field_search.querySelector( "option:checked" ); - + language_hidden_field.forEach(function(select_hidden) { options_hidden = select_hidden.getElementsByTagName("option"); for (let option_hidden of options_hidden) { @@ -192,6 +191,7 @@ jQuery(document).ready(function($) { //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 @@ -203,6 +203,50 @@ jQuery(document).ready(function($) { }); }; + //To retrieve field + let field_field_search = more_criterias_form.querySelector( + `select[name="field"]` + ); + let field_hidden_field = document.querySelectorAll( + 'hidden-widget[name="more_criterias_hidden"] select[name="field"]' + ); + console.log("field_field_search", field_field_search) + + console.log("field_hidden_field", field_hidden_field) + + + field_field_search.onchange = function() { + let option_selected = field_field_search.querySelector( + "option:checked" + ); + + field_hidden_field.forEach(function(select_hidden) { + options_hidden = select_hidden.getElementsByTagName("option"); + for (let option_hidden of options_hidden) { + //Removing the selected attribute from previous selection + option_hidden.removeAttribute("selected"); + console.log("option_hidden.value", option_hidden.value) + console.log("option_selected.value", option_selected.value) + + if (option_hidden.value == option_selected.value) { + //Actually selecting the option if it is the good one + console.log("match") + option_hidden.setAttribute("selected", "selected"); + select_hidden.setAttribute('value', option_selected.value) + console.log("select_hidden", select_hidden) + + } + + //Trigerring a reload of the associated form + let parent_form = select_hidden.closest('sib-form'); + parent_form.component.inputChange(); + } + actualizePagination(); + 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.