Widget: DCTList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 1: Line 1:
<noinclude>Current version of the DCT List.<br><span style="color: red; font-weight: bold;">Not ready for
<noinclude>Current version of the DCT List.<br><span style="color: red; font-weight: bold;">Not ready for production!</span></noinclude>
        production!</span></noinclude>
<includeonly>
<includeonly>
     <link href="/resources/assets/tabulator.min.css" rel="stylesheet">
     <link href="/resources/assets/tabulator.min.css" rel="stylesheet">
Line 657: Line 656:
                 tabulator.setData(dcts);
                 tabulator.setData(dcts);
                 table = tabulator;
                 table = tabulator;
                // Set up the table if parameter was passed.
                const params = new URLSearchParams(window.location.search);
                const encoded = params.get('do');
                if (encoded) {
                    const actions = JSON.parse(decodeURIComponent(atob(encoded)));
                    const filter = actions.filter;
                    if (filter) {
                        // Functions filter
                        const functions = filter.functions;
                        if (functions) {
                            Object.keys(functions).forEach(subfun => {
                                const subfunEl = document.getElementById('subfunc-filter-' + escapeAttr(subfun));
                                subfunEl.checked = !!functions[subfun];
                               
                                const filterBlock = subfunEl.closest('.func-filter-block');
                                const category = filterBlock.querySelector('input.func-cat');
                                const subfunctions = filterBlock.querySelectorAll('.subfunc-filter-block input[type="checkbox"]');
                                // If no subfunctions are selected, deactivate the category. Activate otherwise.
                                const checkedSubs = Array.from(subfunctions).filter(sub => sub.checked).length;
                                category.checked = checkedSubs > 0;
                            });
                            document.getElementById('functions-filter').closest('.filter-wrapper').classList.toggle('open');
                        }
                       
                        // Further filters
                        // ...
                        applyFilters();
                        toggleFilter();
                    }
                    // Further actions (e.g. open filter panel, etc.)
                    // ...
                }
             });
             });


Line 737: Line 775:
             // Listen for changes in filter checkbox state.
             // Listen for changes in filter checkbox state.
             document.getElementById('functions-filter').addEventListener('change', event => {
             document.getElementById('functions-filter').addEventListener('change', event => {
                console.log('EVT:CHANGE')
                 const filterBlock = event.target.closest('.func-filter-block');
                 const filterBlock = event.target.closest('.func-filter-block');
                 const category = filterBlock.querySelector('input.func-cat');
                 const category = filterBlock.querySelector('input.func-cat');
Line 818: Line 855:
             ) { filterPane.classList.remove('open'); }
             ) { filterPane.classList.remove('open'); }
         }, { passive: true });
         }, { passive: true });
        window.addEventListener('load', function () {
            // Set up the table if parameter was passed.
            const params = new URLSearchParams(window.location.search);
            const encoded = params.get('do');
            if (encoded) {
                const actions = JSON.parse(decodeURIComponent(atob(encoded)));
                const filter = actions.filter;
                if (filter) {
                    // Functions filter
                    const functions = filter.functions;
                    if (functions) {
                        Object.keys(functions).forEach(subfun => {
                            document.getElementById('subfunc-filter-' + escapeAttr(subfun)).checked = !!functions[subfun];
                        });
                        document.getElementById('functions-filter').dispatchEvent(new Event('change'));
                        document.getElementById('functions-filter').closest('.filter-wrapper').classList.toggle('open');
                    }
                    // Further filters
                    // ...
                    applyFilters();
                    toggleFilter();
                }
                // Further actions (e.g. open filter panel, etc.)
                // ...
            }
        });
     </script>
     </script>



Revision as of 12:53, 5 June 2023

Current version of the DCT List.
Not ready for production!