fix(legacy): keep datatable settings between views (#2519)

Use a different storage key for datatable settings for the dashboard and
builder views. The settings were overwritten when the other view was
loaded.
This commit is contained in:
Jonas L 2023-04-24 15:52:52 +02:00 committed by GitHub
parent 2fd5b50229
commit aa98309634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -864,6 +864,12 @@ var AIRTIME = (function (AIRTIME) {
DATATABLES
############################################ */
if (onDashboard) {
var dataTableLocalStorageKey = "datatables-library-dashboard";
} else {
var dataTableLocalStorageKey = "datatables-library-builder";
}
mod.libraryDataTable = $libTable.dataTable({
// put hidden columns at the top to insure they can never be visible
// on the table through column reordering.
@ -882,7 +888,7 @@ var AIRTIME = (function (AIRTIME) {
delete oData.aoSearchCols;
},
fnStateSave: function (oSettings, oData) {
localStorage.setItem("datatables-library", JSON.stringify(oData));
localStorage.setItem(dataTableLocalStorageKey, JSON.stringify(oData));
// Sadly, this is necessary because we need to unscramble the colReorder map on the backend
$.ajax({
@ -895,7 +901,9 @@ var AIRTIME = (function (AIRTIME) {
colReorderMap = oData.ColReorder;
},
fnStateLoad: function fnLibStateLoad(oSettings) {
var settings = JSON.parse(localStorage.getItem("datatables-library"));
var settings = JSON.parse(
localStorage.getItem(dataTableLocalStorageKey)
);
// local storage was empty lets get something from the backend
if (settings === null) {
@ -907,7 +915,10 @@ var AIRTIME = (function (AIRTIME) {
async: false, // <<< every sane browser will warn that this is not nice
dataType: "json",
success: function (oData) {
localStorage.setItem("datatables-library", JSON.stringify(oData));
localStorage.setItem(
dataTableLocalStorageKey,
JSON.stringify(oData)
);
settings = oData;
},
});