mirror of
https://github.com/simonw/datasette.git
synced 2026-05-27 20:36:17 +02:00
No hide this column on last remaining column
This commit is contained in:
parent
68966880c2
commit
0f81553b3f
1 changed files with 9 additions and 1 deletions
|
|
@ -110,6 +110,14 @@ function shouldShowShowAllColumns() {
|
|||
return params.getAll("_nocol").length || params.getAll("_col").length;
|
||||
}
|
||||
|
||||
function hasMultipleVisibleColumns(manager) {
|
||||
return (
|
||||
Array.from(document.querySelectorAll(manager.selectors.tableHeaders)).filter(
|
||||
(th) => th.dataset.column && th.dataset.isLinkColumn !== "1",
|
||||
).length > 1
|
||||
);
|
||||
}
|
||||
|
||||
function buildColumnActionItems(manager, th, options) {
|
||||
options = options || {};
|
||||
var params = getParams();
|
||||
|
|
@ -163,7 +171,7 @@ function buildColumnActionItems(manager, th, options) {
|
|||
});
|
||||
}
|
||||
|
||||
if (th.dataset.isPk !== "1") {
|
||||
if (th.dataset.isPk !== "1" && hasMultipleVisibleColumns(manager)) {
|
||||
columnActions.push({
|
||||
label: "Hide this column",
|
||||
href: hideColumnUrl(column),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue