Add potlatch2.BugLayer to extend VectorLayer and have added functions for storing...
authorAndy Allan <gravitystorm@gmail.com>
Wed, 17 Nov 2010 13:03:38 +0000 (13:03 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 17 Nov 2010 13:03:38 +0000 (13:03 +0000)
net/systemeD/potlatch2/BugLayer.as [new file with mode: 0644]
net/systemeD/potlatch2/utils/BugLoader.as

diff --git a/net/systemeD/potlatch2/BugLayer.as b/net/systemeD/potlatch2/BugLayer.as
new file mode 100644 (file)
index 0000000..420d687
--- /dev/null
@@ -0,0 +1,42 @@
+package net.systemeD.potlatch2 {
+
+    import net.systemeD.halcyon.VectorLayer;
+    import net.systemeD.halcyon.Map;
+    import net.systemeD.halcyon.connection.Marker;
+    import flash.net.*;
+    import flash.events.*;
+
+    public class BugLayer extends VectorLayer {
+
+        private var baseUrl:String;
+        private var apiKey:String;
+
+        // as strings, since that's how they are in tags and http calls
+        private var BUG_STATUS_OPEN:String = "1";
+        private var BUG_STATUS_FIXED:String = "2";
+        private var BUG_STATUS_INVALID:String = "3"; // or 'non-reproduceable'
+
+        public function BugLayer(n:String, map:Map, s:String, baseUrl:String, apiKey:String) {
+            this.baseUrl = baseUrl;
+            this.apiKey = apiKey;
+            super(n,map,s);
+        }
+
+        public function closeBug(m:Marker):void {
+            var id:String = m.getTag('bug_id');
+            var status:String = BUG_STATUS_FIXED;
+            var comment:String = "no comment";
+            var nickname:String = "NoName";
+
+            //TODO make this a post request
+            var loader:URLLoader = new URLLoader();
+            loader.load(new URLRequest(baseUrl+"changeBugStatus?&id="+id+"&status="+status+"&comment="+comment+"&nickname="+nickname+"&key="+apiKey));
+            loader.addEventListener(Event.COMPLETE, bugClosed);
+        }
+
+        private function bugClosed(event:Event):void {
+            trace("bug closed");
+            // remove it from the layer, redraw, fix selection etc.
+        }
+    }
+}
index a6dddf7..fcbc2a4 100644 (file)
@@ -3,6 +3,7 @@ package net.systemeD.potlatch2.utils {
     import net.systemeD.halcyon.Map;
     import net.systemeD.halcyon.VectorLayer;
     import net.systemeD.halcyon.connection.Marker;
+    import net.systemeD.potlatch2.BugLayer;
     import flash.net.*;
     import flash.events.*;
     import com.adobe.serialization.json.JSON;
@@ -52,7 +53,7 @@ package net.systemeD.potlatch2.utils {
         private function get layer():VectorLayer {
             if (!_layer) {
                 var n:String='Bugs';
-                _layer=new VectorLayer(n,map,STYLESHEET);
+                _layer=new BugLayer(n,map,STYLESHEET,bugBaseURL,bugApiKey);
                 map.addVectorLayer(_layer);
             }
             return _layer;