From 995bf8c58fe97fa0e066086f40e36dab246d340d Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 10 Oct 2014 14:46:53 -0400 Subject: [PATCH] adding cancel button for survey question form cancel button closes the survey question form and returns the modal into its previous state --- awx/ui/static/js/forms/SurveyQuestion.js | 2 +- awx/ui/static/js/helpers/Survey.js | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js index ff78ca4ca5..8f1be9b202 100644 --- a/awx/ui/static/js/forms/SurveyQuestion.js +++ b/awx/ui/static/js/forms/SurveyQuestion.js @@ -179,7 +179,7 @@ angular.module('SurveyQuestionFormDefinition', []) question_cancel : { label: 'Cancel', 'class' : 'btn btn-default', - ngClick: 'cancelQuestion()' + ngClick: 'cancelQuestion($event)' }, submit_question: { ngClick: 'submitQuestion()', diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js index 722fb18124..8009609b2b 100644 --- a/awx/ui/static/js/helpers/Survey.js +++ b/awx/ui/static/js/helpers/Survey.js @@ -529,8 +529,20 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope: scope }); }; - scope.cancelQuestion = function(){ - alert('success'); + scope.cancelQuestion = function(event){ + var elementID, key; + if(event.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.id==="new_question"){ + $('#new_question .aw-form-well').remove(); + $('#add_question_btn').show(); + $('#add_question_btn').removeAttr('disabled'); + } else { + elementID = event.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.id; + key = elementID.split('_')[1]; + $('#'+elementID).empty(); + scope.finalizeQuestion(scope.survey_questions[key] , key); + } + + }; scope.questionUp = function(index){