frontend user input handling

This commit is contained in:
GotPPay
2018-01-29 21:32:24 +01:00
parent 3b5c287ef9
commit 5e92314938
5 changed files with 87 additions and 24 deletions

View File

@@ -103,33 +103,30 @@ class IntentDetails extends Component {
}
handleQuestionEdit(e,index){
if (e.length === QUESTION_MAX_LENGTH) return;
if (e.length === QUESTION_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e))) return;
let newIntent = this.state.intent;
newIntent.questions[index] = e;
this.setState({intent: newIntent});
}
handleIntentExplanationEdit(e,index){
if (e.length === INTENT_EXPLANATION_MAX_LENGTH) return;
if (e.length === INTENT_EXPLANATION_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e))) return;
let newIntent = this.state.intent;
newIntent.intentExplanation = e;
this.setState({intent: newIntent});
}
handleAnswerEdit(e){
if (e.length === ANSWER_MAX_LENGTH) return;
if (e.length === ANSWER_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e))) return;
let newIntent = this.state.intent;
newIntent.answer = e;
this.setState({intent: newIntent});
}
handleIntentNameEdit(e){
if (e.length === INTENT_NAME_MAX_LENGTH) return;
if (e.length === INTENT_NAME_MAX_LENGTH || !(/^[a-z]*$/i.test(e))) return;
let newIntent = this.state.intent;
//Allow question name with only letters, and with one character minimum
if (/^[a-z]*$/i.test(e)){
newIntent.intentName = e;
}
newIntent.intentName = e;
this.setState({intent: newIntent});
}
}