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