Author: [email protected]
Date: Mon Aug 15 17:27:56 2011
New Revision: 1321

Log:
[AMDATUOPENSOCIAL-88] Implemented the auto-decrease of gadget category count 
upon gadget removal. Next thing to do is to disable the remove button for 
gadgets that were registered whiteboard style, are there any?

Modified:
   
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
   
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/gadgets_appdata.js.jsp

Modified: 
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
==============================================================================
--- 
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
        (original)
+++ 
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
        Mon Aug 15 17:27:56 2011
@@ -201,11 +201,20 @@
     $('.removegadget').live('click', function() {
       var widget = 
dashboard.widgetsToAdd[$(this).attr("id").replace('removegadget','')];
       var uri = widget.id;
-
-      removeGadgetFromRepository(uri);
-
       var cat = $('.selectcategory.selected');
       var button = cat[0];
+
+      if (removeGadgetFromRepository(uri)) {
+        // Current gadget category count must be decreased by 1
+        var count = button.innerHTML;
+        count = count.replace("<button>", "").replace("</button>", "");
+        var catName = count.substring(0, count.lastIndexOf("("));
+        count = count.substring(count.lastIndexOf("(") + 1);
+        count = count.substring(0, count.indexOf(")"));
+        var newCount = parseInt(count) - 1;
+        button.innerHTML = "<button>" + catName + "(" + newCount + 
")</button>";
+      }
+
       button.click();
       return false;
     });

Modified: 
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/gadgets_appdata.js.jsp
==============================================================================
--- 
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/gadgets_appdata.js.jsp
  (original)
+++ 
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/gadgets_appdata.js.jsp
  Mon Aug 15 17:27:56 2011
@@ -124,16 +124,19 @@
 
 removeGadgetFromRepository = function(uri) {
   var url = "${contextPath}/rest/gadgetstore/gadgets?uri="+ 
encodeURIComponent(uri);
+  var removed = false;
   jQuery.ajax({
     url: url,
     type: "DELETE",
     async:false,
     success: function(response) {
+      removed = true;
     },
     error: function(request, textStatus, errorThrown) {
       alertErrorMessage("Could not remove the gadget from the store.", 
request, errorThrown);
     }
   });
+  return removed;
 }
 
 getGadget = function(uri) {
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to