From ff89e990687fdf6b54971106ec5c8536f472e796 Mon Sep 17 00:00:00 2001 From: Stefano Ricci Date: Thu, 14 Nov 2024 13:16:38 +0100 Subject: [PATCH] Data explorer: keep filter and sorting when changing mode from raw to raw edit --- common/model/query/query/query.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/common/model/query/query/query.js b/common/model/query/query/query.js index 9c54641897..a6874fb5f3 100644 --- a/common/model/query/query/query.js +++ b/common/model/query/query/query.js @@ -74,13 +74,15 @@ const resetNotApplicableProps = (query) => { return query } -export const assocMode = (mode) => - A.pipe( - A.assoc(keys.mode, mode), - assocFilter(defaults[keys.filter]), - assocSort(defaults[keys.sort]), - resetNotApplicableProps - ) +export const assocMode = (mode) => (query) => { + const prevMode = getMode(query) + let queryUpdated = A.pipe(A.assoc(keys.mode, mode), resetNotApplicableProps)(query) + if (prevMode == modes.aggregate || mode === modes.aggregate) { + // changing mode from raw to aggregate or vice versa: reset filter and sort + queryUpdated = A.pipe(assocFilter(defaults[keys.filter]), assocSort(defaults[keys.sort]))(queryUpdated) + } + return queryUpdated +} export const toggleMeasureAggregateFunction = ({ nodeDefUuid, aggregateFn }) =>