Skip to content
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

Add callback props onModalLabelOk and onModalLabelCancel to DigitizeButton #888

Merged
merged 2 commits into from
Sep 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion src/Button/DigitizeButton/DigitizeButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,23 @@ class DigitizeButton extends React.Component {
*
* @type {Function} onToggle
*/
onToggle: PropTypes.func
onToggle: PropTypes.func,

/**
* Callback function that will be called
* when the ok-button of the modal was clicked
*
* @type {Function} onModalLabelOk
*/
onModalLabelOk: PropTypes.func,

/**
* Callback function that will be called
* when the cancel-button of the modal was clicked
*
* @type {Function} onModalLabelCancel
*/
onModalLabelCancel: PropTypes.func
};

/**
Expand Down Expand Up @@ -934,10 +950,21 @@ class DigitizeButton extends React.Component {
* Turns visibility of modal off and call `setTextOnFeature` method.
*/
onModalLabelOk = () => {
const {
textLabel
} = this.state;

const {
onModalLabelOk
} = this.props;

this.setState({
showLabelPrompt: false
}, () => {
this.setTextOnFeature(this._digitizeTextFeature);
if (onModalLabelOk) {
onModalLabelOk(this._digitizeTextFeature, textLabel);
}
});
}

Expand All @@ -947,6 +974,10 @@ class DigitizeButton extends React.Component {
* digitize layer.
*/
onModalLabelCancel = () => {
const {
onModalLabelCancel
} = this.props;

this.setState({
showLabelPrompt: false,
textLabel: ''
Expand All @@ -955,6 +986,9 @@ class DigitizeButton extends React.Component {
this._digitizeFeatures.remove(this._digitizeTextFeature);
this._digitizeTextFeature = null;
}
if (onModalLabelCancel) {
onModalLabelCancel();
}
});
}

Expand Down Expand Up @@ -1042,6 +1076,8 @@ class DigitizeButton extends React.Component {
modifyInteractionConfig,
translateInteractionConfig,
onToggle,
onModalLabelOk,
onModalLabelCancel,
...passThroughProps
} = this.props;

Expand Down