Integrating search functionality from AntTheLimey
[potlatch2.git] / net / systemeD / potlatch2 / find / FindDialog.mxml
index 20c11cb666abc5f691cbb309cd0269cc283c390f..e54cc1cabacc811f928ba09c91a819bb3b8a8d18 100644 (file)
@@ -2,8 +2,8 @@
 <mx:TitleWindow
        xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout="vertical" showCloseButton="true"
-       horizontalAlign="center" title="Find a place in OpenStreetMap (powered by Nominatim Search)"
-       width="458" height="350" verticalGap="0">
+       horizontalAlign="center" title="Search"
+       width="458" height="350" verticalGap="0" creationComplete="txtFind.setFocus()">
        <mx:Script><![CDATA[
         import flash.events.Event;
                import mx.core.Application;
@@ -18,7 +18,7 @@
                import net.systemeD.halcyon.Globals;
                
                private var nominatim:HTTPService = new HTTPService;
-               private var nominatimURL:String = "http://open.mapquestapi.com/nominatim/v1/search?";
+               private var nominatimURL:String = "http://open.mapquestapi.com/nominatim/v1/search?";   // ** FIXME - this should be user-configurable
                private var nomOptions:Object = { addressdetails:"1", limit:"10", format:"xml" };
         private var selectedResult:Object = {lat: "0", lon: "0"};
 
                }
                
                private function goneFetched(e:ResultEvent):void {
-                       var resultXML:XML = e.result as XML;
-            var resultList:XMLList = resultXML..place as XMLList;
-                       //Alert.show(resultXML);
-            searchResults = e.result..place as XMLList;
-            var sr2:XMLList = e.result.searchresults as XMLList;
-            var sr3:XMLList = e.result.searchresults.place as XMLList;
+                       searchResults = e.result.* as XMLList;
                }
 
-               protected function btnFind_clickHandler(event:MouseEvent):void
-               {
+               protected function btnFind_clickHandler(event:MouseEvent):void {
                        goFetch(txtFind.text);
                }
 
 
-               protected function txtFind_enterHandler(event:FlexEvent):void
-               {
+               protected function txtFind_enterHandler(event:FlexEvent):void {
                        goFetch(txtFind.text);
                }
 
        ]]>
        </mx:Script>
 
-       <mx:HBox>
-               <mx:TextInput id="txtFind" width="250" enter="txtFind_enterHandler(event)"/>
-               <mx:Button label="Find" id="btnFind" click="btnFind_clickHandler(event)"/>              
+       <mx:HBox horizontalAlign="left" width="100%">
+               <mx:Label text="Search for: " />
+               <mx:TextInput id="txtFind" width="100%" enter="txtFind_enterHandler(event)"/>
+               <mx:Button label="Search" id="btnFind" click="btnFind_clickHandler(event)"/>            
        </mx:HBox>
        
-       <mx:Spacer height="20"/>
+       <mx:Spacer height="10"/>
        
-       <mx:DataGrid id="dgResults" dataProvider="{searchResults}" change="setSelected(event)">
+       <mx:DataGrid id="dgResults" dataProvider="{searchResults}" change="setSelected(event)" width="100%" height="100%">
                <mx:columns>
                        <mx:DataGridColumn headerText="Name" dataField="@display_name" minWidth="200" />
                        <mx:DataGridColumn headerText="Type" dataField="@type"/>
                        <mx:DataGridColumn headerText="Class" dataField="@class"/>            
-                       <mx:DataGridColumn headerText="OSM ID" dataField="@osm_id"/>
+                       <mx:DataGridColumn headerText="ID" dataField="@osm_id"/>
         </mx:columns>
        </mx:DataGrid>
 
     <mx:ControlBar>
+       <mx:Label text="Results from Nominatim" />
         <mx:Spacer width="100%"/>
-        <mx:Button label="Go To" click="goToSelected();" styleName="titleWindowButton" />        
         <mx:Button label="Cancel" click="PopUpManager.removePopUp(this);" styleName="titleWindowButton" />
+        <mx:Button label="Jump to" click="goToSelected();" styleName="titleWindowButton" enabled="{dgResults.selectedItem != null? true : false}" />        
     </mx:ControlBar>
     
-</mx:TitleWindow>
\ No newline at end of file
+</mx:TitleWindow>