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