Skip to content

Commit

Permalink
Dev: Fix bug with condition form submit
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Oct 6, 2016
1 parent 24e718a commit 7a30678
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 48 deletions.
1 change: 1 addition & 0 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -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);
Expand Down
Expand Up @@ -48,16 +48,16 @@
<label class='control-label col-sm-2'><?php eT("Question"); ?></label>
<div class='col-sm-5'>
<?php $this->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')
)));?>
</div>
</div>

<div id='SRCPREVQUEST' class='form-group'>
<div id='SRCPREVQUEST' class='form-group question-option'>
<label class='control-label col-sm-2'><?php eT("Previous questions"); ?></label>
<div class='col-sm-5'>
<select class='form-control' name='cquestions' id='cquestions' size='<?php echo $qcountI;?>'>
Expand All @@ -70,7 +70,7 @@
</div>
</div>

<div id='SRCTOKENATTRS' class='form-group'>
<div id='SRCTOKENATTRS' class='form-group question-option'>
<label class='control-label col-sm-2'><?php eT("Survey participant attributes"); ?></label>
<div class='col-sm-5'>
<select class='form-control' name='csrctoken' id='csrctoken' >
Expand Down Expand Up @@ -100,14 +100,14 @@
<label class='control-label col-sm-2'><?php echo gT("Answer"); ?></label>
<div class='col-sm-8'>
<?php $this->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')
)));?>
</div>
</div>
Expand Down Expand Up @@ -190,8 +190,6 @@ class='form-control'
<input type='hidden' name='subaction' value='<?php echo $submitSubaction; ?>' />
<input type='hidden' name='cqid' id='cqid' value='' />
<input type='hidden' name='cid' id='cid' value='<?php echo $submitcid; ?>' />
<input type='hidden' name='editTargetTab' id='editTargetTab' value='' />
<input type='hidden' name='editSourceTab' id='editSourceTab' value='' />
<input type='hidden' name='canswersToSelect' id='canswersToSelect' value='' />
</div>
</div>
Expand Down
42 changes: 9 additions & 33 deletions scripts/admin/conditions.js
Expand Up @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit 7a30678

Please sign in to comment.