Allow only letters for question name
This commit is contained in:
@@ -132,7 +132,6 @@ class App extends Component {
|
|||||||
this.setState ({
|
this.setState ({
|
||||||
selectedIntent: selectedIntent,
|
selectedIntent: selectedIntent,
|
||||||
selectedIndex: index,
|
selectedIndex: index,
|
||||||
launchRequest: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,14 +215,18 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSaveIntentClick (selectedIntent) {
|
handleSaveIntentClick (selectedIntent) {
|
||||||
|
console.log("Save intent");
|
||||||
let newAllIntentsJSON = JSON.stringify (this.state.allIntents);
|
let newAllIntentsJSON = JSON.stringify (this.state.allIntents);
|
||||||
let newAllIntents = JSON.parse (newAllIntentsJSON);
|
let newAllIntents = JSON.parse (newAllIntentsJSON);
|
||||||
|
|
||||||
|
let resolveState = null;
|
||||||
|
let rejectState = this.state;
|
||||||
|
rejectState.waiting = false;
|
||||||
|
|
||||||
let newState = null;
|
|
||||||
if (this.state.selectedIndex === NEW_INTENT_SELECTED_INDEX) {
|
if (this.state.selectedIndex === NEW_INTENT_SELECTED_INDEX) {
|
||||||
//new intent
|
//new intent
|
||||||
newAllIntents.push (selectedIntent);
|
newAllIntents.push (selectedIntent);
|
||||||
newState = {
|
resolveState = {
|
||||||
allIntents: newAllIntents,
|
allIntents: newAllIntents,
|
||||||
selectedIntent: selectedIntent,
|
selectedIntent: selectedIntent,
|
||||||
selectedIndex: newAllIntents.length - 1,
|
selectedIndex: newAllIntents.length - 1,
|
||||||
@@ -231,18 +234,17 @@ class App extends Component {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
newAllIntents[this.state.selectedIndex] = selectedIntent;
|
newAllIntents[this.state.selectedIndex] = selectedIntent;
|
||||||
newState = {
|
resolveState = {
|
||||||
allIntents: newAllIntents,
|
allIntents: newAllIntents,
|
||||||
selectedIntent: selectedIntent,
|
selectedIntent: selectedIntent,
|
||||||
waiting: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.setState ({waiting: true});
|
this.setState ({waiting: true});
|
||||||
this.sendSkill (
|
this.sendSkill (
|
||||||
newAllIntents,
|
newAllIntents,
|
||||||
true,
|
true,
|
||||||
newState,
|
resolveState,
|
||||||
{waiting: false},
|
rejectState,
|
||||||
this.state.invocationName,
|
this.state.invocationName,
|
||||||
this.state.invocationAnswer,
|
this.state.invocationAnswer,
|
||||||
this.state.contactEmail,
|
this.state.contactEmail,
|
||||||
|
|||||||
@@ -126,7 +126,10 @@ class IntentDetails extends Component {
|
|||||||
handleIntentNameEdit(e){
|
handleIntentNameEdit(e){
|
||||||
if (e.length === INTENT_NAME_MAX_LENGTH) return;
|
if (e.length === INTENT_NAME_MAX_LENGTH) return;
|
||||||
let newIntent = this.state.intent;
|
let newIntent = this.state.intent;
|
||||||
newIntent.intentName = e.replace(/\s/g, ''); //remove all spaces from intent name
|
//Allow question name with only letters, and with one character minimum
|
||||||
|
if (/^[a-z]+$/i.test(e)){
|
||||||
|
newIntent.intentName = e;
|
||||||
|
}
|
||||||
this.setState({intent: newIntent});
|
this.setState({intent: newIntent});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user