Add potlatch2.BugLayer to extend VectorLayer and have added functions for storing...
[potlatch2.git] / net / systemeD / potlatch2 / BugLayer.as
1 package net.systemeD.potlatch2 {
2
3     import net.systemeD.halcyon.VectorLayer;
4     import net.systemeD.halcyon.Map;
5     import net.systemeD.halcyon.connection.Marker;
6     import flash.net.*;
7     import flash.events.*;
8
9     public class BugLayer extends VectorLayer {
10
11         private var baseUrl:String;
12         private var apiKey:String;
13
14         // as strings, since that's how they are in tags and http calls
15         private var BUG_STATUS_OPEN:String = "1";
16         private var BUG_STATUS_FIXED:String = "2";
17         private var BUG_STATUS_INVALID:String = "3"; // or 'non-reproduceable'
18
19         public function BugLayer(n:String, map:Map, s:String, baseUrl:String, apiKey:String) {
20             this.baseUrl = baseUrl;
21             this.apiKey = apiKey;
22             super(n,map,s);
23         }
24
25         public function closeBug(m:Marker):void {
26             var id:String = m.getTag('bug_id');
27             var status:String = BUG_STATUS_FIXED;
28             var comment:String = "no comment";
29             var nickname:String = "NoName";
30
31             //TODO make this a post request
32             var loader:URLLoader = new URLLoader();
33             loader.load(new URLRequest(baseUrl+"changeBugStatus?&id="+id+"&status="+status+"&comment="+comment+"&nickname="+nickname+"&key="+apiKey));
34             loader.addEventListener(Event.COMPLETE, bugClosed);
35         }
36
37         private function bugClosed(event:Event):void {
38             trace("bug closed");
39             // remove it from the layer, redraw, fix selection etc.
40         }
41     }
42 }