Skip to content

Commit

Permalink
Merge pull request #727 from nscuro/fix-redundant-request
Browse files Browse the repository at this point in the history
Fix table column visibility preferences triggering redundant requests
  • Loading branch information
nscuro authored Feb 3, 2024
2 parents 883b651 + ff44ac3 commit 22371f5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,24 @@ export function getContextPath() {
}

export function loadUserPreferencesForBootstrapTable(_this, id, columns) {
const table = _this.$refs.table;
if (!table) {
console.error("No table defined in the calling component; Can't apply user preferences");
return;
}

columns.forEach((column) => {
_this.$set(column, "visible", (localStorage && localStorage.getItem(id + "Show" + common.capitalize(column.field)) !== null) ? (localStorage.getItem(id + "Show" + common.capitalize(column.field)) === "true") : column.visible);
const isVisible = column.visible;
const shouldShow = (localStorage && localStorage.getItem(id + "Show" + common.capitalize(column.field)) !== null)
? (localStorage.getItem(id + "Show" + common.capitalize(column.field)) === "true")
: isVisible;
if (isVisible !== shouldShow) {
if (shouldShow) {
table.showColumn(column.field);
} else {
table.hideColumn(column.field);
}
}
})
}

Expand Down

0 comments on commit 22371f5

Please sign in to comment.