diff --git a/src/includes/entrepreneur/resources/list.pug b/src/includes/entrepreneur/resources/list.pug index e7cb36ded8129abd40f1133d51f2a48d041050d4..a91cde0256ae36102c01f4d530b585397b2bdce0 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 551622ddbdcc955d2ce50f2363982b2e8992756e..aef0b5ff23f1005613ff3ed0c522da8fb870ab5d 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(); } }); };