@zeniai/client-epic-state 5.2.39-betaRD0 → 5.2.39-betaRD1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,6 @@ export const initialFinanceStatementState = {
17
17
  displayOrder: 'ascending_date',
18
18
  reportFormat: 'more_detailed',
19
19
  lastFetchRequestTime: undefined,
20
- isPeriodSelectionExplicit: false,
21
20
  };
22
21
  const financeStatement = createSlice({
23
22
  name: 'financeStatement',
@@ -34,26 +33,23 @@ const financeStatement = createSlice({
34
33
  },
35
34
  },
36
35
  updateFinanceStatementTimeframe(draft, action) {
37
- // A month anchor is meaningless once the timeframe becomes quarter/year, so
38
- // a real timeframe change has to drop it. Callers also re-dispatch the
39
- // *current* timeframe as a side effect of unrelated UI (report format, view
40
- // switches); dropping the anchor there silently resets the user's period to
41
- // the latest one, so leave the selection alone when nothing changed.
36
+ // Unrelated UI re-dispatches the *current* timeframe as a side effect (the
37
+ // reports page hangs its table scroll reset off that callback); dropping the
38
+ // anchor there would silently reset the user's period to the latest one.
42
39
  if (draft.timeframe === action.payload) {
43
40
  return;
44
41
  }
45
42
  draft.timeframe = action.payload;
43
+ // A month anchor is meaningless once the timeframe becomes quarter/year, so
44
+ // a real change drops it and returns the width to the default — 12 months
45
+ // must not become 12 quarters. Order is the user's, so it survives.
46
46
  draft.selectedCOABalancesRange = {
47
- numberOfPeriods: draft.selectedCOABalancesRange.numberOfPeriods,
47
+ numberOfPeriods: initialFinanceStatementState.selectedCOABalancesRange.numberOfPeriods,
48
48
  orderBy: draft.selectedCOABalancesRange.orderBy,
49
49
  };
50
- draft.isPeriodSelectionExplicit = false;
51
50
  },
52
51
  updateCOABalancesRange(draft, action) {
53
52
  draft.selectedCOABalancesRange = Object.assign({}, action.payload);
54
- // A range without an anchor is a programmatic reset to the default, not a
55
- // user pick (e.g. leaving the horizontal by-class layout).
56
- draft.isPeriodSelectionExplicit = action.payload.thisPeriod != null;
57
53
  },
58
54
  updateFinanceStatementThisPeriod(draft, action) {
59
55
  const { firstMonthOfFY, coaBalances, maxNumOfPeriodsToHighlight } = action.payload;
@@ -68,7 +64,6 @@ const financeStatement = createSlice({
68
64
  };
69
65
  const newThisPeriod = getMatchingThisPeriod(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, safeCoaBalances);
70
66
  if (newThisPeriod != null) {
71
- draft.isPeriodSelectionExplicit = true;
72
67
  const selectionRanges = getSelectedAndHighlightedRangesForThisPeriod({
73
68
  firstMonthOfFY,
74
69
  thisPeriod: newThisPeriod,
@@ -91,8 +86,7 @@ const financeStatement = createSlice({
91
86
  draft.selectedReportId = action.payload;
92
87
  },
93
88
  updateFinanceStatementAdditionalBalancesSelection(draft, action) {
94
- const { firstMonthOfFY, additionalBalances: additionalBalancesPayload, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
95
- const safeCoaBalances = coaBalances != null ? coaBalances : [];
89
+ const { additionalBalances: additionalBalancesPayload, maxNumOfPeriodsToHighlight, } = action.payload;
96
90
  const additionalBalances = additionalBalancesPayload ?? [];
97
91
  let tempAdditionalBalances = [...additionalBalances];
98
92
  if (additionalBalances.includes('this_period_vs_last_period') ||
@@ -108,38 +102,12 @@ const financeStatement = createSlice({
108
102
  draft.maxNumOfPeriodsToHighlight = maxNumOfPeriodsToHighlight;
109
103
  draft.isAdditionalBalancesShown =
110
104
  additionalBalances.length != 0 ? true : false;
111
- const { timeframe, selectedCOABalancesRange } = draft;
112
- // The reports page fires this on load, on window resize and on every
113
- // fetch-state transition (so also on report switch and on remount after a
114
- // drill-down), carrying a viewport-derived period count. Re-deriving the
115
- // range from that count silently discards a range the user chose, so only
116
- // the column metadata above is applied once the selection is theirs.
117
- if (draft.isPeriodSelectionExplicit) {
118
- return;
119
- }
120
- if (safeCoaBalances.length > 0) {
121
- const thisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
122
- if (thisPeriod != null) {
123
- const selectedCoaBalancesRangeWithThisPeriod = {
124
- ...selectedCOABalancesRange,
125
- thisPeriod,
126
- };
127
- const selectionRanges = getSelectedAndHighlightedRangesForThisPeriod({
128
- firstMonthOfFY,
129
- thisPeriod: thisPeriod,
130
- coaBalances: safeCoaBalances,
131
- timeframe,
132
- maxNumOfPeriodsToHighlight: maxNumOfPeriodsToHighlight,
133
- currentSelection: {
134
- selectedCOABalancesRange: selectedCoaBalancesRangeWithThisPeriod,
135
- },
136
- orderBy: 'ascending_date',
137
- maxNumOfPeriodsToSelect: maxNumOfPeriodsToHighlight,
138
- });
139
- draft.selectedCOABalancesRange =
140
- selectionRanges.selectedCOABalancesRange;
141
- }
142
- }
105
+ // Column metadata only — must not touch selectedCOABalancesRange. The
106
+ // reports page fires this on load, on resize and on every fetch-state
107
+ // transition (so also on report switch and on remount after a drill-down)
108
+ // with a viewport-derived period count that knows nothing about the range
109
+ // the user picked. The width default comes from initial state, and from
110
+ // updateFinanceStatementTimeframe on a real timeframe change.
143
111
  },
144
112
  updateDownloadState(draft, action) {
145
113
  draft.downloadState = action.payload;