Skip to content
This repository
Browse code

Merge branch 'master' of git://github.com/hemebond/eden

  • Loading branch information...
commit 764df2ecd246e5c2795fb80dd551f5aed205ed04 2 parents 8aa5f4c + 35880c3
Fran Boon authored
14 modules/s3/s3search.py
@@ -803,17 +803,19 @@ def widget(self, resource, vars):
803 803
804 804 # Button to open the Map
805 805 OPEN_MAP = T("Open Map")
806   - map_button = A(OPEN_MAP,
807   - _style="cursor:pointer; cursor:hand",
808   - _id="gis_search_map-btn")
  806 + CLEAR_MAP = T("Clear selection")
  807 + map_buttons = TAG[""](BUTTON(OPEN_MAP,
  808 + _id="gis_search_map-btn"),
  809 + BUTTON(CLEAR_MAP,
  810 + _id="gis_search_polygon_input_clear"))
809 811
810 812 # Settings to be read by static/scripts/S3/s3.gis.js
811   - js_location_search = """S3.gis.draw_polygon = true;"""
  813 + js_location_search = "S3.gis.draw_polygon = true;"
812 814
813 815 # The overall layout of the components
814 816 return TAG[""](
815 817 polygon_input,
816   - map_button,
  818 + map_buttons,
817 819 #map_popup,
818 820 SCRIPT(js_location_search)
819 821 )
@@ -2379,7 +2381,7 @@ def search_json(self, r, **attr):
2379 2381
2380 2382 resource.add_filter(query)
2381 2383
2382   - limit = int(_vars.limit or 0)
  2384 + limit = int(_vars.limit or MAX_SEARCH_RESULTS)
