Skip to content

Commit

Permalink
improved fetcher stream and wfs transaction when object is passed as …
Browse files Browse the repository at this point in the history
…changed value
  • Loading branch information
MV88 committed Sep 28, 2017
1 parent 89335f6 commit b10c49f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion web/client/components/data/query/AutocompleteFieldHOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class AutocompleteFieldHOC extends React.Component {
this.props.onUpdateField(this.props.filterField.rowId, "value", input.value, "string", {currentPage: 1, selected: "selected", delayDebounce: 0});
}
} else {
this.props.onUpdateField(this.props.filterField.rowId, "value", input, "string", {currentPage: 1, delayDebounce: 1000});
this.props.onUpdateField(this.props.filterField.rowId, "value", typeof input === "string" ? input : input.value, "string", {currentPage: 1, delayDebounce: 1000});
}
};

Expand Down
7 changes: 4 additions & 3 deletions web/client/components/misc/AutocompleteCombobox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,22 @@ const addStateHandlers = compose(
if (state.selected && state.changingPage) {
return ({
...state,
delayDebounce: state.selected ? 0 : 1000,
delayDebounce: state.selected ? 0 : 500,
selected: false,
changingPage: false,
performFetch: state.selected && !state.changingPage ? false : true,
value: state.value,
currentPage: !state.changingPage ? 1 : state.currentPage
});
}
const value = typeof v === "string" ? v : v.value;
return ({
...state,
delayDebounce: state.selected ? 0 : 1000,
delayDebounce: state.selected ? 0 : 500,
selected: false,
changingPage: false,
performFetch: state.selected && !state.changingPage ? false : true,
value: state.selected ? v.value : v,
value: value,
currentPage: !state.changingPage ? 1 : state.currentPage
});
},
Expand Down
5 changes: 4 additions & 1 deletion web/client/observables/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ const {getWpsPayload} = require('../utils/ogc/WPS/autocomplete');
* @memberof observables.autocomplete
* @return {external:Observable} the stream used for fetching data for the autocomplete editor
*/
const createPagedUniqueAutompleteStream = (props$) => props$.debounce(props => Rx.Observable.timer(props.delayDebounce || 0))
const createPagedUniqueAutompleteStream = (props$) => props$
.distinctUntilChanged( ({value, currentPage}, newProps = {}) => !(newProps.value !== value || newProps.currentPage !== currentPage))
.throttle(props => Rx.Observable.timer(props.delayDebounce || 0))
.merge(props$.debounce(props => Rx.Observable.timer(props.delayDebounce || 0))).distinctUntilChanged()
.switchMap((p) => {
if (p.performFetch) {
const data = getWpsPayload({
Expand Down

0 comments on commit b10c49f

Please sign in to comment.