-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MousePosition degrees template via plugin props #2625
Conversation
render() { | ||
|
||
const degreesTemplateComponent = ((degreesTemplateStr) => { | ||
switch( degreesTemplateStr ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this function outside render() and remove application of parameter
like so
getDegreesTemplateComponent = (degreesTemplateStr) => {
switch (degreesTemplateStr) {
case "MousePositionLabelDD" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDD');
case "MousePositionLabelDM" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDM');
case "MousePositionLabelDMS" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDMS');
case "MousePositionLabelDMSNW" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDMSNW');
default: return require('../components/mapcontrols/mouseposition/MousePositionLabelDMS');
}
};
inside render
let degreesTemplateComponent = this.getDegreesTemplateComponent(this.props.degreesTemplateStr);
return (
<MousePositionComponent toggle={<MousePositionButton/>} degreesTemplate={degreesTemplateComponent} {...this.props}/>
);
switch( degreesTemplateStr ) { | ||
case "MousePositionLabelDD" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDD'); | ||
case "MousePositionLabelDM" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDM'); | ||
case "MousePositionLabelDMS" : return require('../components/mapcontrols/mouseposition/MousePositionLabelDMS'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use 4 space indentation
class MousePosition extends React.Component { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add property degreesTemplateStr with a default (this will be the one that will be overwritten from localConfig
static propTypes = {
degreesTemplateStr: PropTypes.string
};
static defaultProps = {
degreesTemplateStr: "MousePositionLabelDMS"
};
also add :
const PropTypes = require('prop-types');
return ( | ||
<MousePositionComponent toggle={<MousePositionButton/>} {...this.props}/> | ||
<MousePositionComponent toggle={<MousePositionButton/>} degreesTemplate={degreesTemplateComponent} {...this.props}/> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a unit test if you move this function into a new file MousePositionUtils.js in the utils folder.
then you have to require the function only and use it.
if you need help on how this, do not hesitate to ask
Don't know why but travis reported your PR as abuse, so the build didn't start and you couldn't notice the eslint issue notified by Matteo. I tried to add you to collaborators, I hope it helps. Otherwise you may need to contact travis support, because you may be black-listed (or something else, how knows). |
I tried to trigger the build again by closing and opening the pull request but I had the same result. |
I quote the email from support:
So @riaanvddool you can commit again and you will see the result from travis build. |
Hi Riaan, I make your code a bit more generic here: #2648 Going to close this one. Thanks for the contribution |
@mbarto Thanks, I will try it out. |
Description
Allow MousePosition degrees template to be selected via MousePosition plugin props
Issues
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
What is the current behavior? (You can also link to an open issue here)
The default for MousePosition plugin is to display coordinates in DMS format but I need DM.
It is not possible to configure the degreeTemplate from configuration but you can create your own MousPosition Plugin and pass your own template or one from the available ones.
What is the new behavior?
The MousePosition degreesTemplate can now be specified in localConfig.json:
Does this PR introduce a breaking change? (check one with "x", remove the other)
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
Discussion: https://groups.google.com/forum/#!topic/mapstore-developers/buz2kpzo09I