Skip to content

Commit

Permalink
Only show years with found events
Browse files Browse the repository at this point in the history
  • Loading branch information
Kadrian committed May 28, 2024
1 parent c0eb3ab commit ef1dae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions frontend/src/js/entity-history/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ const groupByQuarter = (
}

// Filter concepts by searchTerm
const filteredSortedEvents = sortedEvents.map(
({ year, quarterwiseData }) => ({
const filteredSortedEvents = sortedEvents
.map(({ year, quarterwiseData }) => ({
year,
quarterwiseData: !searchTerm
? quarterwiseData
Expand Down Expand Up @@ -367,8 +367,12 @@ const groupByQuarter = (
});
}),
})),
}),
);
}))
.filter((year) =>
!searchTerm
? year
: year.quarterwiseData.some(({ events }) => events.length > 0),
);

console.log(filteredSortedEvents);

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/js/entity-history/timeline/Year.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const Year = ({
sourceColumn: ColumnDescription;
timeStratifiedInfos: TimeStratifiedInfo[];
}) => {
const { searchVisible } = useTimelineSearch();
const { searchTerm } = useTimelineSearch();

const isYearOpen = searchVisible || getIsOpen(year);
const isYearOpen = !!searchTerm || getIsOpen(year);
const totalEvents = quarterwiseData.reduce(
(all, data) =>
all + data.groupedEvents.reduce((s, evts) => s + evts.length, 0),
Expand All @@ -76,7 +76,7 @@ const Year = ({
(s, evts) => s + evts.length,
0,
);
const isQuarterOpen = searchVisible || getIsOpen(year, quarter);
const isQuarterOpen = !!searchTerm || getIsOpen(year, quarter);

return (
<Quarter
Expand Down

0 comments on commit ef1dae0

Please sign in to comment.