From 3f1d471398f927a9b45f1edd0f58a975bac70fe8 Mon Sep 17 00:00:00 2001 From: mahmoudadel54 Date: Mon, 6 Nov 2023 21:56:59 +0200 Subject: [PATCH] #9216: resolve the PR reviews --- web/client/actions/wfsquery.js | 15 +++++++++------ web/client/epics/featuregrid.js | 8 ++++---- web/client/epics/wfsquery.js | 2 +- web/client/epics/widgetsbuilder.js | 16 ++++++++-------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/web/client/actions/wfsquery.js b/web/client/actions/wfsquery.js index e6ec54372f..14b41ae5a7 100644 --- a/web/client/actions/wfsquery.js +++ b/web/client/actions/wfsquery.js @@ -46,19 +46,21 @@ export function initQueryPanel() { type: INIT_QUERY_PANEL }; } -export function featureTypeSelected(url, typeName, fields = []) { +export function featureTypeSelected(url, typeName, fields = [], owner) { return { type: FEATURE_TYPE_SELECTED, url, typeName, - fields + fields, + owner }; } -export function featureTypeLoaded(typeName, featureType) { +export function featureTypeLoaded(typeName, featureType, owner) { return { type: FEATURE_TYPE_LOADED, typeName, - featureType + featureType, + owner }; } @@ -142,11 +144,12 @@ export function loadFeature(baseUrl, typeName) { }); }; } -export function createQuery(searchUrl, filterObj) { +export function createQuery(searchUrl, filterObj, owner) { return { type: QUERY_CREATE, searchUrl, - filterObj + filterObj, + owner }; } diff --git a/web/client/epics/featuregrid.js b/web/client/epics/featuregrid.js index 302d3305ba..6982b28a26 100644 --- a/web/client/epics/featuregrid.js +++ b/web/client/epics/featuregrid.js @@ -273,11 +273,11 @@ const createLoadPageFlow = (store) => ({page, size, reason} = {}) => { const createInitialQueryFlow = (action$, store, {url, name, id, fields} = {}) => { const filterObj = get(store.getState(), `featuregrid.advancedFilters["${id}"]`); - const createInitialQuery = () => createQuery(url, filterObj || { + const createInitialQuery = (action) => createQuery(url, filterObj || { featureTypeName: name, filterType: 'OGC', ogcVersion: '1.1.0' - }); + }, action.owner); return Rx.Observable.of(featureTypeSelected(url, name, fields)).merge( action$.ofType(FEATURE_TYPE_LOADED).filter(({typeName} = {}) => typeName === name) @@ -356,8 +356,8 @@ export const featureGridLayerSelectionInitialization = (action$) => */ export const featureGridStartupQuery = (action$, store) => action$.ofType(QUERY_CREATE) - .switchMap(() => Rx.Observable.of(changePage(0)) - .concat(modeSelector(store.getState()) === MODES.VIEW ? Rx.Observable.of(toggleViewMode()) : Rx.Observable.empty())); + .switchMap(({ owner }) => Rx.Observable.of(changePage(0)) + .concat(modeSelector(store.getState()) === MODES.VIEW && owner !== "widgets" ? Rx.Observable.of(toggleViewMode()) : Rx.Observable.empty())); /** * Create sorted queries on sort action * With virtualScroll active reset to page 0 but the grid will reload diff --git a/web/client/epics/wfsquery.js b/web/client/epics/wfsquery.js index c08bf8bd54..e9c3b50dbd 100644 --- a/web/client/epics/wfsquery.js +++ b/web/client/epics/wfsquery.js @@ -102,7 +102,7 @@ export const featureTypeSelectedEpic = (action$, store) => const info = extractInfo(layerDescribeSelector(state, action.typeName), action.fields); const geometry = info.geometry[0] && info.geometry[0].attribute ? info.geometry[0].attribute : 'the_geom'; - return Rx.Observable.of(featureTypeLoaded(action.typeName, info), changeSpatialAttribute(geometry), Rx.Scheduler.async); // async scheduler is needed to allow invokers of `FEATURE_TYPE_SELECTED` to intercept `FEATURE_TYPE_LOADED` action as response. + return Rx.Observable.of(featureTypeLoaded(action.typeName, info, action.owner), changeSpatialAttribute(geometry), Rx.Scheduler.async); // async scheduler is needed to allow invokers of `FEATURE_TYPE_SELECTED` to intercept `FEATURE_TYPE_LOADED` action as response. } const selectedLayer = selectedLayerSelector(state); diff --git a/web/client/epics/widgetsbuilder.js b/web/client/epics/widgetsbuilder.js index b1f54b670d..e917bc0e67 100644 --- a/web/client/epics/widgetsbuilder.js +++ b/web/client/epics/widgetsbuilder.js @@ -23,17 +23,17 @@ import { QUERY_FORM_SEARCH, loadFilter } from '../actions/queryform'; import { setControlProperty, TOGGLE_CONTROL } from '../actions/controls'; import { ADD_LAYER } from '../actions/layers'; import { LOCATION_CHANGE } from 'connected-react-router'; -// import { featureTypeSelected } from '../actions/wfsquery'; +import { featureTypeSelected } from '../actions/wfsquery'; import { getWidgetLayer, getEditingWidgetFilter, getWidgetFilterKey } from '../selectors/widgets'; import { wfsFilter } from '../selectors/query'; import { widgetBuilderAvailable } from '../selectors/controls'; import { generateNewTrace } from '../utils/WidgetsUtils'; -// const getFTSelectedArgs = (state) => { -// let layer = getWidgetLayer(state); -// let url = layer.search && layer.search.url; -// let typeName = layer.name; -// return [url, typeName, layer.fields]; -// }; +const getFTSelectedArgs = (state) => { + let layer = getWidgetLayer(state); + let url = layer.search && layer.search.url; + let typeName = layer.name; + return [url, typeName, layer.fields]; +}; export const openWidgetEditor = (action$, {getState = () => {}} = {}) => action$.ofType(NEW, EDIT, NEW_CHART) .filter(() => widgetBuilderAvailable(getState())) @@ -93,7 +93,7 @@ export const handleWidgetsFilterPanel = (action$, {getState = () => {}} = {}) => .switchMap(() => // open and setup query form Rx.Observable.of( - // featureTypeSelected(...getFTSelectedArgs(getState())), + featureTypeSelected(...getFTSelectedArgs(getState())), loadFilter(getEditingWidgetFilter(getState())), setControlProperty("widgetBuilder", "enabled", false), setControlProperty('queryPanel', "enabled", true)