Skip to content
Snippets Groups Projects
Commit 83ffe187 authored by Alice Poggioli's avatar Alice Poggioli
Browse files

WIP: TRy with sib-form-dropdown.

parent 1b4d3fff
No related branches found
No related tags found
1 merge request!36Feature/entrepreneur dashboard
......@@ -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'
......
......@@ -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);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment