From 7a3067822f20e89e370be2f0f9f70b4405a1a8f3 Mon Sep 17 00:00:00 2001 From: Olle Haerstedt Date: Thu, 6 Oct 2016 17:09:39 +0200 Subject: [PATCH] Dev: Fix bug with condition form submit --- .../controllers/admin/conditionsaction.php | 1 + .../includes/form_editconditions_header.php | 28 ++++++------- scripts/admin/conditions.js | 42 ++++--------------- 3 files changed, 23 insertions(+), 48 deletions(-) diff --git a/application/controllers/admin/conditionsaction.php b/application/controllers/admin/conditionsaction.php index 8e8c115f8ef..8c05847bc0e 100644 --- a/application/controllers/admin/conditionsaction.php +++ b/application/controllers/admin/conditionsaction.php @@ -82,6 +82,7 @@ public function __construct($controller = null, $id = null) */ public function index($subaction, $iSurveyID=null, $gid=null, $qid=null) { + tracevar($_POST); $iSurveyID = sanitize_int($iSurveyID); $this->iSurveyID = $iSurveyID; $gid = sanitize_int($gid); diff --git a/application/views/admin/conditions/includes/form_editconditions_header.php b/application/views/admin/conditions/includes/form_editconditions_header.php index 44e6c50699c..d5d2a7c47a0 100644 --- a/application/views/admin/conditions/includes/form_editconditions_header.php +++ b/application/views/admin/conditions/includes/form_editconditions_header.php @@ -48,16 +48,16 @@
widget('yiiwheels.widgets.buttongroup.WhButtonGroup', array( - 'name' => 'question', - 'value'=> 'prev', + 'name' => 'editSourceTab', + 'value'=> '#SRCPREVQUEST', 'selectOptions'=>array( - 'prev' => gT('Previous questions'), - 'attr' => gT('Survey participant attributes') + '#SRCPREVQUEST' => gT('Previous questions'), + '#SRCTOKENATTRS' => gT('Survey participant attributes') )));?>
-
+
@@ -100,14 +100,14 @@
widget('yiiwheels.widgets.buttongroup.WhButtonGroup', array( - 'name' => 'answer', - 'value'=> 'predefined', + 'name' => 'editTargetTab', + 'value'=> '#CANSWERSTAB', 'selectOptions'=>array( - 'predefined' => gT('Predefined'), - 'constant' => gT('Constant'), - 'questions' => gT('Questions'), - 'tokenFields' => gT('Token fields'), - 'regexp' => gT('RegExp') + '#CANSWERSTAB' => gT('Predefined'), + '#CONST' => gT('Constant'), + '#PREVQUESTIONS' => gT('Questions'), + '#TOKENATTRS' => gT('Token fields'), + '#REGEXP' => gT('RegExp') )));?>
@@ -190,8 +190,6 @@ class='form-control' - -
diff --git a/scripts/admin/conditions.js b/scripts/admin/conditions.js index ed37d75db68..ad9ee5577ee 100644 --- a/scripts/admin/conditions.js +++ b/scripts/admin/conditions.js @@ -107,24 +107,15 @@ $(document).ready(function(){ * @return */ var questionOnChange = function(ev) { - switch (ev.currentTarget.value) { - case 'prev': - $('#SRCPREVQUEST').show(); - $('#SRCTOKENATTRS').hide(); - break; - case 'attr': - $('#SRCTOKENATTRS').show(); - $('#SRCPREVQUEST').hide(); - break; - default: - throw 'Unknown value'; - } + $('.question-option').hide(); + var value = ev.currentTarget.value; + $(value).show(); }; - $('input[name="question"]').change(questionOnChange); + $('input[name="editSourceTab"]').change(questionOnChange); // Run once on load to hide/show relevant part - var currentValue = $('input[name="question"]').val(); + var currentValue = $('input[name="editSourceTab"]').val(); var dummyEvent = {currentTarget: {value: currentValue}}; questionOnChange(dummyEvent); @@ -135,29 +126,14 @@ $(document).ready(function(){ */ var answerOnChange = function(ev) { $('.answer-option').hide(); - switch (ev.currentTarget.value) { - case 'predefined': - $('#CANSWERSTAB').show(); - break; - case 'constant': - $('#CONST').show(); - break; - case 'questions': - $('#PREVQUESTIONS').show(); - break; - case 'tokenFields': - $('#TOKENATTRS').show(); - break; - case 'regexp': - $('#REGEXP').show(); - break; - } + var value = ev.currentTarget.value; + $(value).show(); }; - $('input[name="answer"]').change(answerOnChange); + $('input[name="editTargetTab"]').change(answerOnChange); // Run once on load to hide/show relevant part - var currentValue = $('input[name="answer"]').val(); + var currentValue = $('input[name="editTargetTab"]').val(); var dummyEvent = {currentTarget: {value: currentValue}}; answerOnChange(dummyEvent);