Skip to content

Commit

Permalink
Fixed issue #9448: Label set update : can remove existing language
Browse files Browse the repository at this point in the history
Dev Proper warnings are shown if languages or assessment values might be lost
  • Loading branch information
c-schmitz committed May 11, 2015
1 parent e7c7ff1 commit f340431
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 36 deletions.
33 changes: 33 additions & 0 deletions application/controllers/admin/questions.php
Expand Up @@ -1029,6 +1029,39 @@ public function ajaxlabelsetpicker()
echo ls_json_encode($resultdata);
}

public function ajaxchecklabel()
{
$iLabelID = (int) Yii::app()->request->getParam('lid');
$aNewLanguages = Yii::app()->request->getParam('languages');
$bCheckAssessments = Yii::app()->request->getParam('bCheckAssessments',0);
$arLabelSet=LabelSet::model()->find('lid=:lid',array(':lid' => $iLabelID));
$iLabelsWithAssessmentValues=Label::model()->count('lid=:lid AND assessment_value<>0',array(':lid' => $iLabelID));
$aLabelSetLanguages=explode(' ',$arLabelSet->languages);
$aErrorMessages=array();
if ($bCheckAssessments && $iLabelsWithAssessmentValues)
{
$aErrorMessages[]=gT('The existing label has assessment values assigned.').'<strong>'.gT('If you replace the label set the existing asssessment values will be lost.').'</strong>';
}
if (count(array_diff($aLabelSetLanguages,$aNewLanguages)))
{
$aErrorMessages[]=gT('The existing label has different/more languages.').'<strong>'.gT('If you replace the label set these translations will be lost.').'</strong>';
}
if (count($aErrorMessages)){
foreach ($aErrorMessages as $sErrorMessage)
{
echo $sErrorMessage.'<br>';
}
eT('Do you really want to continue?');
}
else
{
eT('You are about to replace a given label set with the current answer options');
echo '<br>';
eT('Continue?');
}
}


/**
* Load preview of a question screen.
*
Expand Down
Expand Up @@ -28,6 +28,7 @@
var saveaslabletitle = '<?php $clang->eT('Save as label set','js'); ?>';
var lanameurl = '<?php echo Yii::app()->createUrl('/admin/labels/sa/getAllSets'); ?>';
var lasaveurl = '<?php echo Yii::app()->createUrl('/admin/labels/sa/ajaxSets'); ?>';
var sCheckLabelURL = '<?php echo Yii::app()->createUrl('/admin/questions/sa/ajaxchecklabel'); ?>';
var lsdetailurl = '<?php echo Yii::app()->createUrl('/admin/questions/sa/ajaxlabelsetdetails'); ?>';
var lspickurl = '<?php echo Yii::app()->createUrl('/admin/questions/sa/ajaxlabelsetpicker'); ?>';
var check = true;
Expand Down Expand Up @@ -200,7 +201,7 @@
</div>

<div id="dialog-confirm-replace" title="<?php $clang->eT('Replace label set?'); ?>" style='display:none;'>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php $clang->eT('You are about to replace a given label set with the current answer options. Continue?'); ?></p>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><span id='strReplaceMessage'></span></p>
</div>

<div id="dialog-duplicate" title="<?php $clang->eT('Duplicate label set name'); ?>" style='display:none;'>
Expand Down
3 changes: 2 additions & 1 deletion application/views/admin/survey/Question/subQuestion_view.php
Expand Up @@ -15,6 +15,7 @@
var saveaslabletitle = '<?php $clang->eT('Save as label set','js'); ?>';
var lanameurl = '<?php echo Yii::app()->createUrl('/admin/labels/sa/getAllSets'); ?>';
var lasaveurl = '<?php echo Yii::app()->createUrl('/admin/labels/sa/ajaxSets'); ?>';
var sCheckLabelURL = '<?php echo Yii::app()->createUrl('/admin/questions/sa/ajaxchecklabel'); ?>';
var lsdetailurl = '<?php echo Yii::app()->createUrl('/admin/questions/sa/ajaxlabelsetdetails'); ?>';
var lspickurl = '<?php echo Yii::app()->createUrl('/admin/questions/sa/ajaxlabelsetpicker'); ?>';
var check = true;
Expand Down Expand Up @@ -198,7 +199,7 @@ class="highlight"
</p>
</div>
<div id="dialog-confirm-replace" title="<?php $clang->eT('Replace label set?'); ?>" style='display:none;'>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php $clang->eT("You are about to replace an existing label set with the labels of this subquestions. If the existing labels had assessment values set these will be lost!"); ?><br><?php $clang->eT("Do you want to continue?");?></p>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><span id='strReplaceMessage'></span></p>
</div>

<div id="dialog-duplicate" title="<?php $clang->eT('Duplicate label set name'); ?>" style='display:none;'>
Expand Down
38 changes: 21 additions & 17 deletions scripts/admin/answers.js
Expand Up @@ -739,23 +739,27 @@ function savelabel()
}
else
{
$('#dialog-confirm-replace').dialog({
resizable: false,
height: 200,
width:350,
modal: true,
buttons: [{
text: ok,
click: function() {
$(this).dialog("close");
ajaxreqsave();
}},{
text: cancel,
click: function() {
check = false;
$(this).dialog("close");
}}
]
aLanguages = langs.split(';');
$.post(sCheckLabelURL, { languages: aLanguages, lid: lid}, function(data) {
$('#strReplaceMessage').html(data);
$('#dialog-confirm-replace').dialog({
resizable: false,
height: 200,
width:350,
modal: true,
buttons: [{
text: ok,
click: function() {
$(this).dialog("close");
ajaxreqsave();
}},{
text: cancel,
click: function() {
check = false;
$(this).dialog("close");
}}
]
});
});
}
}
Expand Down
38 changes: 21 additions & 17 deletions scripts/admin/subquestions.js
Expand Up @@ -652,23 +652,27 @@ function savelabel()
}
else
{
$('#dialog-confirm-replace').dialog({
resizable: false,
height: 230,
width:350,
modal: true,
buttons: [{
text: ok,
click: function() {
$(this).dialog("close");
ajaxreqsave();
}},{
text: cancel,
click: function() {
check = false;
$(this).dialog("close");
}}
]
aLanguages = langs.split(';');
$.post(sCheckLabelURL, { languages: aLanguages, lid: lid, bCheckAssessments:1 }, function(data) {
$('#strReplaceMessage').html(data);
$('#dialog-confirm-replace').dialog({
resizable: false,
height: 260,
width: 420,
modal: true,
buttons: [{
text: ok,
click: function() {
$(this).dialog("close");
ajaxreqsave();
}},{
text: cancel,
click: function() {
check = false;
$(this).dialog("close");
}}
]
});
});
}
}
Expand Down

0 comments on commit f340431

Please sign in to comment.