Add nickname (with character restrictions) and comment fields when closing bug
[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%">
8   <mx:Text id="markerPanelText" text="You have selected a BUG!!1!." width="100%" styleName="helpInfo" />
9   <mx:DataGrid editable="false" id="markerPanelDG" width="100%" height="50%">
10     <mx:columns>
11       <mx:DataGridColumn editable="false" dataField="key" headerText="key" />
12       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
13     </mx:columns>
14   </mx:DataGrid>
15   <mx:ViewStack id="bugControlStack" resizeToContent="true">
16     <mx:HBox id="bugControl" horizontalAlign="right" width="100%" visible="false">
17       <mx:LinkButton label="Add Comment" enabled="false" />
18       <mx:LinkButton label="Close Bug" click="bugControlStack.selectedChild=closeBugVBox;" />
19     </mx:HBox>
20
21     <mx:VBox id="closeBugVBox" visible="false">
22       <mx:Text><mx:text>Add your comment and close the bug</mx:text></mx:Text>
23       <mx:Label><mx:text>NickName</mx:text></mx:Label>
24       <mx:TextInput id="nickName" restrict="a-zA-Z0-9.\-_"/>
25       <mx:Text><mx:text>Comment form</mx:text></mx:Text>
26       <mx:TextArea id="closeComment" />
27       <mx:HBox horizontalAlign="right" width="100%">
28           <mx:LinkButton label="Cancel" click="bugControlStack.selectedChild=bugControl;" />
29           <mx:LinkButton label="Close Bug" click="closeBug()" />
30       </mx:HBox>
31     </mx:VBox>
32   </mx:ViewStack>
33   <mx:Script><![CDATA[
34
35       import net.systemeD.halcyon.connection.*;
36       import net.systemeD.halcyon.VectorLayer;
37       import net.systemeD.potlatch2.BugLayer;
38       import mx.collections.*;
39
40       private var selectedEntity:Entity;
41       private var tagDataProvider:ArrayCollection;
42       private var layer:VectorLayer;
43
44       public function init(entity:Entity, layer:VectorLayer):void {
45             this.layer = layer;
46             if ( tagDataProvider == null ) {
47                 tagDataProvider = new ArrayCollection();
48                 markerPanelDG.dataProvider = tagDataProvider;
49             }
50
51             selectedEntity=entity;
52             updateTagDataProvider();
53             if (layer is BugLayer) {
54               bugControl.visible = true;
55             }
56       }
57
58       private function updateTagDataProvider():void {
59             tagDataProvider.removeAll();
60             if (selectedEntity==null) { return; }
61             var tags:Array = selectedEntity.getTagArray();
62             tags.sortOn("key");
63             for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
64       }
65
66       private function closeBug():void {
67             if (layer is BugLayer) {
68               BugLayer(layer).closeBug(selectedEntity as Marker, nickName.text, closeComment.text);
69             }
70       }
71       ]]>
72   </mx:Script>
73 </mx:VBox>