improved code readability (comment from PR #18

This commit is contained in:
GotPPay
2018-04-11 10:42:06 +02:00
parent 83134841a2
commit e138c6e09e

View File

@@ -155,14 +155,16 @@ class IntentDetails extends Component {
}
handleQuestionEdit (e, index) {
if (e.length >= QUESTION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e)) return;
const isQuestionInvalid = e.length >= QUESTION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
if (isQuestionInvalid) return;
let newIntent = this.state.intent;
newIntent.questions[index] = e;
this.setState ({intent: newIntent});
}
handleIntentExplanationEdit (e, index) {
if (e.length >= INTENT_EXPLANATION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e))
const isExplanationInvalid = e.length >= INTENT_EXPLANATION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
if (isExplanationInvalid)
return;
let newIntent = this.state.intent;
newIntent.intentExplanation = e;
@@ -170,21 +172,24 @@ class IntentDetails extends Component {
}
handleAnswerEdit (e) {
if (e.length >= ANSWER_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e)) return;
const isAnswerInvalid = e.length >= ANSWER_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
if (isAnswerInvalid) return;
let newIntent = this.state.intent;
newIntent.answer = e;
this.setState ({intent: newIntent});
}
handleAnswerSourceEdit (e) {
if (e.length >= ANSWER_MAX_LENGTH) return;
const isAnswerSourceInvalid = e.length >= ANSWER_MAX_LENGTH;
if (isAnswerSourceInvalid) return;
let newIntent = this.state.intent;
newIntent.externalAnswerSource = e;
this.setState ({intent: newIntent});
}
handleIntentNameEdit (e) {
if (e.length >= INTENT_NAME_MAX_LENGTH || !/^[a-z]*$/i.test (e)) return;
const isIntentNameInvalid = e.length >= INTENT_NAME_MAX_LENGTH || !/^[a-z]*$/i.test (e);
if (isIntentNameInvalid) return;
let newIntent = this.state.intent;
newIntent.intentName = e;
this.setState ({intent: newIntent});