Skip to content

Commit

Permalink
Fixes geosolutions-it#1866: queryform example updated with epics and …
Browse files Browse the repository at this point in the history
…other related fixes
  • Loading branch information
mbarto committed May 23, 2017
1 parent 7343a59 commit 8dd8a29
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web/client/components/data/query/QueryToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const QueryToolbar = React.createClass({
// fieldsWithoutValues ||
fieldsExceptions ||
!this.props.toolbarEnabled ||
(!fieldsWithValues && !this.props.spatialField.geometry);
(!fieldsWithValues && !this.props.spatialField.geometry && this.props.spatialField.method !== 'Viewport');
const tooltip = <Tooltip id="query-warning-tooltip"><I18N.Message msgId="queryform.emptyfilter"/></Tooltip>;
const btn = (<Button disabled={queryDisabled} bsSize="xs" id="query-toolbar-query" onClick={this.search}>
<Glyphicon glyph="glyphicon glyphicon-search"/>
Expand Down
4 changes: 2 additions & 2 deletions web/client/epics/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ const viewportSelectedEpic = (action$, store) =>
action$.ofType(SELECT_VIEWPORT_SPATIAL_METHOD, CHANGE_MAP_VIEW)
.switchMap((action) => {
// calculate new geometry from map properties only for viewport
const map = action.type === CHANGE_MAP_VIEW ? action : store.getState().map.present;
const map = action.type === CHANGE_MAP_VIEW ? action : store.getState().map.present || store.getState().map;
if (action.type === SELECT_VIEWPORT_SPATIAL_METHOD ||
action.type === CHANGE_MAP_VIEW &&
store.getState().queryform &&
store.getState().queryform.spatialField &&
store.getState().queryform.spatialField.method === "viewport") {
store.getState().queryform.spatialField.method === "Viewport") {
const bounds = Object.keys(map.bbox.bounds).reduce((p, c) => {
return assign({}, p, {[c]: parseFloat(map.bbox.bounds[c])});
}, {});
Expand Down
2 changes: 2 additions & 0 deletions web/client/examples/queryform/components/SmartQueryForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {
removeGroupField,
changeCascadingValue,
expandAttributeFilterPanel,
selectViewportSpatialMethod,
expandSpatialFilterPanel,
selectSpatialMethod,
selectSpatialOperation,
Expand Down Expand Up @@ -94,6 +95,7 @@ const SmartQueryForm = connect((state) => {
onSelectSpatialMethod: selectSpatialMethod,
onSelectSpatialOperation: selectSpatialOperation,
onChangeDrawingStatus: changeDrawingStatus,
onSelectViewportSpatialMethod: selectViewportSpatialMethod,
onRemoveSpatialSelection: removeSpatialSelection,
onShowSpatialSelectionDetails: showSpatialSelectionDetails,
onEndDrawing: endDrawing,
Expand Down
7 changes: 6 additions & 1 deletion web/client/examples/queryform/stores/queryformstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
var DebugUtils = require('../../../utils/DebugUtils');

const {combineReducers} = require('redux');
const {createEpicMiddleware, combineEpics} = require('redux-observable');
const {viewportSelectedEpic} = require('../../../epics/wfsquery');

// STATE_FIPS SUB_REGION STATE_ABBR LAND_KM WATER_KM PERSONS FAMILIES HOUSHOLD MALE FEMALE WORKERS DRVALONE CARPOOL PUBTRANS EMPLOYED UNEMPLOY SERVICE MANUAL P_MALE P_FEMALE SAMP_POP

Expand Down Expand Up @@ -69,5 +71,8 @@ const reducers = combineReducers({
query: require('../reducers/query')
});

const rootEpic = combineEpics(viewportSelectedEpic);
const epicMiddleware = createEpicMiddleware(rootEpic);

// export the store with the given reducers
module.exports = DebugUtils.createDebugStore(reducers, {queryform: initialState});
module.exports = DebugUtils.createDebugStore(reducers, {queryform: initialState}, [epicMiddleware]);

0 comments on commit 8dd8a29

Please sign in to comment.