Skip to content

Commit

Permalink
Fixed issue #08467: Questions can disappear during sorting
Browse files Browse the repository at this point in the history
Dev: Updated plugin call to work with new API
  • Loading branch information
tpartner committed Dec 21, 2013
1 parent 16f50ca commit 95e46d2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Expand Up @@ -8,18 +8,18 @@
<?php $clang->eT("After you are done please click the bottom 'Save' button to save your changes.");?>
</p>
<div class='movableList'>
<ol class="organizer">
<ol class="organizer group-list" data-level='group'>
<?php
foreach ($aGroupsAndQuestions as $aGroupAndQuestions)
{?>
<li id='list_g<?php echo $aGroupAndQuestions['gid'];?>'><div class='ui-widget-header'> <?php echo $aGroupAndQuestions['group_name'];?></div>
<li id='list_g<?php echo $aGroupAndQuestions['gid'];?>' class='group-item' data-level='group'><div class='ui-widget-header'> <?php echo $aGroupAndQuestions['group_name'];?></div>
<?php if (isset ($aGroupAndQuestions['questions']))
{?>
<ol>
<ol class='question-list' data-level='question'>
<?php
foreach($aGroupAndQuestions['questions'] as $aQuestion)
{?>
<li id='list_q<?php echo $aQuestion['qid'];?>'><div><b><a href='<?php echo Yii::app()->getController()->createUrl('admin/questions/sa/editquestion/surveyid/'.$surveyid.'/gid/'.$aQuestion['gid'].'/qid/'.$aQuestion['qid']);?>'><?php echo $aQuestion['title'];?></a></b>: <?php echo flattenText($aQuestion['question'],true);?></div></li>
<li id='list_q<?php echo $aQuestion['qid'];?>' class='question-item' data-level='question'><div><b><a href='<?php echo Yii::app()->getController()->createUrl('admin/questions/sa/editquestion/surveyid/'.$surveyid.'/gid/'.$aQuestion['gid'].'/qid/'.$aQuestion['qid']);?>'><?php echo $aQuestion['title'];?></a></b>: <?php echo flattenText($aQuestion['question'],true);?></div></li>

<?php }?>
</ol>
Expand Down
23 changes: 15 additions & 8 deletions scripts/admin/organize.js
@@ -1,6 +1,7 @@
$(document).ready(function(){
var sourceItem;
$('ol.organizer').nestedSortable({
doNotClear: true,
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'div',
Expand All @@ -13,16 +14,22 @@ $(document).ready(function(){
tabSize: 25,
rootID: 'root',
stop: function(event, ui) {
if (ui.item[0].sourceLevel!=ui.placeholder.destinationLevel)
$('ol.organizer').nestedSortable('cancel');
var itemLevel = $(ui.item).attr('data-level');
var listLevel = $(ui.item).closest('ol').attr('data-level');
if (itemLevel != listLevel) {
$('ol.organizer').nestedSortable('cancel');
}
},
change: function(event, ui) {
if (typeof ui.item[0] != 'undefined' && typeof ui.placeholder != 'undefined')
{
if (ui.item[0].sourceLevel!=ui.placeholder.destinationLevel)
{
$('.placeholder').addClass('ui-nestedSortable-error');
}
if (typeof ui.item != 'undefined' && typeof ui.placeholder != 'undefined') {
var itemLevel = $(ui.item).attr('data-level');
var listLevel = $(ui.placeholder).closest('ol').attr('data-level');
if (itemLevel != listLevel) {
$('.placeholder').addClass('ui-nestedSortable-error');
}
else {
$('.placeholder').removeClass('ui-nestedSortable-error');
}
}
},
tolerance: 'pointer',
Expand Down

0 comments on commit 95e46d2

Please sign in to comment.