Commits

Robert Massaioli [Atlassian] committed f358148

Elements can now be deleted from the pingme page.

Comments (0)

Files changed (4)

 # Eclipse Generated Files
 .classpath
 .project
+.settings
 
 # Maven
 target

src/main/resources/js/list-user-pings.js

             ping.contextPath = AJS.contextPath();
             tableBody.append(AJS.template.load("ping-row").fill(ping))
         }
+        setupDeletion();
     };
 
     // This function actually performs a delete back to the server.
             url: AJS.contextPath() + "/rest/pingme/latest/ping",
             type: "DELETE",
             cache: false,
-            data: {
+            data: JSON.stringify({
                pingId: pingId
-            },
+            }),
             contentType:"application/json; charset=utf-8",
             dataType:"json"
         }).done(function (json) {
     };
 
     // Setup the rows so that if the delete button is pressed then they are removed
-    AJS.$(".ping-row").each(function(element) {
-       var pingRow = AJS.$(this); 
-       var pingId = pingRow.attr("x-ping-id");
-       pingRow.$(this).find(".delete-button").click(function() {
-          deletePing(pindId, function() {
-             // TODO does this actually remove the row?
-             pingRow.remove();
-          });
-       });
-    });
+    var setupDeletion = function() {
+	    AJS.$(".ping-row").each(function(element) {
+	       console.log("Running through element!");
+	       var pingRow = AJS.$(this); 
+	       var pingId = pingRow.attr("x-ping-id");
+	       pingRow.find(".delete-button").click(function(event) {
+	          deletePing(pingId, function() {
+	             // TODO does this actually remove the row?
+	             pingRow.remove();
+	          });
+	          event.preventDefault();
+	       });
+	    });
+    };
     
     AJS.$("#clear-user-pings").click(clearMyPings);
     AJS.$("#refresh-list").click(getMyPings);

src/main/resources/templates/list-user-pings.vm

         </script>
     </head>
     <body>
-        <h1>My Pings</h1>
-
-        <p>These are the global operations that you can perform:</p>
-        <input id="clear-user-pings" type="button" value="Clear My Pings" />
-
-        <p>This table contains your pings. You can delete your pings from this page</p>
-        <div id="status-messages"></div>
-        <input id="refresh-list" type="button" value="Refresh my Ping List" />
-        <table class="aui" id="ping">
-            <thead>
-                <tr>
-                    <td id="ping-date">Ping Date</td>
-                    <td id="ping-issueid">Issue</td>
-                    <td id="ping-operations">Operations</td>
-                </tr>
-            </thead>
-            <tbody></tbody>
-        </table>
+    	<form class="aui-panel">
+	        <h1>My Pings</h1>
+	
+	        <p>These are the global operations that you can perform:</p>
+	        <input id="clear-user-pings" type="button" value="Clear My Pings" />
+	
+	        <p>This table contains your pings. You can delete your pings from this page</p>
+	        <div id="status-messages"></div>
+	        <input id="refresh-list" type="button" value="Refresh my Ping List" />
+	        <table class="aui" id="ping">
+	            <thead>
+	                <tr>
+	                    <td id="ping-date">Ping Date</td>
+	                    <td id="ping-issueid">Issue</td>
+	                    <td id="ping-operations">Operations</td>
+	                </tr>
+	            </thead>
+	            <tbody></tbody>
+	        </table>
+        </form>
     </body>
 </html>

src/test/java/it/com/atlassian/jira/extension/rest/PingMeRestResourceFuncTest.java

 
     @Test
     public void messageIsValid() {
-
-        String baseUrl = System.getProperty("baseurl");
-        String resourceUrl = baseUrl + "/rest/pingme/1.0/message";
-
-        RestClient client = new RestClient();
-        Resource resource = client.resource(resourceUrl);
+//        String baseUrl = System.getProperty("baseurl");
+//        String resourceUrl = baseUrl + "/rest/pingme/1.0/message";
+//
+//        RestClient client = new RestClient();
+//        Resource resource = client.resource(resourceUrl);
     }
 }