mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Fixed: Table column order resetting after refresh
#4297 (cherry picked from commit 044cb563a6488c16916ea7617d1f91404330b06f)
This commit is contained in:
parent
dd61480d60
commit
4bf726cc66
@ -28,27 +28,29 @@ function mergeColumns(path, initialState, persistedState, computedState) {
|
|||||||
|
|
||||||
const columns = [];
|
const columns = [];
|
||||||
|
|
||||||
initialColumns.forEach((initialColumn) => {
|
// Add persisted columns in the same order they're currently in
|
||||||
const persistedColumnIndex = _.findIndex(persistedColumns, { name: initialColumn.name });
|
// as long as they haven't been removed.
|
||||||
const column = Object.assign({}, initialColumn);
|
|
||||||
const persistedColumn = persistedColumnIndex > -1 ? persistedColumns[persistedColumnIndex] : undefined;
|
|
||||||
|
|
||||||
if (persistedColumn) {
|
persistedColumns.forEach((persistedColumn) => {
|
||||||
column.isVisible = persistedColumn.isVisible;
|
const columnIndex = initialColumns.findIndex((i) => i.name === persistedColumn.name);
|
||||||
|
|
||||||
|
if (columnIndex >= 0) {
|
||||||
|
columns.push({ ...persistedColumn });
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a persisted column, it's index doesn't exceed the column list
|
|
||||||
// and it's modifiable, insert it in the proper position.
|
|
||||||
|
|
||||||
if (persistedColumn && columns.length - 1 > persistedColumnIndex && persistedColumn.isModifiable !== false) {
|
|
||||||
columns.splice(persistedColumnIndex, 0, column);
|
|
||||||
} else {
|
|
||||||
columns.push(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the columns in the persisted state
|
|
||||||
_.set(computedState, path, columns);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add any columns added to the app in the initial position.
|
||||||
|
initialColumns.forEach((initialColumn, index) => {
|
||||||
|
const persistedColumnIndex = persistedColumns.findIndex((i) => i.name === initialColumn.name);
|
||||||
|
const column = Object.assign({}, initialColumn);
|
||||||
|
|
||||||
|
if (persistedColumnIndex === -1) {
|
||||||
|
columns.splice(index, 0, column);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set the columns in the persisted state
|
||||||
|
_.set(computedState, path, columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
function slicer(paths_) {
|
function slicer(paths_) {
|
||||||
|
Loading…
Reference in New Issue
Block a user