Bladeren bron

Fixed Trac #449: properly reload the current selection when the list of Favorite Organizations is a paginated list.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1525 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 jaren geleden
bovenliggende
commit
29571985bd
1 gewijzigde bestanden met toevoegingen van 37 en 7 verwijderingen
  1. 37 7
      pages/preferences.php

+ 37 - 7
pages/preferences.php

@@ -63,7 +63,20 @@ function DisplayPreferences($oP)
 		// All checked
 		$oP->add_ready_script(
 <<<EOF
+	var pager = $('#user_prefs form .pager');
+	if (pager.length > 0)
+	{
+		console.log("PAGINATED display");
+		// paginated display, restore the selection
+		$(':input[name=selectionMode]', pager).val('negative');
+		$('#user_prefs table.listResults').trigger('load_selection');
+		
+	}
+	else
+	{
+		console.log("Non-paginated display");
 		CheckAll('#user_prefs .listResults :checkbox:not(:disabled)', true);
+	}
 EOF
 );
 	}
@@ -72,15 +85,32 @@ EOF
 		$sChecked = implode('","', $aFavoriteOrgs);
 		$oP->add_ready_script(
 <<<EOF
-	$('#user_prefs form :checkbox[name^=selectObject]').each( function()
+	var aChecked = ["$sChecked"];
+	var pager = $('#user_prefs form .pager');
+	if (pager.length > 0)
+	{
+		console.log("PAGINATED display");
+		// paginated display, restore the selection
+		$(':input[name=selectionMode]', pager).val('positive');
+		for (i=0; i<aChecked.length; i++)
 		{
-			var aChecked = ["$sChecked"];
-			if ($.inArray($(this).val(), aChecked) > -1)
+			pager.append('<input type="hidden" name="storedSelection[]" id="'+aChecked[i]+'" value="'+aChecked[i]+'"/>');
+		}
+		$('#user_prefs table.listResults').trigger('load_selection');
+		
+	}
+	else
+	{
+		console.log("Non-paginated display");
+		$('#user_prefs form :checkbox[name^=selectObject]').each( function()
 			{
-				$(this).attr('checked', true);
-				$(this).trigger('change');
-			}
-		});
+				if ($.inArray($(this).val(), aChecked) > -1)
+				{
+					$(this).attr('checked', true);
+					$(this).trigger('change');
+				}
+			});
+	}
 EOF
 );
 	}}