Skip to content

Commit

Permalink
Fix geosolutions-it#9147 Issue in chart creation from feature grid.
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed Jun 9, 2023
1 parent d839823 commit f18a73e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
14 changes: 12 additions & 2 deletions web/client/epics/__tests__/widgetsbuilder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,24 @@ describe('widgetsbuilder epic', () => {
});
it('initEditorOnNewChart', (done) => {
const startActions = [createChart()];
testEpic(initEditorOnNewChart, 2, startActions, actions => {
expect(actions.length).toBe(2);
const NUMBER_OF_ACTIONS = 3;
testEpic(initEditorOnNewChart, NUMBER_OF_ACTIONS, startActions, actions => {
expect(actions.length).toBe(NUMBER_OF_ACTIONS);
actions.map((action) => {
switch (action.type) {
case EDIT_NEW:
expect(action.widget).toExist();
// verify default mapSync
expect(action.widget.mapSync).toBe(true);
expect(action.widget.widgetType).toBe('chart');
expect(action.widget.charts.length).toBe(1);
expect(action.widget.charts[0].chartId).toBe(action.widget.selectedChartId);
expect(action.widget.charts[0].type).toBe('bar');
expect(action.widget.charts[0].name).toBe('Chart-1');
break;
case EDITOR_CHANGE:
expect(action.key).toBe('returnToFeatureGrid');
expect(action.value).toBe(true);
break;
case CLOSE_FEATURE_GRID:
expect(action.type).toBe(CLOSE_FEATURE_GRID);
Expand Down
39 changes: 27 additions & 12 deletions web/client/epics/widgetsbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
import Rx from 'rxjs';

import uuid from 'uuid';
import {
NEW,
INSERT,
Expand Down Expand Up @@ -56,17 +56,32 @@ export const initEditorOnNew = (action$, {getState = () => {}} = {}) => action$.
}, {step: 0})));
export const initEditorOnNewChart = (action$, {getState = () => {}} = {}) => action$.ofType(NEW_CHART)
.filter(() => widgetBuilderAvailable(getState()))
.switchMap((w) => Rx.Observable.of(closeFeatureGrid(), editNewWidget({
legend: false,
mapSync: true,
cartesian: true,
yAxis: true,
widgetType: "chart",
filter: wfsFilter(getState()),
...w,
// override action's type
type: undefined
}, {step: 0}), onEditorChange("returnToFeatureGrid", true)));
.switchMap(() => {
const chartId = uuid();
const state = getState();
const layer = getWidgetLayer(state);
return Rx.Observable.of(
closeFeatureGrid(),
editNewWidget({
mapSync: true,
selectedChartId: chartId,
widgetType: 'chart',
charts: [
{
name: 'Chart-1',
chartId,
type: 'bar',
legend: false,
cartesian: true,
yAxis: true,
layer,
filter: wfsFilter(state)
}
]
}, {step: 0}),
onEditorChange("returnToFeatureGrid", true)
);
});
/**
* Manages interaction with QueryPanel and widgetBuilder
*/
Expand Down

0 comments on commit f18a73e

Please sign in to comment.