Fix: Force reload of index page when all boxes were removed. This is to

be sure to have the combo list complete after this refresh.
This commit is contained in:
Laurent Destailleur 2012-08-27 21:16:26 +02:00
parent 857a11f508
commit 24c29e23f9

View File

@ -839,12 +839,11 @@ class FormOther
var left_list = cleanSerialize(jQuery("#left").sortable("serialize")); var left_list = cleanSerialize(jQuery("#left").sortable("serialize"));
var right_list = cleanSerialize(jQuery("#right").sortable("serialize")); var right_list = cleanSerialize(jQuery("#right").sortable("serialize"));
var boxorder = \'A:\' + left_list + \'-B:\' + right_list; var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
jQuery.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\', jQuery.ajax({
async: false url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\',
async: false
}); });
//jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&boxid=\'+boxid+\'&zone='.$areacode.'&userid='.$user->id.'\');
window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid; window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=addbox&boxid=\'+boxid;
//window.location.href=\''.$_SERVER["PHP_SELF"].'\';
} }
});'; });';
if (! count($arrayboxtoactivatelabel)) print 'jQuery("#boxcombo").hide();'; if (! count($arrayboxtoactivatelabel)) print 'jQuery("#boxcombo").hide();';
@ -940,16 +939,32 @@ class FormOther
containment: \'.fiche\', containment: \'.fiche\',
connectWith: \'.connectedSortable\', connectWith: \'.connectedSortable\',
stop: function(event, ui) { stop: function(event, ui) {
updateOrder(0); updateBoxOrder(0);
} }
}); });
}); });
'."\n"; '."\n";
print 'function updateOrder() { // To update list of activated boxes
var left_list = cleanSerialize(jQuery("#left").sortable("serialize")); print 'function updateBoxOrder(closing) {
var right_list = cleanSerialize(jQuery("#right").sortable("serialize")); var left_list = cleanSerialize(jQuery("#left").sortable("serialize"));
var boxorder = \'A:\' + left_list + \'-B:\' + right_list; var right_list = cleanSerialize(jQuery("#right").sortable("serialize"));
jQuery.get(\''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.'); var boxorder = \'A:\' + left_list + \'-B:\' + right_list;
if (boxorder==\'A:A-B:B\' && closing == 1) // There is no more boxes on screen, and we are after a delete of a box so we must hide title
{
jQuery.ajax({
url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
async: false
});
// We force reload to be sure to get all boxes into list
window.location.search=\'mainmenu='.GETPOST("mainmenu").'&leftmenu='.GETPOST('leftmenu').'&action=delbox\';
}
else
{
jQuery.ajax({
url: \''.DOL_URL_ROOT.'/core/ajax/box.php?boxorder=\'+boxorder+\'&zone='.$areacode.'&userid=\'+'.$user->id.',
async: true
});
}
}'."\n"; }'."\n";
// For closing // For closing
print 'jQuery(document).ready(function() { print 'jQuery(document).ready(function() {
@ -957,7 +972,7 @@ class FormOther
var self = this; // because JQuery can modify this var self = this; // because JQuery can modify this
var boxid=self.id.substring(8); var boxid=self.id.substring(8);
jQuery(\'#boxto_\'+boxid).remove(); jQuery(\'#boxto_\'+boxid).remove();
updateOrder(); updateBoxOrder(1);
}); });
});'."\n"; });'."\n";
print '</script>'."\n"; print '</script>'."\n";