Skip to content

Commit

Permalink
Move default column array to the column definitions file
Browse files Browse the repository at this point in the history
Resolve a lack of persistence of column slider filters by moving the
default column array to the general column definitions file instead
of in ListViewTable.

If the persistence issues return, try just hardcoding `DEFAULT_COLUMNS`
instead of building it using `initialCol`.

Closes #144
  • Loading branch information
brianlove committed Oct 30, 2023
1 parent a6d8b4a commit d0df51d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 1 addition & 5 deletions web/gui-v2/src/components/ListViewTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import HeaderDropdown from './HeaderDropdown';
import HeaderSlider from './HeaderSlider';
import GroupSelector, { NO_SELECTED_GROUP, USER_CUSTOM_GROUP } from './ListViewGroupSelector';
import groupsList from '../static_data/groups';
import columnDefinitions from '../static_data/table_columns';
import columnDefinitions, { DEFAULT_COLUMNS } from '../static_data/table_columns';
import {
commas,
useMultiState,
Expand Down Expand Up @@ -114,15 +114,11 @@ const DATAKEYS_WITH_SUBKEYS = [
"other_metrics",
];

const DEFAULT_COLUMNS = [];
const DROPDOWN_COLUMNS = [];
const SLIDER_COLUMNS = [];
const SLIDER_NATURAL_COLUMNS = [];
const SLIDER_GROWTH_COLUMNS = [];
columnDefinitions.forEach((colDef) => {
if ( colDef?.initialCol ) {
DEFAULT_COLUMNS.push(colDef.key);
}
if ( colDef.type === "dropdown" ) {
DROPDOWN_COLUMNS.push(colDef.key);
} else if ( colDef.type === "slider" ) {
Expand Down
8 changes: 8 additions & 0 deletions web/gui-v2/src/static_data/table_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ const columnDefinitions = [
];
export default columnDefinitions;

// Filtering down to the default columns in `ListViewTable.jsx` was causing
// filters to not persist across page refreshes. Doing that filtering here
// seems to be fine, but if there are subsequent issues try hardcoding the
// array instead. (see https://github.com/georgetown-cset/parat/issues/144)
export const DEFAULT_COLUMNS = columnDefinitions
.filter(e => e?.initialCol)
.map(e => e.key);

export const articleMap = Object.fromEntries(columnDefinitions
.filter(e => e.dataKey === 'articles')
.map(e => ([e.dataSubkey, e.title]))
Expand Down

0 comments on commit d0df51d

Please sign in to comment.