Merge https://github.com/openstreetmap/potlatch2
[potlatch2.git] / net / systemeD / potlatch2 / panels / BugPanel.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!--
4     Bug Panel
5 -->
6
7 <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" height="100%" paddingTop="10">
8   <mx:HBox>
9     <mx:Image source="{bugImage}" width="32" height="32" />
10     <mx:Text text="{bugTitle}" fontWeight="bold" fontSize="18" />
11   </mx:HBox>
12   <mx:HBox>
13     <mx:Text text="Created: " />
14     <mx:Text text="{bugCreated.toLocaleString()}" />
15   </mx:HBox>
16   <mx:HBox>
17     <mx:Text text="Updated:" />
18     <mx:Text text="{bugUpdated.toLocaleString()}" />
19   </mx:HBox>
20   <mx:HBox>
21     <mx:Text text="Type of bug: " />
22     <mx:Text text="{bugType}" fontWeight="bold"/>
23   </mx:HBox>
24   <mx:HBox id="bugDetailsHbox" visible="false">
25     <mx:Text fontWeight="bold" text="View full details on website..." click="navigateToURL(new URLRequest(bugDetails), 'potlatch_browse')" />
26   </mx:HBox>
27   <mx:TextArea editable="false" text="{bugDescription}" width="100%" fontSize="14" minHeight="100" maxHeight="400"/>
28
29   <mx:ViewStack id="bugControlStack" resizeToContent="true" width="100%">
30     <mx:HBox id="bugFixed" backgroundColor="#ddffdd" width="100%">
31       <mx:Text text="This bug has been marked as Fixed" width="100%"/>
32     </mx:HBox>
33
34     <mx:HBox id="bugInvalid" backgroundColor="#dddddd" width="100%">
35       <mx:Text text="This bug has been marked as Invalid" width="100%"/>
36     </mx:HBox>
37
38     <mx:HBox id="bugControl" horizontalAlign="right" width="100%">
39       <mx:LinkButton label="Add Comment" enabled="false" />
40       <mx:LinkButton label="Close Bug" click="bugControlStack.selectedChild=closeBugVBox;" />
41     </mx:HBox>
42
43     <mx:VBox id="closeBugVBox" visible="false">
44       <mx:Text><mx:text>Add your comment and close the bug</mx:text></mx:Text>
45       <mx:Label><mx:text>Your NickName (3-16 chars):</mx:text></mx:Label>
46       <mx:TextInput id="nickName" restrict="a-zA-Z0-9.\-_" width="100%"/>
47       <mx:Text><mx:text>Comment:</mx:text></mx:Text>
48       <mx:TextArea id="closeComment" width="100%"/>
49       <mx:Text text="Mark bug as:"/>
50       <mx:RadioButton groupName="status" id="option_fixed" label="Fixed" selected="true"/>
51       <mx:RadioButton groupName="status" id="option_invalid" label="Invalid" />
52       <mx:HBox horizontalAlign="right" width="100%">
53           <mx:LinkButton label="Cancel" click="bugControlStack.selectedChild=bugControl;" />
54           <mx:LinkButton label="Close Bug" click="closeBug()" />
55       </mx:HBox>
56     </mx:VBox>
57   </mx:ViewStack>
58
59   <mx:Script><![CDATA[
60
61       import net.systemeD.halcyon.connection.*;
62       import net.systemeD.potlatch2.BugConnection;
63       import mx.collections.*;
64       import com.adobe.utils.DateUtil;
65
66       private var selectedEntity:Entity;
67       private var connection:BugConnection;
68
69       [Bindable] private var bugId:String;
70       [Bindable] private var bugStatus:String;
71       [Bindable] private var bugDescription:String;
72       [Bindable] private var bugType:String;
73       [Bindable] private var bugImage:String;
74       [Bindable] private var bugTitle:String;
75       [Bindable] private var bugCreated:Date;
76       [Bindable] private var bugUpdated:Date;
77       [Bindable] private var bugDetails:String;
78
79       public function init(entity:Entity, connection:BugConnection):void {
80             this.connection = connection;
81             selectedEntity=entity;
82
83             bugId = selectedEntity.getTag("bug_id");
84             bugTitle = "Bug "+bugId;
85             bugStatus = selectedEntity.getTag("status");
86             bugDescription = selectedEntity.getTag("description");
87             bugType = selectedEntity.getTag("type").replace(/_/g, " ");
88             bugImage = 'features/bugs/'+bugStatus+'.png';
89             bugCreated = DateUtil.parseW3CDTF(selectedEntity.getTag("date_created"));
90             bugUpdated = DateUtil.parseW3CDTF(selectedEntity.getTag("date_updated"));
91
92             if ( bugStatus == BugConnection.status[int(BugConnection.BUG_STATUS_FIXED)] ) {
93               bugControlStack.selectedChild = bugFixed;
94             } else if ( bugStatus == BugConnection.status[int(BugConnection.BUG_STATUS_INVALID)] ) {
95               bugControlStack.selectedChild = bugInvalid;
96             } else {
97               bugControlStack.selectedChild = bugControl;
98             }
99
100             var u:String = connection.bugDetailsUrl(Marker(selectedEntity));
101             if (u) {
102               bugDetails = u;
103               bugDetailsHbox.visible=true;
104             }
105       }
106
107       private function closeBug():void {
108             var status:String = option_invalid.selected ? BugConnection.BUG_STATUS_INVALID : BugConnection.BUG_STATUS_FIXED;
109             trace(status);
110             connection.closeBug(selectedEntity as Marker, nickName.text, closeComment.text, status);
111             bugStatus = selectedEntity.getTag("status");
112             // this should really be a 'saving...' state, with a callback depending on the server result
113             bugControlStack.selectedChild = option_invalid.selected ? bugInvalid : bugFixed;
114       }
115
116       ]]>
117   </mx:Script>
118 </mx:VBox>