Skip to content

Commit b5f2068

Browse files
authored
fix(toolbarFieldCategory): sw-3443 reset filter, legend links (#1565)
* toolbarFieldGroupVariant, reset legend dispatch * graphReducer, action type, hard reset for legend * viewReducer, annotations
1 parent 95677a0 commit b5f2068

File tree

8 files changed

+33
-3
lines changed

8 files changed

+33
-3
lines changed

src/components/toolbar/__tests__/__snapshots__/toolbarFieldGroupVariant.test.js.snap

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ exports[`ToolbarFieldGroupVariant Component should handle updating through redux
3838
"type": "SET_PRODUCT_VARIANT_QUERY_RESET_ALL",
3939
"variant": "ipsum",
4040
},
41+
{
42+
"type": "SET_GRAPH_LEGEND_RESET",
43+
},
4144
{
4245
"productGroup": undefined,
4346
"type": "SET_PRODUCT_VARIANT",
@@ -56,6 +59,9 @@ exports[`ToolbarFieldGroupVariant Component should handle updating through redux
5659
"type": "SET_PRODUCT_VARIANT_QUERY_RESET_ALL",
5760
"variant": "dolor sit",
5861
},
62+
{
63+
"type": "SET_GRAPH_LEGEND_RESET",
64+
},
5965
{
6066
"productGroup": "loremIpsum",
6167
"type": "SET_PRODUCT_VARIANT",

src/components/toolbar/toolbarFieldGroupVariant.js

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ const useOnSelect = ({
6060
type: reduxTypes.app.SET_PRODUCT_VARIANT_QUERY_RESET_ALL,
6161
variant: value
6262
},
63+
{
64+
type: reduxTypes.graph.SET_GRAPH_LEGEND_RESET
65+
},
6366
{
6467
type: reduxTypes.app.SET_PRODUCT_VARIANT,
6568
variant: value,

src/redux/reducers/__tests__/__snapshots__/graphReducer.test.js.snap

+11
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,14 @@ exports[`GraphReducer should handle specific defined types: defined type SET_GRA
126126
"type": "SET_GRAPH_LEGEND",
127127
}
128128
`;
129+
130+
exports[`GraphReducer should handle specific defined types: defined type SET_GRAPH_LEGEND_RESET 1`] = `
131+
{
132+
"result": {
133+
"capacity": {},
134+
"legend": {},
135+
"tally": {},
136+
},
137+
"type": "SET_GRAPH_LEGEND_RESET",
138+
}
139+
`;

src/redux/reducers/__tests__/graphReducer.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('GraphReducer', () => {
88
});
99

1010
it('should handle specific defined types', () => {
11-
const specificTypes = [graphTypes.SET_GRAPH_LEGEND];
11+
const specificTypes = [graphTypes.SET_GRAPH_LEGEND_RESET, graphTypes.SET_GRAPH_LEGEND];
1212

1313
specificTypes.forEach(value => {
1414
const dispatched = {

src/redux/reducers/graphReducer.js

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const initialState = {
3030
*/
3131
const graphReducer = (state = initialState, action) => {
3232
switch (action.type) {
33+
// Reset both category/type filtering and graph legend buttons/links
34+
case graphTypes.SET_GRAPH_LEGEND_RESET:
35+
return { ...state, legend: {} };
3336
case graphTypes.SET_GRAPH_LEGEND:
3437
return reduxHelpers.setStateProp(
3538
'legend',

src/redux/reducers/viewReducer.js

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const viewReducer = (state = initialState, action) => {
6363
reset: false
6464
}
6565
);
66+
// Reset inventory displays' paging offset, sort direction, sort
6667
case reduxTypes.query.SET_QUERY_RESET_INVENTORY_LIST:
6768
const updateResetQueries = (query = {}, id) => {
6869
const queryIds = productConfig.sortedConfigs().byViewIds[id] || (query[id] && [id]) || [];
@@ -94,6 +95,7 @@ const viewReducer = (state = initialState, action) => {
9495
reset: false
9596
}
9697
);
98+
// Reset inventory displays' paging offset
9799
case reduxTypes.query.SET_QUERY_CLEAR_INVENTORY_LIST:
98100
const updateClearQueries = (query = {}, id) => {
99101
const queryIds = productConfig.sortedConfigs().byViewIds[id] || (query[id] && [id]) || [];

src/redux/types/__tests__/__snapshots__/index.test.js.snap

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ exports[`ReduxTypes should have specific type properties: all redux types 1`] =
2525
},
2626
"graph": {
2727
"SET_GRAPH_LEGEND": "SET_GRAPH_LEGEND",
28+
"SET_GRAPH_LEGEND_RESET": "SET_GRAPH_LEGEND_RESET",
2829
},
2930
"inventory": {
3031
"CLEAR_INVENTORY_GUESTS": "CLEAR_INVENTORY_GUESTS",
@@ -70,6 +71,7 @@ exports[`ReduxTypes should have specific type properties: all redux types 1`] =
7071
},
7172
"graphTypes": {
7273
"SET_GRAPH_LEGEND": "SET_GRAPH_LEGEND",
74+
"SET_GRAPH_LEGEND_RESET": "SET_GRAPH_LEGEND_RESET",
7375
},
7476
"inventoryTypes": {
7577
"CLEAR_INVENTORY_GUESTS": "CLEAR_INVENTORY_GUESTS",
@@ -114,6 +116,7 @@ exports[`ReduxTypes should have specific type properties: all redux types 1`] =
114116
},
115117
"graph": {
116118
"SET_GRAPH_LEGEND": "SET_GRAPH_LEGEND",
119+
"SET_GRAPH_LEGEND_RESET": "SET_GRAPH_LEGEND_RESET",
117120
},
118121
"inventory": {
119122
"CLEAR_INVENTORY_GUESTS": "CLEAR_INVENTORY_GUESTS",
@@ -185,6 +188,7 @@ exports[`ReduxTypes should have specific type properties: specific types 1`] = `
185188
},
186189
"graph": {
187190
"SET_GRAPH_LEGEND": "SET_GRAPH_LEGEND",
191+
"SET_GRAPH_LEGEND_RESET": "SET_GRAPH_LEGEND_RESET",
188192
},
189193
"inventory": {
190194
"CLEAR_INVENTORY_GUESTS": "CLEAR_INVENTORY_GUESTS",

src/redux/types/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ const appTypes = {
3030
/**
3131
* Graph action, reducer types.
3232
*
33-
* @type {{SET_GRAPH_LEGEND: string}}
33+
* @type {{SET_GRAPH_LEGEND_RESET: string, SET_GRAPH_LEGEND: string}}
3434
*/
3535
const graphTypes = {
36-
SET_GRAPH_LEGEND: 'SET_GRAPH_LEGEND'
36+
SET_GRAPH_LEGEND: 'SET_GRAPH_LEGEND',
37+
SET_GRAPH_LEGEND_RESET: 'SET_GRAPH_LEGEND_RESET'
3738
};
3839

3940
/**

0 commit comments

Comments
 (0)