better Save button detection
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / RouteEditor.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <edit:RelationMemberEditor
3         xmlns:mx="http://www.adobe.com/2006/mxml" 
4         xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
5         xmlns:flexlib="flexlib.controls.*"
6         verticalGap="0"
7         width="100%"
8         toolTip="{fieldDescription}"
9         initialize="addRoutes()">
10
11   <mx:Label text="{fieldName}:"/>
12   <mx:VBox verticalGap="0" width="100%" id="routeIcons"/>
13   <mx:LinkButton label="Add to route" click="addToRelation()" />
14
15   <mx:Script><![CDATA[
16     import net.systemeD.halcyon.connection.*;
17     import net.systemeD.potlatch2.*;
18     import mx.managers.PopUpManager;
19     import mx.core.*;
20    
21     public function addRoutes():void {
22         for each(var relation:Object in matchedRelations) {
23             var icon:RouteIcon = new RouteIcon();
24             icon.setRoute(relation, RouteEditorFactory(_factory).icon);
25             
26             icon.addEventListener(MouseEvent.CLICK, routeClicked);
27             routeIcons.addChild(icon);
28         }
29     }
30     
31     public function routeClicked(event:Event):void {
32         var relation:Object = RouteIcon(event.currentTarget).route;
33         trace(relation+" is clicked");
34         var panel:RelationEditorPanel = RelationEditorPanel(
35             PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
36         panel.setRelation(relation["relation"]);
37         PopUpManager.centerPopUp(panel);
38     }
39
40       public function addToRelation():void {
41           new RelationSelectPanel().init(_entity, _factory.relationTags);        
42       }
43       
44     
45   ]]></mx:Script>
46 </edit:RelationMemberEditor>
47