From 6c56fe9b4250c16ecea4ac270375c867d15c97d1 Mon Sep 17 00:00:00 2001 From: Stefano Ricci Date: Fri, 29 Nov 2024 11:14:28 +0100 Subject: [PATCH] sort editor: keep only first variable in composite attributes --- .../ButtonBar/ButtonSort/SortEditor/SortEditor.js | 4 +--- .../ButtonSort/SortEditor/store/useSortEditor.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/webapp/components/DataQuery/ButtonBar/ButtonSort/SortEditor/SortEditor.js b/webapp/components/DataQuery/ButtonBar/ButtonSort/SortEditor/SortEditor.js index 3363aebcf0..ad48fdaed8 100644 --- a/webapp/components/DataQuery/ButtonBar/ButtonSort/SortEditor/SortEditor.js +++ b/webapp/components/DataQuery/ButtonBar/ButtonSort/SortEditor/SortEditor.js @@ -4,7 +4,6 @@ import PropTypes from 'prop-types' import { Button } from '@webapp/components/buttons' import PanelRight from '@webapp/components/PanelRight' -import { useI18n } from '@webapp/store/system' import { Sort, SortCriteria } from '@common/model/query' import { useSortEditor } from './store' @@ -13,11 +12,10 @@ import SortCriteriaEditor from './SortCriteriaEditor' const SortEditor = (props) => { const { onChange, onClose, query } = props - const i18n = useI18n() const { draft, sort, sortDraft, setSortDraft, variables, variablesAvailable } = useSortEditor({ query }) return ( - +
{sortDraft.map((sortCriteria, idx) => ( }) if (Objects.isEmpty(attributeDefUuids)) return variables - const variablesByUuid = ObjectUtils.toUuidIndexedObj(variables) + const variablesByUuid = variables.reduce((acc, variable) => { + const { uuid } = variable + if (!acc[uuid]) { + // keep only first variable + // variables for composite attributes have same UUID for different properties (e.g. taxon) + acc[uuid] = variable + } + return acc + }, {}) return attributeDefUuids.map((uuid) => variablesByUuid[uuid]).filter(Boolean) }