mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 17:23:29 +02:00
Add the persistence of the columns setup
Add the persistence of the columns' visibility and ordering.
This commit is contained in:
parent
f3dea2fbad
commit
233d68952a
1 changed files with 57 additions and 5 deletions
|
@ -20,7 +20,7 @@ const EMPTY_ENTITY_ID = "0";
|
|||
const MAX_LENGTH_RADIUS = 9;
|
||||
const MINIMUM_COLUMN_WIDTH = 24;
|
||||
const SCROLLBAR_WIDTH = 20;
|
||||
const RESIZER_WIDTH = 10;
|
||||
const RESIZER_WIDTH = 13; //Must be the number of COLUMNS - 1.
|
||||
const DELTA_X_MOVE_COLUMNS_THRESHOLD = 2;
|
||||
const DELTA_X_COLUMN_SWAP_POSITION = 5;
|
||||
const CERTIFIED_PLACEHOLDER = "** Certified **";
|
||||
|
@ -283,6 +283,9 @@ const PROFILE = !ENABLE_PROFILING ? PROFILE_NOOP : function(name, fn, args) {
|
|||
|
||||
function loaded() {
|
||||
openEventBridge(function() {
|
||||
|
||||
var isColumnsSettingLoaded = false;
|
||||
|
||||
elEntityTable = document.getElementById("entity-table");
|
||||
elEntityTableHeader = document.getElementById("entity-table-header");
|
||||
elEntityTableBody = document.getElementById("entity-table-body");
|
||||
|
@ -1409,6 +1412,10 @@ function loaded() {
|
|||
column.elResizer.style.visibility = columnVisible && visibleColumns > 0 ? "visible" : "hidden";
|
||||
}
|
||||
|
||||
if (isColumnsSettingLoaded) {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'saveColumnsConfigSetting', columnsData: columns }));
|
||||
}
|
||||
|
||||
entityList.refresh();
|
||||
}
|
||||
|
||||
|
@ -1660,6 +1667,49 @@ function loaded() {
|
|||
} else {
|
||||
document.getElementById("hmdmultiselect").style.display = "none";
|
||||
}
|
||||
} else if (data.type === "loadedColumnsSetup") {
|
||||
if (data.columnsData !== "NO_DATA" && typeof(data.columnsData) === "object") {
|
||||
var isValid = true;
|
||||
var originalColumnIDs = [];
|
||||
for (let originalColumnID in COLUMNS) {
|
||||
originalColumnIDs.push(originalColumnID);
|
||||
}
|
||||
for (let columnSetupIndex in data.columnsData) {
|
||||
var checkPresence = originalColumnIDs.indexOf(data.columnsData[columnSetupIndex].columnID);
|
||||
if (checkPresence === -1) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isValid) {
|
||||
for (var columnIndex = 0; columnIndex < data.columnsData.length; columnIndex++) {
|
||||
if (data.columnsData[columnIndex].data.alwaysShown !== true) {
|
||||
var columnDropdownID = "entity-table-column-" + data.columnsData[columnIndex].columnID;
|
||||
if (data.columnsData[columnIndex].width !== 0) {
|
||||
document.getElementById(columnDropdownID).checked = false;
|
||||
document.getElementById(columnDropdownID).click();
|
||||
} else {
|
||||
document.getElementById(columnDropdownID).checked = true;
|
||||
document.getElementById(columnDropdownID).click();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (columnIndex = 0; columnIndex < data.columnsData.length; columnIndex++) {
|
||||
let currentColumnIndex = originalColumnIDs.indexOf(data.columnsData[columnIndex].columnID);
|
||||
if (currentColumnIndex !== -1 && columnIndex !== currentColumnIndex) {
|
||||
for (var i = currentColumnIndex; i > columnIndex; i--) {
|
||||
swapColumns(i-1, i);
|
||||
var swappedContent = originalColumnIDs[i-1];
|
||||
originalColumnIDs[i-1] = originalColumnIDs[i];
|
||||
originalColumnIDs[i] = swappedContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'saveColumnsConfigSetting', columnsData: "" }));
|
||||
}
|
||||
}
|
||||
isColumnsSettingLoaded = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1668,6 +1718,8 @@ function loaded() {
|
|||
refreshEntities();
|
||||
|
||||
window.addEventListener("resize", updateColumnWidths);
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'loadColumnsConfigSetting' }));
|
||||
});
|
||||
|
||||
augmentSpinButtons();
|
||||
|
|
Loading…
Reference in a new issue