-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2668 Increase precision of Query Panel Circle/BBox Details
- Loading branch information
1 parent
1fc70ff
commit 82d6308
Showing
12 changed files
with
130 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
web/client/components/misc/enhancers/__tests__/debounce-test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2018, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
const {createSink, compose} = require('recompose'); | ||
const expect = require('expect'); | ||
const debounce = require('../debounce'); | ||
|
||
describe('debounce enhancer', () => { | ||
beforeEach((done) => { | ||
document.body.innerHTML = '<div id="container"></div>'; | ||
setTimeout(done); | ||
}); | ||
afterEach((done) => { | ||
ReactDOM.unmountComponentAtNode(document.getElementById("container")); | ||
document.body.innerHTML = ''; | ||
setTimeout(done); | ||
}); | ||
it('debounce call only last action', (done) => { | ||
const action = (status, method, owner, features) => { | ||
expect(status).toExist(); | ||
expect(status).toBe("replace"); | ||
expect(method).toNotExist(); | ||
expect(owner).toExist(); | ||
expect(owner).toBe("queryform"); | ||
expect(features).toExist(); | ||
expect(features).toBe("geom2"); | ||
done(); | ||
}; | ||
const Sink = compose(debounce("onChangeDrawingStatus", 800))(createSink( props => { | ||
expect(props).toExist(); | ||
expect(props.onChangeDrawingStatus).toExist(); | ||
props.onChangeDrawingStatus("geom"); | ||
props.onChangeDrawingStatus("geom1"); | ||
props.onChangeDrawingStatus("replace", undefined, "queryform", "geom2"); | ||
})); | ||
ReactDOM.render((<Sink onChangeDrawingStatus={action} | ||
/>), document.getElementById("container")); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright 2018, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const {withHandlers} = require('recompose'); | ||
const {debounce} = require("lodash"); | ||
const emptyFunc = () => {}; | ||
/** | ||
* This enhancer de-bounce a method passed as prop of the given time. | ||
* The action should be present in the props passed to the component | ||
* @memberof components.misc.enhancers | ||
* @function | ||
* @name debounce | ||
* @example | ||
* // example: every props change increment the *count* prop | ||
* compose(debounce("onChangeDrawingStatus", 800)); | ||
* the onChangeDrawingStatus action is debounced by 800 ms | ||
*/ | ||
module.exports = (action = "", debounceTime = 1000) => withHandlers((initProp = {}) => { | ||
const debounced = debounce(initProp[action] || emptyFunc, debounceTime); | ||
return { | ||
[action]: () => debounced | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters