fixed PR #15 comments

This commit is contained in:
GotPPay
2018-04-03 14:19:07 +02:00
parent 284cdcd7ba
commit 4a43dda852
11 changed files with 164 additions and 151 deletions

View File

@@ -10,6 +10,7 @@ import {
INTENT_EXPLANATION_MAX_LENGTH,
ANSWER_TYPE,
} from '../config/constants';
import AnswerTextBox from './helper/AnswerTextBox.js';
class IntentDetails extends Component {
constructor (props) {
@@ -20,13 +21,10 @@ class IntentDetails extends Component {
this.addQuestion = this.addQuestion.bind (this);
this.deleteQuestion = this.deleteQuestion.bind (this);
this.handleQuestionEdit = this.handleQuestionEdit.bind (this);
this.handleAnswerEdit = this.handleAnswerEdit.bind (this);
this.handleAnswerSourceEdit = this.handleAnswerSourceEdit.bind (this);
this.handleIntentNameEdit = this.handleIntentNameEdit.bind (this);
this.handleIntentExplanationEdit = this.handleIntentExplanationEdit.bind (
this
);
this.handleExternalSourceSave = this.handleExternalSourceSave.bind (this);
}
componentWillReceiveProps (props) {
@@ -34,43 +32,6 @@ class IntentDetails extends Component {
}
render () {
let answerBox;
switch (this.state.intent.answerType) {
case ANSWER_TYPE.PREDEFINED:
answerBox = (
<div className="QuestionBox">
<TextField
id="intent answer"
lineDirection="center"
label="Answer"
placeholder="Answer"
maxLength={ANSWER_MAX_LENGTH}
className="md-cell md-cell--bottom IntentDetailsInputBoxes"
onChange={this.handleAnswerEdit}
value={this.state.intent.answer}
/>
</div>
);
break;
case ANSWER_TYPE.EXTERNAL_SOURCE_WP_JSON:
case ANSWER_TYPE.EXTERNAL_SOURCE_RSS:
answerBox = (
<div className="QuestionBox">
<TextField
id="intent answer"
lineDirection="center"
label="Answer source"
placeholder="Answer source"
maxLength={ANSWER_MAX_LENGTH}
className="md-cell md-cell--bottom IntentDetailsInputBoxes"
onChange={this.handleAnswerSourceEdit}
value={this.state.intent.externalAnswerSource}
/>
</div>
);
break;
}
return (
<div className="RightPanelBox">
<div className="QuestionBox">
@@ -140,11 +101,17 @@ class IntentDetails extends Component {
add
</Button>
<AnswerSource
className="QuestionTypeButton"
onSaveHandle={this.handleExternalSourceSave}
className="AnswerTypeButton"
onSaveAnswerType={this.handleExternalSourceSave.bind(this)}
answerType={this.state.intent.answerType}
/>
{answerBox}
<AnswerTextBox
answerType={this.state.intent.answerType}
externalAnswerSource={this.state.intent.externalAnswerSource}
handleAnswerSourceEdit={this.handleAnswerSourceEdit.bind(this)}
handleAnswerEdit={this.handleAnswerEdit.bind(this)}
answer={this.state.intent.answer}
/>
<Button
className="IntentDetailsButton-firstInRow"
flat