Skip to content

Commit

Permalink
geosolutions-it#8997: resolve review comments on PR
Browse files Browse the repository at this point in the history
Description:
- fix logic issue if enableMapFilterSync = true in config
- refactor code by avoid inline if
  • Loading branch information
mahmoudadel54 committed Dec 13, 2023
1 parent 25a4e56 commit b72fa8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
9 changes: 6 additions & 3 deletions web/client/epics/featuregrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,9 +1106,12 @@ export const deactivateSyncWmsFilterOnFeatureGridClose = (action$, store) =>
action$.ofType(CLOSE_FEATURE_GRID)
.switchMap(() => {
let state = store.getState();
let isQueryPanelCloserGrid = state.featuregrid?.closer === 'queryPanel';
if (isQueryPanelCloserGrid && isSyncWmsActive(state)) return Rx.Observable.of(removeFilterFromWMSLayer(store.getState())); // in case close grid by queryPanel, remove filter to dislay all feats on map
else if (isSyncWmsActive(state) && !isQueryPanelCloserGrid) return Rx.Observable.of(toggleSyncWms()); // if close feature grid by others---> reset wms sync
let isQueryPanelClosingFeatureGrid = state.featuregrid?.closer === 'queryPanel';
if (isQueryPanelClosingFeatureGrid && isSyncWmsActive(state)) { // in case close grid by queryPanel, remove filter to dislay all feats on map
return Rx.Observable.of(removeFilterFromWMSLayer(store.getState()));
} else if (isSyncWmsActive(state) && !isQueryPanelClosingFeatureGrid ) { // if close feature grid by others---> reset wms sync
return Rx.Observable.of(toggleSyncWms());
}
return Rx.Observable.empty();
});
export const activateSyncWmsFilterOnFeatureGridOpen = (action$, store) =>
Expand Down
23 changes: 9 additions & 14 deletions web/client/plugins/featuregrid/FeatureEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,29 +283,24 @@ const EditorPlugin = compose(
lifecycle({
componentDidMount() {
// only the passed properties will be picked
this.props.onMount(pick(this.props, ['showFilteredObject', 'showTimeSync', 'timeSync', 'customEditorsOptions', 'isSyncWmsActive']));
if (this.props.isSyncWmsActive) return;
if (this.props.enableMapFilterSync) {
this.props.setSyncTool(true);
} else {
this.props.setSyncTool(false);
this.props.onMount(pick(this.props, ['showFilteredObject', 'showTimeSync', 'timeSync', 'customEditorsOptions']));
if (!this.props.isSyncWmsActive) {
if (this.props.enableMapFilterSync) {
this.props.setSyncTool(true);
} else {
this.props.setSyncTool(false);
}
}
},
// TODO: fix this in contexts
// due to multiple renders of plugins in contexts (one with default props, then with context props)
// the options have to be updated when change.
componentDidUpdate(oldProps) {
const newOptions = pick(this.props, ['showFilteredObject', 'showTimeSync', 'timeSync', 'customEditorsOptions', 'isSyncWmsActive']);
const oldOptions = pick(oldProps, ['showFilteredObject', 'showTimeSync', 'timeSync', 'customEditorsOptions', 'isSyncWmsActive']);
const newOptions = pick(this.props, ['showFilteredObject', 'showTimeSync', 'timeSync', 'customEditorsOptions']);
const oldOptions = pick(oldProps, ['showFilteredObject', 'showTimeSync', 'timeSync', 'customEditorsOptions']);
if (!isEqual(newOptions, oldOptions) ) {
this.props.onMount(newOptions);
}
if (newOptions.isSyncWmsActive) return;
if (this.props.enableMapFilterSync) {
this.props.setSyncTool(true);
} else {
this.props.setSyncTool(false);
}
}
}),
connect(selector,
Expand Down

0 comments on commit b72fa8c

Please sign in to comment.