From 8bd445feb87303303deab3c7602b17d1adb6e9d8 Mon Sep 17 00:00:00 2001 From: jansule Date: Thu, 20 Sep 2018 08:41:12 +0200 Subject: [PATCH 1/2] add callback prop for onModalLabelOk --- src/Button/DigitizeButton/DigitizeButton.jsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Button/DigitizeButton/DigitizeButton.jsx b/src/Button/DigitizeButton/DigitizeButton.jsx index fbc978afdf..62a971d44e 100644 --- a/src/Button/DigitizeButton/DigitizeButton.jsx +++ b/src/Button/DigitizeButton/DigitizeButton.jsx @@ -401,7 +401,13 @@ 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 + */ + onModalLabelOk: PropTypes.func }; /** @@ -934,10 +940,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); + } }); } @@ -1042,6 +1059,7 @@ class DigitizeButton extends React.Component { modifyInteractionConfig, translateInteractionConfig, onToggle, + onModalLabelOk, ...passThroughProps } = this.props; From a3b432ef8f577161532977d2af57182c41984ca5 Mon Sep 17 00:00:00 2001 From: jansule Date: Thu, 20 Sep 2018 09:30:23 +0200 Subject: [PATCH 2/2] add callback prop for onModalLabelCancel --- src/Button/DigitizeButton/DigitizeButton.jsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Button/DigitizeButton/DigitizeButton.jsx b/src/Button/DigitizeButton/DigitizeButton.jsx index 62a971d44e..1a73c2a4fd 100644 --- a/src/Button/DigitizeButton/DigitizeButton.jsx +++ b/src/Button/DigitizeButton/DigitizeButton.jsx @@ -406,8 +406,18 @@ class DigitizeButton extends React.Component { /** * 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 */ - onModalLabelOk: PropTypes.func + onModalLabelCancel: PropTypes.func }; /** @@ -964,6 +974,10 @@ class DigitizeButton extends React.Component { * digitize layer. */ onModalLabelCancel = () => { + const { + onModalLabelCancel + } = this.props; + this.setState({ showLabelPrompt: false, textLabel: '' @@ -972,6 +986,9 @@ class DigitizeButton extends React.Component { this._digitizeFeatures.remove(this._digitizeTextFeature); this._digitizeTextFeature = null; } + if (onModalLabelCancel) { + onModalLabelCancel(); + } }); } @@ -1060,6 +1077,7 @@ class DigitizeButton extends React.Component { translateInteractionConfig, onToggle, onModalLabelOk, + onModalLabelCancel, ...passThroughProps } = this.props;