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 225: Line 225:
         const dataSources = data[0];
         const dataSources = data[0];
         const dcts = data[1];
         const dcts = data[1];
        // dataSources.unshift(dataSources.splice(dataSources.findIndex(src => src.name === 'Web'), 1)[0]);
        // dataSources.unshift(dataSources.splice(dataSources.findIndex(src => src.name === 'Crowd'), 1)[0]);


         // Set up filters.
         // Set up filters.
Line 236: Line 233:
             for (const source of layoutGroup) {
             for (const source of layoutGroup) {
                 let idx = sourcesCopy.findIndex(src => src.name === source);
                 let idx = sourcesCopy.findIndex(src => src.name === source);
                 if (idx !== -1) {
                 if (idx !== -1) { group.push(sourcesCopy.splice(idx, 1)[0]); }
                    group.push(sourcesCopy.splice(idx, 1)[0]);
                }
             }
             }
             if (group.length > 0) groupedSources.push(group);
             if (group.length > 0) { groupedSources.push(group); }
         }
         }
         groupedSources.push(sourcesCopy);
         groupedSources.push(sourcesCopy);


 
         let filterHtml = '';
         let html2 = '';
         groupedSources.forEach(group => {
         groupedSources.forEach(group => {
             html2 += group.reduce((prev, curr, idx) => {
             filterHtml += group.reduce((prev, curr, idx) => {
                 const identifier = escapeAttr(curr.name);
                 const identifier = escapeAttr(curr.name);
                 return prev + '<div ' + (idx === 0 ? ' class="filter-group-start">' : '>') +
                 return prev + '<div ' + (idx === 0 ? ' class="filter-group-start">' : '>') +
Line 254: Line 248:
             }, '');
             }, '');
         })
         })
 
         document.getElementById('data-source-filter').innerHTML = filterHtml;
        const filterHtml = dataSources.reduce((prev, curr, idx) => {
            const identifier = escapeAttr(curr.name);
            return prev + '<div ' + (idx === 2 ? ' style="grid-column-start: 1">' : '>') +
                '<input type="checkbox" id="filter-' + identifier + '" value="' + curr.name + '" checked>' +
                '<label for="filter-' + identifier + '"><img src="' + curr.image + '"> ' + curr.name + '</label></div>'
        }, '');
         document.getElementById('data-source-filter').innerHTML = html2;


         // Set up table.
         // Set up table.

Revision as of 14:54, 13 June 2022

Development verstion of the DCT List.
Not ready for production!