Skip to content

Commit

Permalink
Improve history's default filter state and its empty search state
Browse files Browse the repository at this point in the history
  • Loading branch information
Kadrian committed Jun 24, 2024
1 parent 9789c12 commit 1d59016
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions frontend/src/js/entity-history/ContentControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ const ContentControl = ({ value, onChange }: Props) => {

export const useContentControl = () => {
const [contentFilter, setContentFilter] = useState<ContentFilterValue>({
groupId: false,
groupId: true,
secondaryId: true,
concept: true,
money: true,
rest: false,
rest: true,
dates: true,
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/entity-history/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Timeline = memo(
timeStratifiedInfos={currentEntityTimeStratifiedInfos}
/>
)}
{isEmpty && <SxTimelineEmptyPlaceholder />}
{isEmpty && <SxTimelineEmptyPlaceholder searchTerm={searchTerm} />}
{dateColumn &&
sourceColumn &&
eventsByQuarterWithGroups.map(({ year, quarterwiseData }, i) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import styled from "@emotion/styled";
import { faListUl } from "@fortawesome/free-solid-svg-icons";
import { faListUl, faMagnifyingGlass } from "@fortawesome/free-solid-svg-icons";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";

import { useMemo } from "react";
import { StateT } from "../../app/reducers";
import FaIcon from "../../icon/FaIcon";
import { EntityHistoryStateT } from "../reducer";
Expand Down Expand Up @@ -49,8 +50,10 @@ const Description = styled("p")`

export const TimelineEmptyPlaceholder = ({
className,
searchTerm,
}: {
className?: string;
searchTerm?: string;
}) => {
const { t } = useTranslation();

Expand All @@ -61,20 +64,28 @@ export const TimelineEmptyPlaceholder = ({
(state) => state.entityHistory.currentEntityId,
);

const message = useMemo(() => {
if (searchTerm) {
return t("history.emptyTimeline.descriptionWithSearchTerm", {
searchTerm,
});
}

if (ids.length === 0 || !id) {
return t("history.emptyTimeline.descriptionWithoutIds");
}

return t("history.emptyTimeline.descriptionWithId");
}, [ids, id, t, searchTerm]);

return (
<Root className={className}>
<Row>
<BigIcon icon={faListUl} />
<BigIcon icon={searchTerm ? faMagnifyingGlass : faListUl} />
<div>
<Headline>{t("history.emptyTimeline.headline")}</Headline>
<Description>{t("history.emptyTimeline.description")}</Description>
<Message>
{ids.length === 0
? t("history.emptyTimeline.descriptionWithoutIds")
: id
? t("history.emptyTimeline.descriptionWithId")
: t("history.emptyTimeline.descriptionWithoutId")}
</Message>
<Message dangerouslySetInnerHTML={{ __html: message }} />
</div>
</Row>
</Root>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@
"description": "Hier werden Informationen chronologisch dargestellt.",
"descriptionWithoutIds": "Importiere IDs in die leere Liste auf der linken Seite, um zu starten.",
"descriptionWithoutId": "Wähle eine ID aus der Liste auf der linken Seite.",
"descriptionWithId": "Für diese ID konnten keine Daten gefunden werden."
"descriptionWithId": "Für diese ID konnten keine Daten gefunden werden.",
"descriptionWithSearchTerm": "Für den Suchbegriff '<strong>{{ searchTerm }}</strong>' konnten keine Daten gefunden werden."
},
"backButtonWarning": "Achtung: Wenn Du zurück gehst, werden Änderungen an der Liste verworfen. Lade die Liste vorher herunter, um sie zu speichern.",
"history": "Historie",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@
"description": "Exploring individual events chronologically.",
"descriptionWithoutIds": "To get started, import IDs into the empty list on the left side.",
"descriptionWithoutId": "Select an ID from the list on the left side",
"descriptionWithId": "Couldn't find any data for this ID."
"descriptionWithId": "Couldn't find any data for this ID.",
"descriptionWithSearchTerm": "Couldn't find any data for the search term '<strong>{{ searchTerm }}</strong>'."
},
"backButtonWarning": "Note: changes will be discarded. Please download the list before going back.",
"history": "History",
Expand Down

0 comments on commit 1d59016

Please sign in to comment.