Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Nov 6, 2023
1 parent a99fab3 commit d6944a9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
15 changes: 9 additions & 6 deletions web/client/actions/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}

Expand Down Expand Up @@ -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
};
}

Expand Down
18 changes: 10 additions & 8 deletions web/client/epics/featuregrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,18 @@ 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)
.map(createInitialQuery)
);
return Rx.Observable.of(featureTypeSelected(url, name, fields))
.merge(
action$.ofType(FEATURE_TYPE_LOADED)
.filter(({typeName} = {}) => typeName === name)
.map(createInitialQuery)
);
};

// Create action to add filter to wms layer
Expand Down Expand Up @@ -356,8 +358,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
Expand Down
2 changes: 1 addition & 1 deletion web/client/epics/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions web/client/epics/widgetsbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -93,7 +93,7 @@ export const handleWidgetsFilterPanel = (action$, {getState = () => {}} = {}) =>
.switchMap(() =>
// open and setup query form
Rx.Observable.of(
// featureTypeSelected(...getFTSelectedArgs(getState())),
featureTypeSelected(...getFTSelectedArgs(getState()).concat(["widgets"])),
loadFilter(getEditingWidgetFilter(getState())),
setControlProperty("widgetBuilder", "enabled", false),
setControlProperty('queryPanel', "enabled", true)
Expand Down

0 comments on commit d6944a9

Please sign in to comment.