flip logic (comment from PR #18)

This commit is contained in:
GotPPay
2018-04-15 16:28:19 +02:00
parent 4ac7284724
commit 5a1d878150
3 changed files with 42 additions and 35 deletions

View File

@@ -155,44 +155,48 @@ class IntentDetails extends Component {
}
handleQuestionEdit (e, index) {
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});
const isQuestionValid = e.length < QUESTION_MAX_LENGTH && /^[a-z,.' ]*$/i.test (e);
if (isQuestionValid){
let newIntent = this.state.intent;
newIntent.questions[index] = e;
this.setState ({intent: newIntent});
}
}
handleIntentExplanationEdit (e, index) {
const isExplanationInvalid = e.length >= INTENT_EXPLANATION_MAX_LENGTH || !/^[a-z,.' ]*$/i.test (e);
if (isExplanationInvalid)
return;
let newIntent = this.state.intent;
newIntent.intentExplanation = e;
this.setState ({intent: newIntent});
const isExplanationValid = e.length < INTENT_EXPLANATION_MAX_LENGTH && /^[a-z,.' ]*$/i.test (e);
if (isExplanationValid){
let newIntent = this.state.intent;
newIntent.intentExplanation = e;
this.setState ({intent: newIntent});
}
}
handleAnswerEdit (e) {
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});
const isAnswerValid = e.length < ANSWER_MAX_LENGTH && /^[a-z,.' ]*$/i.test (e);
if (isAnswerValid){
let newIntent = this.state.intent;
newIntent.answer = e;
this.setState ({intent: newIntent});
}
}
handleAnswerSourceEdit (e) {
const isAnswerSourceInvalid = e.length >= ANSWER_MAX_LENGTH;
if (isAnswerSourceInvalid) return;
let newIntent = this.state.intent;
newIntent.externalAnswerSource = e;
this.setState ({intent: newIntent});
const isAnswerSourceValid = e.length < ANSWER_MAX_LENGTH;
if (isAnswerSourceValid){
let newIntent = this.state.intent;
newIntent.externalAnswerSource = e;
this.setState ({intent: newIntent});
}
}
handleIntentNameEdit (e) {
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});
const isIntentNameValid = e.length < INTENT_NAME_MAX_LENGTH && /^[a-z]*$/i.test (e);
if (isIntentNameValid){
let newIntent = this.state.intent;
newIntent.intentName = e;
this.setState ({intent: newIntent});
}
}
handleExternalSourceSave (answerType) {