diff --git a/awx/ui/client/src/partials/survey-maker-modal.html b/awx/ui/client/src/partials/survey-maker-modal.html
index 5385a14b28..b6acbe2ab3 100644
--- a/awx/ui/client/src/partials/survey-maker-modal.html
+++ b/awx/ui/client/src/partials/survey-maker-modal.html
@@ -84,7 +84,7 @@
-
+
diff --git a/awx/ui/client/src/templates/survey-maker/surveys/add.factory.js b/awx/ui/client/src/templates/survey-maker/surveys/add.factory.js
index 3773e1ede9..eef26fa5d6 100644
--- a/awx/ui/client/src/templates/survey-maker/surveys/add.factory.js
+++ b/awx/ui/client/src/templates/survey-maker/surveys/add.factory.js
@@ -7,6 +7,8 @@ export default
// modal title. We want this toggle to be on by default
scope.survey_enabled = true;
+ scope.isEditSurvey = false;
+
if (scope.removeDialogReady) {
scope.removeDialogReady();
}
diff --git a/awx/ui/client/src/templates/survey-maker/surveys/edit.factory.js b/awx/ui/client/src/templates/survey-maker/surveys/edit.factory.js
index 790822e628..90d2c734ce 100644
--- a/awx/ui/client/src/templates/survey-maker/surveys/edit.factory.js
+++ b/awx/ui/client/src/templates/survey-maker/surveys/edit.factory.js
@@ -37,6 +37,7 @@ export default
scope.survey_name = data.name;
scope.survey_description = data.description;
scope.survey_questions = data.spec;
+ scope.isEditSurvey = true;
Wait('stop');
} else {
AddSurvey({
diff --git a/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js b/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js
index 3a13f4f70c..f3f7d09e84 100644
--- a/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js
+++ b/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js
@@ -109,15 +109,18 @@ export default
});
};
- updateSurveyQuestions()
- .then(function() {
- return updateSurveyEnabled();
- })
- .then(function() {
- scope.closeSurvey('survey-modal-dialog');
- scope.$emit('SurveySaved');
- });
-
+ if (!scope.survey_questions || scope.survey_questions.length === 0) {
+ scope.deleteSurvey();
+ } else {
+ updateSurveyQuestions()
+ .then(function() {
+ return updateSurveyEnabled();
+ })
+ .then(function() {
+ scope.closeSurvey('survey-modal-dialog');
+ scope.$emit('SurveySaved');
+ });
+ }
};
// Gets called when the user clicks the on/off toggle beside the survey modal title.