Merge branch 'tests-for-import-from-source' into summarizer-feature

This commit is contained in:
GotPPay
2018-04-15 16:33:03 +02:00
3 changed files with 42 additions and 35 deletions

View File

@@ -40,9 +40,10 @@ class Contact extends Component {
}
handleEmailEdit(e){
const isEmailInvalid = e.length >= EMAIL_MAX_LENGTH;
if (isEmailInvalid) return;
this.setState({contactEmail: e});
const isEmailValid = e.length < EMAIL_MAX_LENGTH;
if (isEmailValid){
this.setState({contactEmail: e});
}
}
}

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) {

View File

@@ -52,15 +52,17 @@ class LaunchRequest extends Component {
}
handleNameEdit(e){
const isInvocationNameInvalid = e.length === INVOCATION_NAME_MAX_LENGTH || !(/^[a-z,.' ]*$/.test(e));
if (isInvocationNameInvalid) return;
this.setState({invocationName: e});
const isInvocationNameValid = e.length < INVOCATION_NAME_MAX_LENGTH && (/^[a-z,.' ]*$/.test(e));
if (isInvocationNameValid) {
this.setState({invocationName: e});
}
}
handleAnswerEdit(e){
const isInvocationAnswerInvalid = e.length === INVOCATION_ANSWER_MAX_LENGTH || !(/^[a-z,.' ]*$/i.test(e));
if (isInvocationAnswerInvalid) return;
this.setState({invocationAnswer: e});
const isInvocationAnswerValid = e.length < INVOCATION_ANSWER_MAX_LENGTH && (/^[a-z,.' ]*$/i.test(e));
if (isInvocationAnswerValid){
this.setState({invocationAnswer: e});
}
}
}