diff --git a/backend/helpers/externalSource.js b/backend/helpers/externalSource.js
index 4713672..8bf0d6c 100644
--- a/backend/helpers/externalSource.js
+++ b/backend/helpers/externalSource.js
@@ -6,14 +6,6 @@ const constants = require ('../config/constants');
let parser = new Parser ();
-getDataFromRSSFeed = function (url) {
- //let feed = await parser.parseURL(url);
- //console.log(feed.title);
- //feed.items.forEach(item => {
- // console.log(item.title + ':' + item.link)
- //});
-};
-
getDataFromWPJSON = function (sourceUrl, page = 1, maxPosts = 10) {
return new Promise ((resolve, reject) => {
var options = {
diff --git a/backend/models/alexa.js b/backend/models/alexa.js
index e7a251d..105160e 100644
--- a/backend/models/alexa.js
+++ b/backend/models/alexa.js
@@ -7,6 +7,7 @@ let predefinedSourceHelper = require ('../helpers/externalSource');
var handlers = {};
var destinationEmail;
+let skillName;
module.exports = {
run: function (req, res) {
@@ -33,6 +34,7 @@ module.exports = {
.then (activeSkill => {
handlers = {};
destinationEmail = activeSkill.contactEmail;
+ skillName = activeSkill.invocationName;
let listOfPossibleQuestions = '';
activeSkill.intents.forEach (intent => {
@@ -77,7 +79,7 @@ module.exports = {
reject: null,
};
- let answer = new Promise ((resolve, reject) => {
+ let answerPromise = new Promise ((resolve, reject) => {
answerPromiseProps = {
resolve: resolve,
reject: reject,
@@ -116,7 +118,7 @@ module.exports = {
break;
}
- answer
+ answerPromiseProps
.then (answer => {
this.response
.speak (answer)
@@ -230,7 +232,7 @@ module.exports = {
if (this.attributes['LaunchRequestYesNo']) {
this.attributes['LaunchRequestYesNo'] = false;
}
- this.response.speak ('Thank you for using Saburly');
+ this.response.speak (`Thank you for using ${skillName}`);
this.emit (':responseReady');
};
diff --git a/web/src/App.js b/web/src/App.js
index bed0a50..cd6e3eb 100644
--- a/web/src/App.js
+++ b/web/src/App.js
@@ -253,30 +253,24 @@ class App extends Component {
}
//Check for same question variants and same question name in other intents
+ //all intents with the same intentName, or some of the questions are the same
+ //will be kept in filteredIntents. After filterring, there should be only one
+ //intent left, the selected one
+
+ let selectedIntentQuestionsForSearch = selectedIntent.questions.map(question=>
+ question.toLowerCase().trim());
- for (let i = 0; i < this.state.allIntents.length; i++) {
- if (i !== this.state.selectedIndex) {
- if (selectedIntent.intentName === this.state.allIntents[i].intentName) {
- Popup.alert ('Question name already exists');
- return;
- }
+ let filteredIntents = this.state.allIntents.filter(intent=>{
+ let result = (selectedIntent.intentName.toLowerCase().trim() === intent.intentName.toLowerCase().trim());
+ let filteredQuestions = intent.questions.filter(question=>{
+ return (selectedIntentQuestionsForSearch.indexOf(question.toLowerCase().trim())!==-1);
+ });
+ return (result || filteredQuestions.length > 0);
+ });
- for (let j = 0; j < selectedIntent.questions.length; j++) {
- for (let k = 0; k < this.state.allIntents[i].questions.length; k++) {
- if (
- selectedIntent.questions[j] ===
- this.state.allIntents[i].questions[k]
- ) {
- Popup.alert (
- 'Question variant already exists (in question :' +
- this.state.allIntents[i].intentName +
- ')'
- );
- return;
- }
- }
- }
- }
+ if (filteredIntents.length > 1){
+ Popup.alert('Question name or question variant already exists');
+ return;
}
let newAllIntentsJSON = JSON.stringify (this.state.allIntents);
diff --git a/web/src/components/AnswerSource.js b/web/src/components/AnswerSource.js
index 6737020..9f6710a 100644
--- a/web/src/components/AnswerSource.js
+++ b/web/src/components/AnswerSource.js
@@ -1,9 +1,7 @@
import React, {Component} from 'react';
-import {Button, SelectionControlGroup} from 'react-md';
-import Modal from './modal/Modal';
-import {
- ANSWER_TYPE
-} from '../config/constants';
+import {Button} from 'react-md';
+import AnswerSourceForm from './helper/AnswerSourceForm';
+import '../css/components/IntentDetails.css';
class AnswerSource extends Component {
constructor (props) {
@@ -30,67 +28,27 @@ class AnswerSource extends Component {
onSave(){
this.onClose();
- this.props.onSaveHandle(this.state.answerType);
+ this.props.onSaveAnswerType(this.state.answerType);
}
onSourceChange(value, event){
- this.setState({answerType:parseInt(value)});
+ this.setState({answerType:parseInt(value,10)});
}
render () {
let modal;
if (this.state.isModalOpen) {
- modal = (
-