Skip to content

Commit

Permalink
Merge pull request #394 from georgetown-cset/329-format-group-in-acti…
Browse files Browse the repository at this point in the history
…ve-filters-tooltip

Show human-readable name for filtered groups
  • Loading branch information
jmelot authored Jun 3, 2024
2 parents 306b42a + 4bdbb42 commit df76332
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions web/gui-v2/src/components/ListViewTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -793,18 +793,36 @@ const ListViewTable = ({
<>
<label>Active filters:</label>
<ul css={styles.activeFiltersList}>
{activeFilters.map((filter) => {
{activeFilters.flatMap((filter) => {
const [key, values] = filter;
const title = columnKeyMap[key];
if ( DROPDOWN_COLUMNS.includes(key) ) {
return <li key={key}>{title}: <span>{values.join(", ")}</span></li>;
if ( key === 'name' ) {
const groups = []
const companies = [];
values.forEach((entry) => {
if ( entry.startsWith("GROUP:") ) {
groups.push(overallData.groups[entry.split(":")[1]].name);
} else {
companies.push(entry);
}
});
return [
groups.length > 0 && (
<li key="groups">Group: <span>{groups.join(", ")}</span></li>
),
companies.length > 0 && (
<li key="companies">{title}: <span>{companies.join(", ")}</span></li>
),
];
} else if ( DROPDOWN_COLUMNS.includes(key) ) {
return [<li key={key}>{title}: <span>{values.join(", ")}</span></li>];
} else {
const formatted = formatActiveSliderFilter(
values,
DEFAULT_FILTER_VALUES[key],
SLIDER_GROWTH_COLUMNS.includes(key)
);
return <li key={key}>{title}: <span>{formatted}</span></li>;
return [<li key={key}>{title}: <span>{formatted}</span></li>];
}
})}
</ul>
Expand Down

0 comments on commit df76332

Please sign in to comment.