-
In introduction, Alexa will help users to ask her the right questions about your business. For Example, she will say : "To ask us about our services, say : What do you do ? ". What do you do ? is defined in question field. Alexa will use first variation of question in intro.
-
+ {' '}
+ In introduction, Alexa will help users to ask her the right questions about your business. For Example, she will say : "To ask us about our services, say : What do you do ? ". What do you do ? is defined in question field. Alexa will use first variation of question in intro.
+
+
-
+ value={this.state.intent.intentExplanation}
+ />
+
+ value={this.state.intent.intentName}
+ />
Question variants
- {
- this.state.intent.questions.map((question, index)=>{
- return (
-
-
{this.deleteQuestion(question)}}> }
- onChange={(e)=>{this.handleQuestionEdit(e,index)}}
- value={question}/>
-
- );
- })
- }
-
- {
-
-
-
- }
-
-
-
{this.props.onDeleteIntentClick(this.state.intent)}} disabled={this.props.waiting}>Delete question
-
Add variant
-
{this.props.onSaveIntentClick(this.state.intent)}} disabled={this.props.waiting}>Save
-
+ {this.state.intent.questions.map ((question, index) => {
+ return (
+
+
{
+ this.deleteQuestion (index);
+ }}
+ >
+ {' '}
+
+ {' '}
+
+ }
+ onChange={e => {
+ this.handleQuestionEdit (e, index);
+ }}
+ value={question}
+ />
+
+ );
+ })}
+
+ add
+
+
+
+
{
+ this.props.onSaveIntentClick (this.state.intent);
+ }}
+ disabled={this.props.waiting}
+ >
+ Save
+
+
{
+ this.props.onDeleteIntentClick (this.state.intent);
+ }}
+ disabled={this.props.waiting}
+ >
+ Delete
+
+
);
}
- addQuestion(){
+ addQuestion () {
let newIntent = this.state.intent;
- newIntent.questions.push('');
- this.setState({intent: newIntent});
+ newIntent.questions.push ('');
+ this.setState ({intent: newIntent});
}
- deleteQuestion(question){
- let newIntent = this.state.intent;
- let removeId = newIntent.questions.indexOf(question);
- if (removeId !== -1)
- newIntent.questions.splice(removeId,1);
-
- this.setState({intent: newIntent});
+ deleteQuestion (index) {
+ if (this.state.intent.questions.length > 1) {
+ let newIntent = this.state.intent;
+ if (index >= 0 && index < newIntent.questions.length) newIntent.questions.splice (index, 1);
+ this.setState ({intent: newIntent});
+ }
}
- handleQuestionEdit(e,index){
- if (e.length === QUESTION_MAX_LENGTH) return;
- let newIntent = this.state.intent;
- newIntent.questions[index] = e;
- this.setState({intent: newIntent});
+ handleQuestionEdit (e, index) {
+ 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){
- if (e.length === INTENT_EXPLANATION_MAX_LENGTH) return;
- let newIntent = this.state.intent;
- newIntent.intentExplanation = e;
- this.setState({intent: newIntent});
+ handleIntentExplanationEdit (e, index) {
+ 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){
- if (e.length === ANSWER_MAX_LENGTH) return;
- let newIntent = this.state.intent;
- newIntent.answer = e;
- this.setState({intent: newIntent});
+ handleAnswerEdit (e) {
+ 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});
+ }
}
- handleIntentNameEdit(e){
- if (e.length === INTENT_NAME_MAX_LENGTH) return;
+ handleAnswerSourceEdit (e) {
+ const isAnswerSourceValid = e.length < ANSWER_MAX_LENGTH;
+ if (isAnswerSourceValid){
+ let newIntent = this.state.intent;
+ newIntent.externalAnswerSource = e;
+ this.setState ({intent: newIntent});
+ }
+ }
+
+ handleIntentNameEdit (e) {
+ 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) {
let newIntent = this.state.intent;
- newIntent.intentName = e;
- this.setState({intent: newIntent});
+ newIntent.answerType = answerType;
+ this.setState ({intent: newIntent});
}
}
diff --git a/web/src/components/LaunchRequest.js b/web/src/components/LaunchRequest.js
index a6ef19a..6d4f555 100644
--- a/web/src/components/LaunchRequest.js
+++ b/web/src/components/LaunchRequest.js
@@ -25,7 +25,7 @@ class LaunchRequest extends Component {