From fd141fbf82c13df6d366898a7376b0dd26ac0c72 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 29 Aug 2011 17:34:48 +0530 Subject: [PATCH] search page: use for results; restrict set to 20; simplify css / page --- gazetteer/places/models.py | 5 ++++- gazetteer/places/views.py | 2 +- gazetteer/static/css/main.css | 7 ++++++- gazetteer/static/js/gazetteer.js | 25 ++++++++++++++++++++++--- gazetteer/templates/search.html | 31 ++++++++++++++++++++++++------- 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/gazetteer/places/models.py b/gazetteer/places/models.py index 7b99a7e..0da0fad 100644 --- a/gazetteer/places/models.py +++ b/gazetteer/places/models.py @@ -61,7 +61,10 @@ class Feature(models.Model): geom = json.loads(self.geometry.transform(3785, True).geojson) properties = { 'id': self.id, - 'preferred_name': self.preferred_name + 'preferred_name': self.preferred_name, + 'feature_type': self.feature_type.name, + 'admin1': self.admin1, + 'admin2': self.admin2 } return { 'type': 'Feature', diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index d9bc9fa..894ba03 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -17,7 +17,7 @@ def search_json(request): bs = bbox.split(",") bs_param = (float(bs[0]), float(bs[1]), float(bs[2]), float(bs[3]),) - features_qset = Feature.search.overlaps(bs_param, text=search_term, srid=3785) + features_qset = Feature.search.overlaps(bs_param, text=search_term, srid=3785)[0:20] features = [f.get_geojson() for f in features_qset] d = { 'type': 'FeatureCollection', diff --git a/gazetteer/static/css/main.css b/gazetteer/static/css/main.css index 2df4be3..72a835f 100644 --- a/gazetteer/static/css/main.css +++ b/gazetteer/static/css/main.css @@ -36,13 +36,18 @@ padding-right:8px; box-shadow: rgba(0,0,0, 0.3) 0px 0px 8px; background-color:rgba(254, 254, 254, 0.9);*/ border-radius:8px; + +/* -moz-box-shadow:inset 2px 2px 8px 1px #aca7a7; -webkit-box-shadow:inset 2px 2px 8px 1px #aca7a7; box-shadow:inset 2px 2px 8px 1px #aca7a7; border:1px solid #c8c6c6; -moz-border-radius:16px; -webkit-border-radius:16px; -border-radius:20px;} +border-radius:20px; +*/ +} + .search input:focus {outline:none; diff --git a/gazetteer/static/js/gazetteer.js b/gazetteer/static/js/gazetteer.js index 1271f29..35ade2f 100644 --- a/gazetteer/static/js/gazetteer.js +++ b/gazetteer/static/js/gazetteer.js @@ -20,7 +20,8 @@ $(function() { 'bbox': bbox, 'search': search_term }, function(features) { - $('#mapList').empty(); + $('#mapList tbody').empty(); +// var headerRow = getHeaderRow(); // console.log(response); var currFeatures = jsonLayer.features; jsonLayer.removeFeatures(currFeatures); @@ -28,15 +29,33 @@ $(function() { for (var i=0; i'); + var $one = $(''); +} diff --git a/gazetteer/templates/search.html b/gazetteer/templates/search.html index b9ab14a..cd1a0c6 100644 --- a/gazetteer/templates/search.html +++ b/gazetteer/templates/search.html @@ -35,8 +35,24 @@
-
').appendTo$($tr); + var $a = $('').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one); + $('').text(props.feature_type).appendTo($tr); + $('').text(props.admin1).appendTo($tr); + $('').text(props.admin2).appendTo($tr); + return $tr; +} + + +/* function getLi(props) { var $li = $('
  • ').addClass("mapListItem").attr("data-id", props.id); var $a = $('').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($li); return $li; } +*/ + +function getHeaderRow() { + var heads = ['Preferred Name', 'Feature Type', 'State', 'County'] + var $thead = $('
  • + + + + + + + + + + + + +
    Preferred NameFeature TypeStateCounty
    + - -
      - + +--> + +
    1. »
    First Last
    - +-->