Author: channa
Date: Wed May  7 08:55:21 2008
New Revision: 16626

Log:

Added warning message and confirmation for administrator's tag deletion 
(completing MASHUP-667).

Modified:
   trunk/mashup/java/modules/www/ajax_tag.jsp
   trunk/mashup/java/modules/www/js/mashup-utils.js
   trunk/mashup/java/modules/www/mashup.jsp

Modified: trunk/mashup/java/modules/www/ajax_tag.jsp
==============================================================================
--- trunk/mashup/java/modules/www/ajax_tag.jsp  (original)
+++ trunk/mashup/java/modules/www/ajax_tag.jsp  Wed May  7 08:55:21 2008
@@ -81,7 +81,7 @@
     for (int i = 0; i < tags.length; i++) {
         Tag tag = tags[i];
         String name = tag.getTagName();
-        boolean canDelete = (author.equals(currentUser) || 
RegistryUtils.isAdminRole(userRegistry));
+        boolean canDelete = (author.equals(currentUser));
 
         if (!canDelete) {
             QueryResults isTagger = RegistryUtils.doQuery(userRegistry,
@@ -96,6 +96,8 @@
         <a class="link-cloud2" 
href="search.jsp?query=mashups&for=<%=name%>&tags=true"><%=name%></a><%
         if (canDelete) {
             %>&nbsp;<span class="edit-link"><img src="images/smalldelete.gif" 
alt="remove this tag" onClick="removeTag('<%=name%>')"/></span><%
+        } else if (RegistryUtils.isAdminRole(userRegistry)) {
+            %>&nbsp;<span class="edit-link"><img src="images/smalldelete.gif" 
alt="remove this tag" 
onClick="WSO2.MashupUtils.showTagDeletionDialog('<%=name%>')"/></span><%
         }
         if (i < tags.length - 1) out.print(","); %>&nbsp; <%
     } 

Modified: trunk/mashup/java/modules/www/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-utils.js    (original)
+++ trunk/mashup/java/modules/www/js/mashup-utils.js    Wed May  7 08:55:21 2008
@@ -320,6 +320,47 @@
     });
 };
 
+/**
+ * @description Displays the dialog to warn about tag deletion and get 
confirmation.
+ * @method showTagDeletionDialog
+ */
+WSO2.MashupUtils.showTagDeletionDialog = function(tag) {
+
+    //Creating a dialog to show the warning and get confirmation.
+    var parent = document.createElement("div");
+    parent.setAttribute("id", "TagDeletionDialog");
+
+    var lblWarnMessage = document.createElement("label");
+    var txtStrong = document.createElement("strong");
+    txtStrong.appendChild(document.createTextNode("Please confirm that you 
wish to delete the '" +
+        tag + "' tag added by any and all users to this Mashup!"));
+    lblWarnMessage.appendChild(txtStrong);
+    parent.appendChild(lblWarnMessage);
+
+    parent.appendChild(document.createElement("br"));
+    parent.appendChild(document.createElement("br"));
+
+    var cmdCancel = document.createElement("input");
+    cmdCancel.setAttribute("type", "button");
+    cmdCancel.setAttribute("id", "cmdCancel");
+    cmdCancel.value = "Cancel";
+    cmdCancel.setAttribute("onclick", "WSO2.MashupUtils.dialog.close();");
+    cmdCancel.setAttribute("style", "float: right;");
+    parent.appendChild(cmdCancel);
+
+    var cmdSubmit = document.createElement("input");
+    cmdSubmit.setAttribute("type", "button");
+    cmdSubmit.setAttribute("id", "cmdSubmit");
+    cmdSubmit.value = "Delete";
+    cmdSubmit.setAttribute("onclick", "removeTag('" + tag + 
"');WSO2.MashupUtils.dialog.close();");
+    cmdSubmit.setAttribute("style", "float: right;");
+    parent.appendChild(cmdSubmit);
+
+    YAHOO.util.Event.onContentReady('doc3', function() {
+        // Instantiate the Dialog
+        WSO2.MashupUtils.dialog("Confirm Tag Deletion", parent.innerHTML, 400, 
100, 'cmdCancel');
+    });
+};
 
 WSO2.MashupUtils.makeServiceNameValidationRequest = function(userName) {
 

Modified: trunk/mashup/java/modules/www/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/mashup.jsp    (original)
+++ trunk/mashup/java/modules/www/mashup.jsp    Wed May  7 08:55:21 2008
@@ -483,7 +483,7 @@
                 for (int i = 0; i < tags.length; i++) {
                     Tag tag = tags[i];
                     String name = tag.getTagName();
-                    boolean canDelete = (author.equals(currentUser) || 
RegistryUtils.isAdminRole(userRegistry));
+                    boolean canDelete = (author.equals(currentUser));
 
                     if (!canDelete) {
                         QueryResults isTagger = 
RegistryUtils.doQuery(userRegistry,
@@ -498,6 +498,8 @@
                     <a class="link-cloud2" 
href="search.jsp?query=mashups&for=<%=name%>&tags=true"><%=name%></a><%
                     if (canDelete) {
                         %>&nbsp;<span class="edit-link"><img 
src="images/smalldelete.gif" alt="remove this tag" 
onClick="removeTag('<%=name%>')"/></span><%
+                    } else if (RegistryUtils.isAdminRole(userRegistry)) {
+                        %>&nbsp;<span class="edit-link"><img 
src="images/smalldelete.gif" alt="remove this tag" 
onClick="WSO2.MashupUtils.showTagDeletionDialog('<%=name%>')"/></span><%
                     }
                     if (i < tags.length - 1) out.print(","); %>&nbsp; <%
                 } %>

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to