Add nickname (with character restrictions) and comment fields when closing bug
authorAndy Allan <gravitystorm@gmail.com>
Wed, 24 Nov 2010 14:06:51 +0000 (14:06 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 24 Nov 2010 14:06:51 +0000 (14:06 +0000)
net/systemeD/potlatch2/BugLayer.as
net/systemeD/potlatch2/panels/BugPanel.mxml

index 01e9d6c..4ccee60 100644 (file)
@@ -25,14 +25,12 @@ package net.systemeD.potlatch2 {
             super(n,map,s);
         }
 
-        public function closeBug(m:Marker):void {
+        public function closeBug(m:Marker, nickname:String = "NoName", comment:String = "No Comment"):void {
             var id:String = m.getTag('bug_id');
             var status:String = BUG_STATUS_FIXED;
-            var comment:String = "NoComment";
-            var nickname:String = "NoName";
 
             //TODO urlencode stuff
-            var urlReq:URLRequest = new URLRequest(baseUrl+"changeBugStatus?id="+id+"&status="+status+"&comment="+comment+"&nickname="+nickname+"&key="+apiKey);
+            var urlReq:URLRequest = new URLRequest(baseUrl+"changeBugStatus?id="+id+"&status="+status+"&comment="+encodeURIComponent(comment)+"&nickname="+encodeURIComponent(nickname)+"&key="+apiKey);
             urlReq.method = "POST";
             urlReq.data = '    '; // dear Adobe, this is nuts, kthxbye (you can't POST with an empty payload)
             var loader:URLLoader = new URLLoader();
index a176256..3ac5b0e 100644 (file)
       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
     </mx:columns>
   </mx:DataGrid>
-  <mx:HBox id="bugControl" horizontalAlign="right" width="100%" visible="false">
-    <mx:LinkButton label="Add Comment" enabled="false" />
-    <mx:LinkButton label="Close Bug" click="closeBug()" />
-  </mx:HBox>
+  <mx:ViewStack id="bugControlStack" resizeToContent="true">
+    <mx:HBox id="bugControl" horizontalAlign="right" width="100%" visible="false">
+      <mx:LinkButton label="Add Comment" enabled="false" />
+      <mx:LinkButton label="Close Bug" click="bugControlStack.selectedChild=closeBugVBox;" />
+    </mx:HBox>
+
+    <mx:VBox id="closeBugVBox" visible="false">
+      <mx:Text><mx:text>Add your comment and close the bug</mx:text></mx:Text>
+      <mx:Label><mx:text>NickName</mx:text></mx:Label>
+      <mx:TextInput id="nickName" restrict="a-zA-Z0-9.\-_"/>
+      <mx:Text><mx:text>Comment form</mx:text></mx:Text>
+      <mx:TextArea id="closeComment" />
+      <mx:HBox horizontalAlign="right" width="100%">
+          <mx:LinkButton label="Cancel" click="bugControlStack.selectedChild=bugControl;" />
+          <mx:LinkButton label="Close Bug" click="closeBug()" />
+      </mx:HBox>
+    </mx:VBox>
+  </mx:ViewStack>
   <mx:Script><![CDATA[
 
       import net.systemeD.halcyon.connection.*;
@@ -51,7 +65,7 @@
 
       private function closeBug():void {
             if (layer is BugLayer) {
-              BugLayer(layer).closeBug(selectedEntity as Marker);
+              BugLayer(layer).closeBug(selectedEntity as Marker, nickName.text, closeComment.text);
             }
       }
       ]]>