Reformat dates. Surprisingly limited options for parsing and displaying dates.
[potlatch2.git] / net / systemeD / potlatch2 / BugLayer.as
index 4ccee609f13aef3e4b0230f014112883efa1ebfa..69dafc8007d32c8b1e81bbe14ca214bdadf7b813 100644 (file)
@@ -14,10 +14,10 @@ package net.systemeD.potlatch2 {
         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'
-        private static const status:Array = ["", "open", "fixed", "invalid"];
+        public static var BUG_STATUS_OPEN:String = "1";
+        public static var BUG_STATUS_FIXED:String = "2";
+        public static var BUG_STATUS_INVALID:String = "3"; // or 'non-reproduceable'
+        public static const status:Array = ["", "open", "fixed", "invalid"];
 
         public function BugLayer(n:String, map:Map, s:String, baseUrl:String, apiKey:String) {
             this.baseUrl = baseUrl;
@@ -25,21 +25,19 @@ package net.systemeD.potlatch2 {
             super(n,map,s);
         }
 
-        public function closeBug(m:Marker, nickname:String = "NoName", comment:String = "No Comment"):void {
+        public function closeBug(m:Marker, nickname:String = "NoName", comment:String = "No Comment", status:String = null):void {
             var id:String = m.getTag('bug_id');
-            var status:String = BUG_STATUS_FIXED;
-
-            //TODO urlencode stuff
+            status ||= BUG_STATUS_FIXED;
             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();
             loader.load(urlReq);
-            loader.addEventListener(Event.COMPLETE, function(e:Event):void { bugClosed(e, m); } );
+            loader.addEventListener(Event.COMPLETE, function(e:Event):void { bugClosed(e, m, status); } );
         }
 
-        private function bugClosed(event:Event, marker:Marker):void {
-            var action:UndoableEntityAction = new SetTagAction(marker, "status", status[int(BUG_STATUS_FIXED)]);
+        private function bugClosed(event:Event, marker:Marker, s:String):void {
+            var action:UndoableEntityAction = new SetTagAction(marker, "status", status[int(s)]);
             action.doAction(); // just do it, don't add to undo stack
         }
 
@@ -69,7 +67,7 @@ package net.systemeD.potlatch2 {
                 tags["date_updated"] = feature.properties.date_updated;
                 tags["source"] = feature.properties.source;
                 tags["status"] = status[int(feature.properties.status)];
-                var marker:Marker = createMarker(tags, lat, lon);
+                var marker:Marker = createMarker(tags, lat, lon, Number(feature.id));
               }
               paint.updateEntityUIs(getObjectsByBbox(map.edge_l,map.edge_r,map.edge_t,map.edge_b), true, false);
             }