Skip to content

Commit

Permalink
Data explorer: keep order of selected dimensions in sort editor (#3641)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ricci <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent 25022f6 commit 55b481c
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import { useState } from 'react'

import { Objects } from '@openforis/arena-core'

import { Query, Sort } from '@common/model/query'
import * as ObjectUtils from '@core/objectUtils'
import * as Expression from '@core/expressionParser/expression'

import * as ExpressionVariables from '@webapp/components/expression/expressionVariables'

import { useLang } from '@webapp/store/system'
import { useNodeDefByUuid, useSurvey, useSurveyCycleKey } from '@webapp/store/survey'

const getVariables = ({ survey, cycle, entityDef, attributeDefUuids, lang }) =>
ExpressionVariables.getVariables({
const getVariables = ({ survey, cycle, entityDef, attributeDefUuids, lang }) => {
const variables = ExpressionVariables.getVariables({
survey,
cycle,
nodeDefContext: entityDef,
mode: Expression.modes.sql,
lang,
}).filter((variable) => attributeDefUuids.includes(variable.uuid))
})
if (Objects.isEmpty(attributeDefUuids)) return variables

const variablesByUuid = ObjectUtils.toUuidIndexedObj(variables)
return attributeDefUuids.map((uuid) => variablesByUuid[uuid]).filter(Boolean)
}

export const useSortEditor = ({ query }) => {
const sort = Query.getSort(query)
Expand Down

0 comments on commit 55b481c

Please sign in to comment.