changeset 67:b6aa7b77d110

work on saving and loading maps
author casties
date Fri, 12 Nov 2010 12:08:24 +0100
parents da0556e4fa10
children 49fb47bbe2e6
files gis_gui/blocks/home.html.pt gis_gui/blocks/home.js gis_gui/blocks/map.js
diffstat 3 files changed, 48 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gis_gui/blocks/home.html.pt	Tue Nov 09 21:21:14 2010 +0100
+++ b/gis_gui/blocks/home.html.pt	Fri Nov 12 12:08:24 2010 +0100
@@ -169,6 +169,15 @@
       <input type="button" value="Open" class="open_open_layer"/> 
     </div>
 
+    <div class="subscreen open_map" style="display:none">
+      <select size="8">
+        <option> loading... </option>
+      </select> <br/>
+      <!-- <input type="text" value="Filter" style="color: grey;"/>
+      <br/><br/> -->
+      <input type="button" value="Open" class="open_open_map"/> 
+    </div>
+
  </tal:block>
   
 </tal:block>
\ No newline at end of file
--- a/gis_gui/blocks/home.js	Tue Nov 09 21:21:14 2010 +0100
+++ b/gis_gui/blocks/home.js	Fri Nov 12 12:08:24 2010 +0100
@@ -58,9 +58,31 @@
     });
     
     homeblock.find(".open_map_button").live("click", function(){
-    	clearAllTasks();
-    	foldBlock($(this).parents().filter(".block"));
-    	addBlock("blocks/map?title=map","map");
+        homeblock.find(".open_map_button").addClass("selected");
+        // load list of maps 
+        var el = homeblock.find(".subscreen.open_map select").get(0);
+        blocks.loadListOfItems("test1","map",function(data) {
+            console.debug("open map list of items=",data);
+            $(el).empty();
+            for (var i=0; i < data.length; i++) {
+                var key = data[i].key;
+                var val = data[i].val;
+                var name = val.name;
+                console.debug("map",i," key=",key," value=",name);
+                $(el).append('<option value="'+key+'">'+name+'</option>');
+            }
+            // arm load map button
+            homeblock.find(".open_open_map").unbind("click");
+            homeblock.find(".open_open_map").click(function() {
+                clearAllTasks();
+                foldBlock($(this).parents().filter(".block"));
+                var mapname = $(this).parent().find("select").val();
+                var params = jQuery.grep(data, function(x){return (x.key == mapname);})[0].val;
+                console.debug("open map=",mapname," params=",params);
+                var newblock = blocks.addMapBlock("blocks/map.html?table="+escape(params.table),"map", params);
+            });
+        });
+        homeblock.find(".subscreen.open_map").fadeIn();
     });
 
     // open subtasks
--- a/gis_gui/blocks/map.js	Tue Nov 09 21:21:14 2010 +0100
+++ b/gis_gui/blocks/map.js	Fri Nov 12 12:08:24 2010 +0100
@@ -1,11 +1,13 @@
 
-guiBlocks.prototype.addMapBlock = function(url, baseId, firstLayer) {
-    var block = this.addBlock(url, baseId, function() {
+guiBlocks.prototype.addMapBlock = function(url, baseId, params, firstLayer) {
+    var block = this.addBlock(url, baseId, params, function() {
         // function after add block finished
+        console.debug("in mapblock after block load!");
         var be = block.element;
-        console.debug("in mapblock after block load!");
-        block.params.map_layers = [];
-        if (typeof(firstLayer) != "undefined") {
+        block.type = "map";
+        params.type = "map";
+        params.map_layers = [];
+        if (typeof(firstLayer) != null) {
             block.appendMapLayer(firstLayer);
         }
         
@@ -17,7 +19,7 @@
         //params = block.readLayerParams();
         
         // load map
-        block.updateMap(be,block.params);
+        block.updateMap(be,params);
         
         // add layer button
         $(be).find(".layer_add_button").click(function() {
@@ -31,6 +33,12 @@
             params = block.readMapParams();
             block.updateMap(be,params);
         });
+        // save button
+        $(be).find(".map_save_button").click(function() {
+            console.debug("map save. this=",this," block=",block);
+            params = block.readMapParams(be,params);
+            block.storeBlock("test1");
+        });
     });
 };