Expand the explanatory text. Wrap the s:RichText in a spark group in order to get...
[potlatch2.git] / net / systemeD / potlatch2 / panels / BackgroundPanel.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!--
4     Background 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     xmlns:s="library://ns.adobe.com/flex/spark"
11     height="100%">
12   <s:RichText id="backgroundPanelText" text="You have selected a Background Feature." />
13   <s:RichText text="{connectionName}" />
14   <mx:DataGrid editable="false" id="backgroundPanelDG" width="100%" height="50%">
15     <mx:columns>
16       <mx:DataGridColumn editable="false" dataField="key" headerText="key" />
17       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
18     </mx:columns>
19   </mx:DataGrid>
20   <mx:ViewStack id="statusStack" resizeToContent="true" width="100%">
21     <mx:VBox id="empty" />
22     <mx:VBox id="not_complete" width="100%">
23       <s:VGroup width="100%">
24         <s:RichText width="100%">If all the information from this feature is accounted for in the main layer, you can mark this feature as 'complete'.</s:RichText>
25         <s:RichText width="100%">This lets other contributors see what still needs reconciling.</s:RichText>
26         <mx:Button label="Mark feature as Complete" click="markComplete()"/>
27       </s:VGroup>
28     </mx:VBox>
29     <mx:VBox id="complete" width="100%">
30       <s:VGroup width="100%">
31         <s:RichText width="100%">This feature has been marked as 'complete'. If this is incorrect, and there is still reconciling required, you can mark this feature as 'not complete'.</s:RichText>
32         <mx:Button label="Mark feature as Not complete" click="markNotComplete()"/>
33       </s:VGroup>
34     </mx:VBox>
35   </mx:ViewStack>
36   <fx:Script><![CDATA[
37
38       import net.systemeD.halcyon.connection.*;
39       import net.systemeD.potlatch2.utils.SnapshotConnection;
40       import mx.collections.*;
41
42       private var selectedEntity:Entity;
43       private var tagDataProvider:ArrayCollection;
44       [Bindable]
45       private var connectionName:String;
46
47       public function init(entity:Entity):void {
48           if ( tagDataProvider == null ) {
49               tagDataProvider = new ArrayCollection();
50               backgroundPanelDG.dataProvider = tagDataProvider;
51           }
52
53           selectedEntity=entity;
54           selectedEntity.addEventListener(Connection.STATUS_CHANGED, statusEvent, false, 0, true);
55           connectionName = selectedEntity.connection.name;
56           setStatusStack();
57           updateTagDataProvider();
58       }
59
60       private function updateTagDataProvider():void {
61           tagDataProvider.removeAll();
62           if (selectedEntity==null) { return; }
63           var tags:Array = selectedEntity.getTagArray();
64           tags.sortOn("key");
65           for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
66       }
67
68       private function statusEvent(e:Event):void {
69             setStatusStack();
70       }
71
72       private function setStatusStack():void {
73           switch (selectedEntity.status) {
74               case 'incomplete':
75                   statusStack.selectedChild = not_complete;
76                   break;
77               case 'complete':
78                   statusStack.selectedChild = complete;
79                   break;
80               default:
81                   statusStack.selectedChild = empty;
82           }
83       }
84
85       private function markComplete():void {
86           if (selectedEntity.connection is SnapshotConnection) {
87               SnapshotConnection(selectedEntity.connection).markComplete(selectedEntity);
88           }
89       }
90
91       private function markNotComplete():void {
92           if (selectedEntity.connection is SnapshotConnection) {
93               SnapshotConnection(selectedEntity.connection).markNotComplete(selectedEntity);
94           }
95       }
96       ]]>
97   </fx:Script>
98 </mx:VBox>