2383 2385 if (not limit or limit > MAX_SEARCH_RESULTS) and resource.count() > MAX_SEARCH_RESULTS:
2384 2386 output = jsons([dict(id="",
2385 2387 name="Search results are over %d. Please input more characters." \
10 static/scripts/S3/S3.js
@@ -113,6 +113,16 @@ $(document).ready(function() {
113 113 $('.confirmation').click(function() { $(this).fadeOut('slow'); return false; });
114 114 $("input[type='checkbox'].delete").click(function() { if(this.checked) if(!confirm(S3.i18n.delete_confirmation)) this.checked=false; });
115 115
  116 + // If a form is submitted with errors, this will scroll
  117 + // the window to the first form error message
  118 + inputErrorId = $('form .error[id]').eq(0).attr('id');
  119 + if (inputErrorId != undefined) {
  120 + inputName = inputErrorId.replace("__error", "");
  121 + inputId = $('[name=' + inputName + ']').attr('id');
  122 + inputLabel = $('[for=' + inputId + ']');
  123 + window.scrollTo(0, inputLabel.offset().top)
  124 + }
  125 +
116 126 // T2 Layer
117 127 //try { $('.zoom').fancyZoom( {
118 128 // scaleImg: true,
8 static/scripts/S3/s3.dataTables.js
@@ -524,7 +524,7 @@ $(document).ready(function() {
524 524
525 525 /****************************************************************/
526 526 /* Helper function to add the new group row */
527   - /****************************************************************/
  527 + /****************************************************************/
528 528 function addNewGroup(t,
529 529 sGroup,
530 530 level,
@@ -614,7 +614,7 @@ $(document).ready(function() {
614 614
615 615 /*********************************************************************
616 616 * Function to group the data
617   - *
  617 + *
618 618 * @param oSettings the dataTable settings
619 619 * @param t the index of the table
620 620 * @param group The index of the colum that will be grouped
@@ -1020,7 +1020,9 @@ Ext.onReady(function(){
1020 1020 }
1021 1021 var s3_search_mapButton = Ext.get('gis_search_map-btn');
1022 1022 if (s3_search_mapButton) {
1023   - s3_search_mapButton.on('click', function() {
  1023 + s3_search_mapButton.on('click', function(evt) {
  1024 + // prevent button submitting the form
  1025 + evt.preventDefault();
1024 1026 // Enable the polygon control
1025 1027 S3.gis.polygonButton.enable();
1026 1028 // @ToDo: Set appropriate Bounds
16 static/scripts/S3/s3.gis.controls.js
@@ -339,7 +339,7 @@ function googleEarthKmlLoaded(object) {
339 339
340 340 // Google Streetview control
341 341 function addGoogleStreetviewControl(toolbar) {
342   - var Clicker = OpenLayers.Class(OpenLayers.Control, {
  342 + var Clicker = OpenLayers.Class(OpenLayers.Control, {
343 343 defaults: {
344 344 pixelTolerance: 1,
345 345 stopSingle: true
@@ -348,11 +348,11 @@ function addGoogleStreetviewControl(toolbar) {
348 348 this.handlerOptions = OpenLayers.Util.extend(
349 349 {}, this.defaults
350 350 );
351   - OpenLayers.Control.prototype.initialize.apply(this, arguments);
  351 + OpenLayers.Control.prototype.initialize.apply(this, arguments);
352 352 this.handler = new OpenLayers.Handler.Click(
353 353 this, {click: this.trigger}, this.handlerOptions
354 354 );
355   - },
  355 + },
356 356 trigger: function(event) {
357 357 openStreetviewPopup(map.getLonLatFromViewPortPx(event.xy));
358 358 }
@@ -491,7 +491,7 @@ function addMeasureControls(toolbar) {
491 491 allowDepress: true,
492 492 enableToggle: true
493 493 });
494   -
  494 +
495 495 toolbar.add(areaButton);
496 496 }
497 497 }
@@ -587,7 +587,7 @@ function addPolygonControl(toolbar, polygon_pressed, not_regular) {
587 587 }
588 588 // update Form Field
589 589 var WKT = feature.geometry.transform(S3.gis.projection_current, S3.gis.proj4326).toString();
590   - $('#gis_search_polygon_input').val(WKT);
  590 + $('#gis_search_polygon_input').val(WKT).trigger('change');
591 591 $('#gis_location_wkt').val(WKT);
592 592 // Prepare in case user draws a new polygon
593 593 S3.gis.lastDraftFeature = feature;
@@ -846,13 +846,13 @@ function addRemoveLayersControl() {
846 846 uploadText: S3.i18n.gis_uploadlayer,
847 847 relativeUploadOnly: false
848 848 });
849   -
  849 +
850 850 // @ToDo: Populate this from disabled Catalogue Layers (to which the user has access)
851 851 // Use WMStore for the GeoServer which we can write to?
852 852 // Use current layerStore for Removelayer()?
853 853 //var store = S3.gis.mapPanel.layers;
854 854 var store = new GeoExt.data.LayerStore();
855   -
  855 +
856 856 // Set up shortcuts to allow GXP Plugin to work
857 857 S3.gis.addLayersControl.target = S3.gis.layerTree;
858 858 S3.gis.layerTree.proxy = OpenLayers.ProxyHost; // Required for 'Add a New Server'
@@ -981,7 +981,7 @@ function addLayerPropertiesButton() {
981 981 var pcs = [];
982 982 for (i=0; i < ids.length; i++) {
983 983 q = $('#' + ids[i]).serialize();
984   - if (q) {
  984 + if (q) {
985 985 pcs.push(q);
986 986 }
987 987 }
47 static/scripts/S3/s3.search.js
@@ -279,5 +279,48 @@ $(document).ready(function() {
279 279 });
280 280
281 281 // Activate the Save Search buttons
282   - $('button#save-search').on('click', S3.search.saveCurrentSearch);
283   -});
  282 + $('button#save-search').on('click', S3.search.saveCurrentSearch);
  283 +
  284 + // S3SearchLocationWidget
  285 + // Allow clearing of map polygons in search forms
  286 + $('button#gis_search_polygon_input_clear')
  287 + .on('click', function(event) {
  288 + S3.search.clearMapPolygon();
  289 + // prevent form submission
  290 + event.preventDefault();
  291 + });
  292 + $('input#gis_search_polygon_input')
  293 + .on('change', S3.search.toggleMapClearButton)
  294 + .trigger('change');
  295 + });
  296 +
  297 +/*
  298 + * S3SearchLocationWidget
  299 + *
  300 + * Clears the map widget in a search form and also removes the
  301 + * polygon from the map itself
  302 + */
  303 +S3.search.clearMapPolygon = function() {
  304 + if (S3.gis.lastDraftFeature) {
  305 + S3.gis.lastDraftFeature.destroy();
  306 + }
  307 + $('input#gis_search_polygon_input').val("").trigger('change');
  308 +}
  309 +
  310 +/*
  311 + * S3SearchLocationWidget
  312 + *
  313 + * If the map widget has a value, a clear button will be shown
  314 + * otherwise it is hidden
  315 + */
  316 +S3.search.toggleMapClearButton = function(event) {
  317 + var inputElement = $(event.currentTarget);
  318 + var clearButton = inputElement.siblings('button#gis_search_polygon_input_clear');
  319 +
  320 + if (inputElement.val()) {
  321 + clearButton.show();
  322 + }
  323 + else {
  324 + clearButton.hide();
  325 + }
  326 +}

0 comments on commit 764df2e

Please sign in to comment.
Something went wrong with that request. Please try again.