Improved Organization Application review overview and bulk reviewing.
authorLennard de Rijk <ljvderijk@gmail.com>
Sat, 28 Feb 2009 22:23:16 +0000
changeset 1570 cda9f118bfef
parent 1569 6347d0a4fa7b
child 1571 e23f9719ec1f
Improved Organization Application review overview and bulk reviewing. Both buttons now fade out and if no organizations can be accepted/rejected the buttons will not fade and a message will be shown to the user explaining the situation. Patch by: Mario Ferraro Reviewed by: Lennard de Rijk
app/soc/content/js/bulk-review.js
app/soc/templates/soc/org_app/review_overview.html
--- a/app/soc/content/js/bulk-review.js	Sat Feb 28 21:26:28 2009 +0000
+++ b/app/soc/content/js/bulk-review.js	Sat Feb 28 22:23:16 2009 +0000
@@ -2,14 +2,14 @@
 	$("#applications_progress_bar").progressBar({showText: false});
 });
 
-function bulkReviewInit(bulk_review_link) {
+function bulkReviewInit(bulk_review_link,button) {
 	// get the JSON object with details of every application for bulk acceptance
 	$.getJSON(bulk_review_link+"?_="+(new Date().getTime()),
 		function(data){
 			// If there are applications to review...
 			if (data.nr_applications != 0) {
 				//...then fade out the button, show the progress bar and call the function for review
-				$("#button_bulk_review").fadeOut("slow",
+				$("[id^=button_bulk_]").fadeOut("slow",
 					function() {
 						$("#applications_progress_bar").progressBar(0);
 						$("#description_done").html("");
@@ -17,7 +17,14 @@
 					}
 				);
 			}else {
-				$("#description_done").html("<strong>No organizations to accept</strong>");
+				var no_organization_text="No organizations to ";
+				if ($(button).attr("id").indexOf("reject")!=-1) {
+					no_organization_text+="reject";
+				}
+				else {
+					no_organization_text+="accept";
+				}
+				$("#description_done").html("<strong>"+no_organization_text+"</strong>");
 			}
 		}
 	);
@@ -64,7 +71,7 @@
 			error: function(XMLHttpRequest, textStatus, errorThrown) {
 				// if there is an error return the button and leave a try again message
 				error_happened = true;
-				$("#button_bulk_review").fadeIn("slow", function() {
+				$("[id^=button_bulk_]").fadeIn("slow", function() {
 					$("#description_done").html("<strong class='error'> Error encountered, try again</strong>");
 				});
 			}
@@ -81,7 +88,7 @@
 				$("#applications_progress_bar").fadeOut("slow",
 					function() {
 						$("#applications_progress_bar").progressBar(0);
-						$("#button_bulk_review").fadeIn("slow");
+						$("[id^=button_bulk_]").fadeIn("slow");
 					}
 				);
 				$("#description_progressbar").html("");
--- a/app/soc/templates/soc/org_app/review_overview.html	Sat Feb 28 21:26:28 2009 +0000
+++ b/app/soc/templates/soc/org_app/review_overview.html	Sat Feb 28 22:23:16 2009 +0000
@@ -14,15 +14,12 @@
 {% endcomment %}
 
 {% block body %}
-<input id="button_bulk_review" type="button" class="button" 
-  onclick="javascript:bulkReviewInit('{{ bulk_accept_link|safe }}');" value="Bulk Accept"
+<input id="button_bulk_accept" type="button" class="button" 
+  onclick="javascript:bulkReviewInit('{{ bulk_accept_link|safe }}',this);" value="Bulk Accept"
 />
-{% comment %}
-TODO(ljvderijk) also make this button disappear
-{% endcomment %}
 
-<input id="button_bulk_review" type="button" class="button" 
-  onclick="javascript:bulkReviewInit('{{ bulk_reject_link|safe }}');" value="Bulk Reject"
+<input id="button_bulk_reject" type="button" class="button" 
+  onclick="javascript:bulkReviewInit('{{ bulk_reject_link|safe }}',this);" value="Bulk Reject"
 />
 <span class="progressBar" style="display:none;" id="applications_progress_bar"></span>
 <span id="description_progressbar"></span><span id="description_done"></span>