Skip to content
Snippets Groups Projects
Commit b9fb95f2 authored by Benoit Alessandroni's avatar Benoit Alessandroni
Browse files

update: fix connector script

parent 0348476c
No related branches found
No related tags found
1 merge request!19update: fix connector script
Pipeline #10359 passed with stage
in 50 seconds
......@@ -78,44 +78,6 @@ function manageAccordionByStep(){
}
}
/**
* Manage select hidden to fullfill them with more "more criterias" selection
* @param {HTMLElement} select_hidden - Hidden select to fullfill.
* @param {HTMLElement} option_selected - Option selcted to set in hidden select.
*/
function selectHiddenManagement(select_hidden, option_selected) {
options_hidden = select_hidden.getElementsByTagName("option");
for (let option_hidden of options_hidden) {
//Removing the selected attribute from previous selection
option_hidden.removeAttribute("selected");
if (option_hidden.value == option_selected.value) {
//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();
refreshPagination();
};
/**
* Manage input hidden field to fullfill them with more "more criterias" selection
* @param {HTMLElement} field - Hidden field to fullfill.
* @param {HTMLElement} field_search - Field with the value wanted by the user.
*/
function inputHiddenManagement(field, field_search) {
field.setAttribute("value", field_search.value);
let parent_form = field.closest("sib-form");
parent_form.component.inputChange();
refreshPagination();
}
/**
* Manage select hidden for type to fullfill them with more "more criterias" selection
* @param {HTMLElement} tab - Selected type tabs.
......@@ -127,9 +89,9 @@ function selectHiddenManagementForType(tab, form) {
let type_field_search = tab
.querySelector(`solid-display`)
.getAttribute("data-src");
//Fullfill hidden field
let hidden_type_select = form.querySelector('select[name="type"]');
hidden_options = hidden_type_select.getElementsByTagName("option");
for (let hidden_option of hidden_options) {
hidden_option.removeAttribute("selected");
......@@ -154,13 +116,16 @@ function selectHiddenManagementForType(tab, form) {
/**
* Init type to type 1
*/
function InitManagementForType(timeout) {
setTimeout(function() {
var tabs = document.querySelectorAll(".tablink.filter_by_type");
tabs[0].click();
tabs[0].classList.add("active");
refreshPagination();
}, timeout);
function initManagementForType(filterFormId) {
var tabs = document.querySelectorAll(".tablink.filter_by_type");
var form = document.getElementById(filterFormId);
var baseElement = document.querySelector('solid-display.resource_by_step.panel');
if (baseElement) {
baseElement.addEventListener("populate", event => {
selectHiddenManagementForType(tabs[0], form);
});
}
}
/**
......@@ -171,7 +136,6 @@ function InitManagementForType(timeout) {
*/
function addProperFilterToSearchComponents(targetId, filterFormId) {
var baseElement = document.getElementById(targetId);
if (baseElement) {
// Adding default type management
var form = document.getElementById(filterFormId);
......@@ -190,12 +154,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXX ON LOAD XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
(function() {
refreshPagination();
addProperFilterToSearchComponents("coopedia-search-results-component", "coopedia-search-box-component");
window.setTimeout( function() {
refreshPagination();
manageAccordionByStep();
}, 3000);
InitManagementForType(3000);
addProperFilterToSearchComponents("coopedia-search-results-component", "coopedia-search-box-component");
initManagementForType("coopedia-search-box-component");
}, 4000);
})();
......
import { SolidTemplateElement, Helpers } from 'https://cdn.skypack.dev/@startinblox/core@0.15';
import { SolidTemplateElement, Helpers } from 'https://cdn.skypack.dev/@startinblox/core@beta';
// Dev Mode
// const base_url = import.meta.url.replace(/\/[^\/]*$/, '');
......
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