Widget: UseCaseList: Difference between revisions

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


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


             const eventTypeOptions = Array.from(document.querySelectorAll('#event-type-filter input[type="checkbox"]'));
             const selectedEvents = Array.from(document.querySelectorAll('#event-type-filter input[type="checkbox"]:checked'))
            const selectedeventType = eventTypeOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.eventType = selectedeventType.length === eventTypeOptions.length ? undefined : selectedeventType;
             if (selectedEvents.length > 0) filterState.eventType = selectedEvents;


             const categoryOptions = Array.from(document.querySelectorAll('#category-filter input[type="checkbox"]'));
             const selectedCats = Array.from(document.querySelectorAll('#category-filter input[type="checkbox"]:checked'))
            const selectedcategorys = categoryOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.category = selectedcategorys.length === categoryOptions.length ? undefined : selectedcategorys;
             if (selectedCats.length > 0) filterState.category = selectedCats;


             const scaleOptions = Array.from(document.querySelectorAll('#scale-filter input[type="checkbox"]'));
             const selectedScales = Array.from(document.querySelectorAll('#scale-filter input[type="checkbox"]:checked'))
            const selectedScaleOptions = scaleOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
                .map(checkbox => checkbox.value);
             filterState.scale = selectedScaleOptions.length === scaleOptions.length ? undefined : selectedScaleOptions;
             if (selectedScales.length > 0) filterState.scale = selectedScales;


             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 phaseOptions = Array.from(document.querySelectorAll('#phases-filter input[type="checkbox"]'));
             const selectedPhases = Array.from(document.querySelectorAll('#phases-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;


             table.setFilter(useCaseFilter, filterState);
             table.setFilter(useCaseFilter, filterState);
Line 351: Line 351:


             const typeCheck = filterState.type
             const typeCheck = filterState.type
                 ? useCase[TYPE_PROP].some(type => filterState.type.includes(type))
                 ? filterState.type.every(type => useCase[TYPE_PROP].includes(type))
                 : true;
                 : true;
             const eventTypeCheck = filterState.eventType
             const eventTypeCheck = filterState.eventType
                 ? useCase[EVENT_PROP].some(event => filterState.eventType.includes(event))
                 ? filterState.eventType.every(event => useCase[EVENT_PROP].includes(event))
                 : true;
                 : true;
             const categoryCheck = filterState.category
             const categoryCheck = filterState.category
                 ? useCase[CAT_PROP].some(target => filterState.category.includes(target))
                 ? filterState.category.every(cat => useCase[CAT_PROP].includes(cat))
                 : true;
                 : true;
             const scaleCheck = filterState.scale
             const scaleCheck = filterState.scale
                 ? useCase[SCALE_PROP].some(ex => filterState.scale.includes(ex))
                 ? filterState.scale.every(scale => useCase[SCALE_PROP].includes(scale))
                 : true;
                 : true;
             const thematicCheck = filterState.thematics
             const thematicCheck = filterState.thematics
                 ? useCase[THEME_PROP].some(theme => filterState.thematics.includes(theme))
                 ? filterState.thematics.every(thematic => useCase[THEME_PROP].includes(thematic))
                 : true;
                 : true;
             const phaseCheck = filterState.phases
             const phaseCheck = filterState.phases
                 ? useCase[PHASE_PROP].some(phase => filterState.phases.includes(phase))
                 ? filterState.phases.every(phase => useCase[PHASE_PROP].includes(phase))
                 : true;
                 : true;
             return typeCheck && eventTypeCheck && categoryCheck && scaleCheck && thematicCheck && phaseCheck;
             return typeCheck && eventTypeCheck && categoryCheck && scaleCheck && thematicCheck && phaseCheck;

Revision as of 15:23, 21 March 2023

Current version of the List of Use Cases.
currently in use!