From 80ce1bea85a926abb27ff920af8b7e3e23264659 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 18 Oct 2022 10:23:41 +0200 Subject: [PATCH 01/28] refactor: Function name --- app/rdf/queries.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/rdf/queries.ts b/app/rdf/queries.ts index 1eef9fd73..34b976564 100644 --- a/app/rdf/queries.ts +++ b/app/rdf/queries.ts @@ -234,7 +234,7 @@ export const getCubeDimensionValues = async ( return []; } - return await getCubeDimensionValuesWithLabels({ + return await getCubeDimensionValuesWithMetadata({ dimension, cube, sparqlClient, @@ -246,7 +246,7 @@ export const getCubeDimensionValues = async ( export const dimensionIsVersioned = (dimension: CubeDimension) => dimension.out(ns.schema.version)?.value ? true : false; -const getCubeDimensionValuesWithLabels = async ({ +const getCubeDimensionValuesWithMetadata = async ({ dimension, cube, sparqlClient, From a349f387b369acbde1c3503f66bfe47ecb4d6d64 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 18 Oct 2022 11:16:41 +0200 Subject: [PATCH 02/28] feat: Add loading of identifiers for dimension values --- app/domain/data.ts | 1 + app/rdf/queries.ts | 55 +++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/app/domain/data.ts b/app/domain/data.ts index b174ad550..f70929a1c 100644 --- a/app/domain/data.ts +++ b/app/domain/data.ts @@ -24,6 +24,7 @@ export type DimensionValue = { label: string; position?: number; color?: string; + identifier?: string; }; export type Observation = Record; diff --git a/app/rdf/queries.ts b/app/rdf/queries.ts index 34b976564..ab774fa19 100644 --- a/app/rdf/queries.ts +++ b/app/rdf/queries.ts @@ -318,26 +318,40 @@ const getCubeDimensionValuesWithMetadata = async ({ if (namedNodes.length > 0) { const scaleType = getScaleType(dimension); - const [labels, positions, colors, unversioned] = await Promise.all([ - loadResourceLabels({ ids: namedNodes, locale, sparqlClient }), - scaleType === "Ordinal" - ? loadResourceLiterals({ - ids: namedNodes, - sparqlClient, - predicate: schema.position, - }) - : [], - scaleType === "Ordinal" - ? loadResourceLiterals({ - ids: namedNodes, - sparqlClient, - predicate: schema.color, - }) - : [], - dimensionIsVersioned(dimension) - ? loadUnversionedResources({ ids: namedNodes, sparqlClient }) - : [], - ]); + const [labels, positions, identifiers, colors, unversioned] = + await Promise.all([ + loadResourceLabels({ ids: namedNodes, locale, sparqlClient }), + scaleType === "Ordinal" + ? loadResourceLiterals({ + ids: namedNodes, + sparqlClient, + predicate: schema.position, + }) + : [], + scaleType === "Ordinal" || scaleType === "Nominal" + ? loadResourceLiterals({ + ids: namedNodes, + sparqlClient, + predicate: schema.identifier, + }) + : [], + scaleType === "Ordinal" + ? loadResourceLiterals({ + ids: namedNodes, + sparqlClient, + predicate: schema.color, + }) + : [], + dimensionIsVersioned(dimension) + ? loadUnversionedResources({ ids: namedNodes, sparqlClient }) + : [], + ]); + + const identifiersLookup = new Map( + identifiers.map(({ iri, value }) => [iri.value, value?.value]) + ); + + console.log({ identifiers }); const labelsLookup = new Map( labels.map(({ iri, label }) => [iri.value, label?.value]) @@ -362,6 +376,7 @@ const getCubeDimensionValuesWithMetadata = async ({ value: unversionedLookup.get(iri.value) ?? iri.value, label: labelsLookup.get(iri.value) ?? "", position: position !== undefined ? parseInt(position, 10) : undefined, + identifier: identifiersLookup.get(iri.value) ?? undefined, color: colorsLookup.get(iri.value) ?? undefined, }); }); From fbd42900b2284b8ca7172e823985d976e075fb91 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Wed, 19 Oct 2022 14:40:21 +0200 Subject: [PATCH 03/28] refactor: Use classes for ControlSectionContent --- .../components/chart-controls/section.tsx | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/app/configurator/components/chart-controls/section.tsx b/app/configurator/components/chart-controls/section.tsx index 8f2b26d1d..a2933b6c8 100644 --- a/app/configurator/components/chart-controls/section.tsx +++ b/app/configurator/components/chart-controls/section.tsx @@ -13,7 +13,7 @@ import { ElementType, forwardRef, HTMLProps, ReactNode } from "react"; import { Icon, IconName } from "@/icons"; import { useTheme } from "@/themes"; -const useStyles = makeStyles((theme: Theme) => ({ +const useControlSectionStyles = makeStyles((theme) => ({ controlSection: { borderTopColor: theme.palette.grey[500], borderTopWidth: "1px", @@ -35,12 +35,12 @@ export const ControlSection = forwardRef< sx?: BoxProps["sx"]; } & Omit, "ref"> >(({ role, children, isHighlighted, sx, ...props }, ref) => { - const classes = useStyles(); + const classes = useControlSectionStyles(); return ( { +} & BoxProps; + +const useControlSectionContentStyles = makeStyles< + Theme, + Pick +>((theme) => ({ + controlSectionContent: { + display: "flex", + flexDirection: "column", + gap: ({ gap }) => + theme.spacing(gap === "large" ? 3 : gap === "default" ? 2 : 0), + padding: ({ px }) => + `0 ${theme.spacing(px === "small" ? 2 : 4)} ${theme.spacing(4)}`, + }, +})); + +export const ControlSectionContent = ({ + component, + role, + ariaLabelledBy, + children, + gap = "default", + px, + sx, + ...props +}: ControlSectionContentProps) => { + const classes = useControlSectionContentStyles({ gap, px }); return ( {children} From a704a306b32d385dd97e7076e2eb225f85beb5f8 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Wed, 19 Oct 2022 14:40:40 +0200 Subject: [PATCH 04/28] fix: Increase gap between sort type select and sort order radio --- app/configurator/components/chart-options-selector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/configurator/components/chart-options-selector.tsx b/app/configurator/components/chart-options-selector.tsx index eafacacd2..19eb75def 100644 --- a/app/configurator/components/chart-options-selector.tsx +++ b/app/configurator/components/chart-options-selector.tsx @@ -549,7 +549,7 @@ const ChartFieldSorting = ({ Sort - +