From 48b13581851ede5f781209dd25ae72f11be892c4 Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:47:59 +0100 Subject: [PATCH] Data explorer: keep filter and sorting when changing mode from raw to raw edit (#3658) Co-authored-by: Stefano Ricci Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- 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 }) =>