From 7d1de6df08861d31a8ab1a7a61edbdf76260235c Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Thu, 17 Feb 2022 15:59:59 +0100 Subject: [PATCH] feat: Show checkbox for standard error only if dimension has a related standard error dimension --- .../components/chart-options-selector.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/configurator/components/chart-options-selector.tsx b/app/configurator/components/chart-options-selector.tsx index 2e98721a1..c2ceae557 100644 --- a/app/configurator/components/chart-options-selector.tsx +++ b/app/configurator/components/chart-options-selector.tsx @@ -143,7 +143,8 @@ const ActiveFieldSwitch = ({ activeField ); - const component = [...metaData.dimensions].find( + const allDimensions = [...metaData.dimensions, ...metaData.measures]; + const component = allDimensions.find( (d) => d.iri === activeFieldComponentIri ); @@ -217,10 +218,19 @@ const EncodingOptionsPanel = ({ })); }, [dimensions, encoding.values, measures, otherFieldsIris]); + const hasStandardError = useMemo(() => { + return [...measures, ...dimensions].find((m) => + m.related?.some( + (r) => r.type === "StandardError" && r.iri === component?.iri + ) + ); + }, [dimensions, measures, component]); + const optionsByField = useMemo( () => keyBy(encoding.options, (enc) => enc.field), [encoding] ); + return (
)} - {optionsByField["showStandardError"] && ( + {optionsByField["showStandardError"] && hasStandardError && (