Skip to content

Commit 892a230

Browse files
authored
Merge pull request #1453 from visualize-admin/feat/shared-dims-search
Shared termset search
2 parents 84893c3 + e289c1e commit 892a230

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4722
-664
lines changed

app/browser/dataset-browse.tsx

+56-14
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import SvgIcCategories from "@/icons/components/IcCategories";
4848
import SvgIcClose from "@/icons/components/IcClose";
4949
import SvgIcOrganisations from "@/icons/components/IcOrganisations";
5050
import isAttrEqual from "@/utils/is-attr-equal";
51+
import { MaybeTooltip } from "@/utils/maybe-tooltip";
5152
import useEvent from "@/utils/use-event";
5253

5354
import {
@@ -67,7 +68,7 @@ export const SearchDatasetInput = ({
6768

6869
const searchLabel = t({
6970
id: "dataset.search.label",
70-
message: "Search datasets",
71+
message: "Search",
7172
});
7273

7374
const placeholderLabel = t({
@@ -835,7 +836,7 @@ export type PartialSearchCube = Pick<
835836
| "datePublished"
836837
| "themes"
837838
| "creator"
838-
| "termsets"
839+
| "dimensions"
839840
>;
840841
type ResultProps = {
841842
dataCube: PartialSearchCube;
@@ -844,7 +845,7 @@ type ResultProps = {
844845
showTags?: boolean;
845846
rowActions?: (r: PartialSearchCube) => React.ReactNode;
846847
disableTitleLink?: boolean;
847-
showTermsets?: boolean;
848+
showDimensions?: boolean;
848849
};
849850

850851
export const DatasetResult = ({
@@ -854,7 +855,7 @@ export const DatasetResult = ({
854855
showTags,
855856
rowActions,
856857
disableTitleLink,
857-
showTermsets,
858+
showDimensions,
858859
...cardProps
859860
}: ResultProps & CardProps) => {
860861
const {
@@ -865,7 +866,7 @@ export const DatasetResult = ({
865866
themes,
866867
datePublished,
867868
creator,
868-
termsets,
869+
dimensions,
869870
} = dataCube;
870871
const isDraft = publicationStatus === DataCubePublicationStatus.Draft;
871872
const router = useRouter();
@@ -977,14 +978,7 @@ export const DatasetResult = ({
977978
)
978979
)
979980
: null}
980-
{showTermsets &&
981-
sortBy(termsets, (t) => t.label).map((termset) => {
982-
return (
983-
<Tag key={termset.iri} type="termset">
984-
{termset.label}
985-
</Tag>
986-
);
987-
})}
981+
988982
{creator?.label ? (
989983
<Link
990984
key={creator.iri}
@@ -1003,7 +997,55 @@ export const DatasetResult = ({
1003997
</Link>
1004998
) : null}
1005999
</Flex>
1006-
{rowActions?.(dataCube)}
1000+
<Flex alignItems="center" width="100%">
1001+
<Box flexGrow={1}>
1002+
{showDimensions && (
1003+
<Flex alignItems="center" mt={1} flexWrap="wrap" gap="0.25rem">
1004+
<Typography variant="body2" sx={{ mr: 1 }}>
1005+
<Trans id="dataset-result.shared-dimensions">
1006+
Shared dimensions:
1007+
</Trans>
1008+
</Typography>
1009+
{sortBy(dimensions, (t) => t.label).map((dimension) => {
1010+
return (
1011+
<MaybeTooltip
1012+
key={dimension.iri}
1013+
title={
1014+
dimension.termsets.length > 0 ? (
1015+
<>
1016+
<Typography variant="body2">
1017+
<Trans id="dataset-result.dimension-termset-contains">
1018+
Contains values from
1019+
</Trans>
1020+
<Stack gap={1} flexDirection="row" mt={1}>
1021+
{dimension.termsets.map((termset) => {
1022+
return (
1023+
<Tag
1024+
key={termset.iri}
1025+
type="termset"
1026+
sx={{ flexShrink: 0 }}
1027+
>
1028+
{termset.label}
1029+
</Tag>
1030+
);
1031+
})}
1032+
</Stack>
1033+
</Typography>
1034+
</>
1035+
) : undefined
1036+
}
1037+
>
1038+
<Tag sx={{ cursor: "default" }} type="dimension">
1039+
{dimension.label}
1040+
</Tag>
1041+
</MaybeTooltip>
1042+
);
1043+
})}
1044+
</Flex>
1045+
)}
1046+
</Box>
1047+
<Box flexShrink={1}>{rowActions?.(dataCube)}</Box>
1048+
</Flex>
10071049
</MotionCard>
10081050
);
10091051
};

app/charts/shared/legend-color.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,15 @@ export const LegendItem = (props: LegendItemProps) => {
374374

375375
return interactive && onToggle ? (
376376
<MaybeTooltip
377-
text={
378-
disabled
379-
? t({
377+
title={
378+
disabled ? (
379+
<Typography variant="body2">
380+
{t({
380381
id: "controls.filters.interactive.color.min-1-filter",
381382
message: "At least one filter must be selected.",
382-
})
383-
: undefined
383+
})}
384+
</Typography>
385+
) : undefined
384386
}
385387
>
386388
<div>

app/components/data-download.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
useContext,
2727
useState,
2828
} from "react";
29+
import { useClient } from "urql";
2930

3031
import { getSortedColumns } from "@/browse/datatable";
3132
import Flex from "@/components/flex";
@@ -321,6 +322,7 @@ const DownloadMenuItem = ({
321322
}) => {
322323
const locale = useLocale();
323324
const i18n = useI18n();
325+
const client = useClient();
324326
const [state, dispatch] = useDataDownloadState();
325327
const download = useCallback(
326328
async (
@@ -392,13 +394,13 @@ const DownloadMenuItem = ({
392394

393395
try {
394396
const [componentsResult, observationsResult] = await Promise.all([
395-
executeDataCubesComponentsQuery({
397+
executeDataCubesComponentsQuery(client, {
396398
sourceType: dataSource.type,
397399
sourceUrl: dataSource.url,
398400
locale,
399401
cubeFilters: filters,
400402
}),
401-
executeDataCubesObservationsQuery({
403+
executeDataCubesObservationsQuery(client, {
402404
sourceType: dataSource.type,
403405
sourceUrl: dataSource.url,
404406
locale,

app/components/form.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ export const Radio = ({
9898
: "grey.500";
9999

100100
return (
101-
<MaybeTooltip text={warnMessage}>
101+
<MaybeTooltip
102+
title={
103+
warnMessage ? (
104+
<Typography variant="body2">{warnMessage}</Typography>
105+
) : undefined
106+
}
107+
>
102108
<FormControlLabel
103109
label={label || "-"}
104110
htmlFor={`${name}-${value}`}

0 commit comments

Comments
 (0)