mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Allow faceting on compound primary keys, closes #985
This commit is contained in:
parent
141544613f
commit
5d6bc4c268
1 changed files with 6 additions and 2 deletions
|
|
@ -88,9 +88,13 @@ var DROPDOWN_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="14" heig
|
||||||
sortDesc.style.display = 'block';
|
sortDesc.style.display = 'block';
|
||||||
sortDesc.setAttribute('href', sortDescUrl(column));
|
sortDesc.setAttribute('href', sortDescUrl(column));
|
||||||
}
|
}
|
||||||
/* Only show facet if it's not the first column, not selected, not a PK */
|
/* Only show facet if it's not the first column, not selected, not a single PK */
|
||||||
var isFirstColumn = th.parentElement.querySelector('th:first-of-type') == th;
|
var isFirstColumn = th.parentElement.querySelector('th:first-of-type') == th;
|
||||||
if (isFirstColumn || params.getAll('_facet').includes(column) || th.getAttribute('data-is-pk') == '1') {
|
var isSinglePk = (
|
||||||
|
th.getAttribute('data-is-pk') == '1' &&
|
||||||
|
document.querySelectorAll('th[data-is-pk="1"]').length == 1
|
||||||
|
);
|
||||||
|
if (isFirstColumn || params.getAll('_facet').includes(column) || isSinglePk) {
|
||||||
facetItem.style.display = 'none';
|
facetItem.style.display = 'none';
|
||||||
} else {
|
} else {
|
||||||
facetItem.style.display = 'block';
|
facetItem.style.display = 'block';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue