Widget: GuidelinesList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 358: Line 358:
             const filterState = {};
             const filterState = {};


             const phaseOptions = Array.from(document.querySelectorAll('#phase-filter input[type="checkbox"]'));
             const selectedPhases = Array.from(document.querySelectorAll('#phase-filter input[type="checkbox"]:checked'))
            const selectedPhases = phaseOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.phases = selectedPhases.length === phaseOptions.length ? undefined : selectedPhases;
             if (selectedPhases.length > 0) filterState.phases = selectedPhases;


             const thematicOptions = Array.from(document.querySelectorAll('#thematic-filter input[type="checkbox"]'));
             const selectedThematics = Array.from(document.querySelectorAll('#thematic-filter input[type="checkbox"]:checked'))
            const selectedthematics = thematicOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.thematics = selectedthematics.length === thematicOptions.length ? undefined : selectedthematics;
             if (selectedThematics.length > 0) filterState.thematics = selectedThematics;


             const audienceExperienceOptions = Array.from(document.querySelectorAll('#audience-experience-filter input[type="checkbox"]'));
             const selectedExp = Array.from(document.querySelectorAll('#audience-experience-filter input[type="checkbox"]:checked'))
            const selectedaudienceExperiences = audienceExperienceOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.audienceExperiences = selectedaudienceExperiences.length === audienceExperienceOptions.length ? undefined : selectedaudienceExperiences;
             if (selectedExp.length > 0) filterState.audienceExperiences = selectedExp;


             const audienceTargetOptions = Array.from(document.querySelectorAll('#target-audience-filter input[type="checkbox"]'));
             const selectedTA = Array.from(document.querySelectorAll('#target-audience-filter input[type="checkbox"]:checked'))
            const selectedaudienceTargets = audienceTargetOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.audienceTargets = selectedaudienceTargets.length === audienceTargetOptions.length ? undefined : selectedaudienceTargets;
             if (selectedTA.length > 0) filterState.audienceTargets = selectedTA;


             const languageOptions = Array.from(document.querySelectorAll('#language-filter input[type="checkbox"]'));
             const selectedLang = Array.from(document.querySelectorAll('#language-filter input[type="checkbox"]:checked'))
            const selectedlanguages = languageOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.languages = selectedlanguages.length === languageOptions.length ? undefined : selectedlanguages;
             if (selectedLang.length > 0) filterState.languages = selectedLang;


             const sourceOptions = Array.from(document.querySelectorAll('#data-source-filter input[type="checkbox"]'));
             const selectedSources = Array.from(document.querySelectorAll('#data-source-filter input[type="checkbox"]:checked'))
            const selectedSources = sourceOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.dataSources = selectedSources.length === sourceOptions.length ? undefined : selectedSources;
             if (selectedSources.length > 0) filterState.dataSources = selectedSources;


             const techOptions = Array.from(document.querySelectorAll('#tech-filter input[type="checkbox"]'));
             const selectedTech = Array.from(document.querySelectorAll('#tech-filter input[type="checkbox"]:checked'))
            const selectedTechs = techOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.techs = selectedTechs.length === techOptions.length ? undefined : selectedTechs;
             if (selectedTech.length > 0) filterState.techs = selectedTech;


             table.setFilter(guidelineFilter, filterState);
             table.setFilter(guidelineFilter, filterState);
Line 398: Line 398:
             // Passing an empty object (as with applyFilters(true)) should result in an unfiltered table.
             // Passing an empty object (as with applyFilters(true)) should result in an unfiltered table.
             const phaseCheck = filterState.phases
             const phaseCheck = filterState.phases
                 ? guideline[PHASE_PROP].some(phase => filterState.phases.includes(phase))
                 ? filterState.phases.every(phase => guideline[PHASE_PROP].includes(phase))
                 : true;
                 : true;
             const thematicCheck = filterState.thematics
             const thematicCheck = filterState.thematics
                 ? guideline[THEME_PROP].some(theme => filterState.thematics.includes(theme))
                 ? filterState.thematics.every(thematic => guideline[THEME_PROP].includes(thematic))
                 : true;
                 : true;
             const audienceExperiencesCheck = filterState.audienceExperiences
             const audienceExperiencesCheck = filterState.audienceExperiences
                 ? guideline[EX_PROP].some(ex => filterState.audienceExperiences.includes(ex))
                 ? filterState.audienceExperiences.every(exp => guideline[EX_PROP].includes(exp))
                 : true;
                 : true;
             const audienceTargetCheck = filterState.audienceTargets
             const audienceTargetCheck = filterState.audienceTargets
                 ? guideline[TA_PROP].some(target => filterState.audienceTargets.includes(target))
                 ? filterState.audienceTargets.every(target => guideline[TA_PROP].includes(target))
                 : true;
                 : true;
             const langCheck = filterState.languages
             const langCheck = filterState.languages
                 ? guideline[LANG_PROP].some(lang => filterState.languages.includes(lang))
                 ? filterState.languages.every(lang => guideline[LANG_PROP].includes(lang))
                 : true;
                 : true;
             const sourcesCheck = filterState.dataSources
             const sourcesCheck = filterState.dataSources
                 ? guideline[DATASRC_PROP].some(source => filterState.dataSources.includes(source))
                 ? filterState.dataSources.every(src => guideline[DATASRC_PROP].includes(src))
                 : true;
                 : true;
             const techCheck = filterState.techs
             const techCheck = filterState.techs
                 ? guideline[TECH_PROP].some(source => filterState.techs.includes(source))
                 ? filterState.techs.every(tech => guideline[TECH_PROP].includes(tech))
                 : true
                 : true;


             return phaseCheck && thematicCheck && audienceExperiencesCheck && audienceTargetCheck && langCheck && sourcesCheck & techCheck;
             return phaseCheck && thematicCheck && audienceExperiencesCheck && audienceTargetCheck && langCheck && sourcesCheck & techCheck;

Revision as of 16:54, 21 March 2023

Current version of the List of Guidelines.
Currently in use!