Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 69: | Line 69: | ||
} | } | ||
/** @param {string} text */ | /** @param {string} text */ | ||
function escapeAttr(text) { | function escapeAttr(text) { | ||
return text ? text.replace(/\s/g, '-') : text; | return text ? text.replace(/\s/g, '-') : text; | ||
Line 108: | Line 108: | ||
} | } | ||
/** | /** | ||
* @param {DCT} dct | * @param {DCT} dct | ||
* @param {Partial<DCT>} filterState | * @param {Partial<DCT>} filterState | ||
Line 143: | Line 143: | ||
const filterHtml = dataSources.reduce((prev, curr) => { | const filterHtml = dataSources.reduce((prev, curr) => { | ||
const identifier = escapeAttr(curr.name); | const identifier = escapeAttr(curr.name); | ||
return prev + | return prev + | ||
'<div><input type="checkbox" id="filter-' + identifier + '" value="' + curr.name + '" checked>' + | '<div><input type="checkbox" id="filter-' + identifier + '" value="' + curr.name + '" checked>' + | ||
'<label for="filter-' + identifier + '"><img src="' + curr.image + '"> ' + curr.name + '</label></div>' | '<label for="filter-' + identifier + '"><img src="' + curr.image + '"> ' + curr.name + '</label></div>' | ||
Line 177: | Line 177: | ||
] | ] | ||
}); | }); | ||
tabulator.on('tableBuilt', () => { | tabulator.on('tableBuilt', () => { | ||
tabulator.setData(dcts); | tabulator.setData(dcts); | ||
table = tabulator; | table = tabulator; | ||
Line 183: | Line 183: | ||
tabulator.on('dataFiltered', (filters, rows) => { | tabulator.on('dataFiltered', (filters, rows) => { | ||
if (!(filters[0] && filters[0].type)) { return; } | if (!(filters[0] && filters[0].type)) { return; } | ||
const selectedSources = filters[0].type.dataSources; | |||
document.querySelectorAll('.data-source-cell .data-source-img').forEach(img => { | |||
if (selectedSources.includes(img.dataset.value)) { img.classList.remove('unselected') } | |||
else { img.classList.add('unselected'); } | |||
}); | |||
}); | }); | ||
Revision as of 09:57, 9 June 2022
Development verstion of the DCT List.
Not ready for production!