search page: use <table> for results; restrict set to 20; simplify css / page

This commit is contained in:
Sanj 2011-08-29 17:34:48 +05:30
parent 3808453878
commit fd141fbf82
5 changed files with 57 additions and 13 deletions

View File

@ -61,7 +61,10 @@ class Feature(models.Model):
geom = json.loads(self.geometry.transform(3785, True).geojson) geom = json.loads(self.geometry.transform(3785, True).geojson)
properties = { properties = {
'id': self.id, '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 { return {
'type': 'Feature', 'type': 'Feature',

View File

@ -17,7 +17,7 @@ def search_json(request):
bs = bbox.split(",") bs = bbox.split(",")
bs_param = (float(bs[0]), float(bs[1]), float(bs[2]), float(bs[3]),) 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] features = [f.get_geojson() for f in features_qset]
d = { d = {
'type': 'FeatureCollection', 'type': 'FeatureCollection',

View File

@ -36,13 +36,18 @@ padding-right:8px;
box-shadow: rgba(0,0,0, 0.3) 0px 0px 8px; box-shadow: rgba(0,0,0, 0.3) 0px 0px 8px;
background-color:rgba(254, 254, 254, 0.9);*/ background-color:rgba(254, 254, 254, 0.9);*/
border-radius:8px; border-radius:8px;
/*
-moz-box-shadow:inset 2px 2px 8px 1px #aca7a7; -moz-box-shadow:inset 2px 2px 8px 1px #aca7a7;
-webkit-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; box-shadow:inset 2px 2px 8px 1px #aca7a7;
border:1px solid #c8c6c6; border:1px solid #c8c6c6;
-moz-border-radius:16px; -moz-border-radius:16px;
-webkit-border-radius:16px; -webkit-border-radius:16px;
border-radius:20px;} border-radius:20px;
*/
}
.search input:focus .search input:focus
{outline:none; {outline:none;

View File

@ -20,7 +20,8 @@ $(function() {
'bbox': bbox, 'bbox': bbox,
'search': search_term 'search': search_term
}, function(features) { }, function(features) {
$('#mapList').empty(); $('#mapList tbody').empty();
// var headerRow = getHeaderRow();
// console.log(response); // console.log(response);
var currFeatures = jsonLayer.features; var currFeatures = jsonLayer.features;
jsonLayer.removeFeatures(currFeatures); jsonLayer.removeFeatures(currFeatures);
@ -28,15 +29,33 @@ $(function() {
for (var i=0; i<features.features.length;i++) { for (var i=0; i<features.features.length;i++) {
var f = features.features[i]; var f = features.features[i];
var props = f.properties; var props = f.properties;
var listItem = getLi(props); var listItem = getRow(props);
$('#mapList').append(listItem); $('#mapList tbody').append(listItem);
} }
}); });
}); });
}); });
function getRow(props) {
var $tr = $('<tr />');
var $one = $('<td />').appendTo$($tr);
var $a = $('<a />').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one);
$('<td />').text(props.feature_type).appendTo($tr);
$('<td />').text(props.admin1).appendTo($tr);
$('<td />').text(props.admin2).appendTo($tr);
return $tr;
}
/*
function getLi(props) { function getLi(props) {
var $li = $('<li />').addClass("mapListItem").attr("data-id", props.id); var $li = $('<li />').addClass("mapListItem").attr("data-id", props.id);
var $a = $('<a />').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($li); var $a = $('<a />').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($li);
return $li; return $li;
} }
*/
function getHeaderRow() {
var heads = ['Preferred Name', 'Feature Type', 'State', 'County']
var $thead = $('<thead />');
}

View File

@ -35,8 +35,24 @@
<div class="mapListSection"> <div class="mapListSection">
<ul class="mapList" id="mapList"> <table id="mapList">
<thead>
<tr>
<td>Preferred Name</td>
<td>Feature Type</td>
<td>State</td>
<td>County</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<!-- <!--
<ul class="mapList" id="mapList">
<li>Water Well Imagery</li> <li>Water Well Imagery</li>
<li>Chicago in the 20s</li> <li>Chicago in the 20s</li>
<li>Maps go here</li> <li>Maps go here</li>
@ -47,11 +63,12 @@
<li>Maps go here</li> <li>Maps go here</li>
<li>Maps go here</li> <li>Maps go here</li>
<li>Maps go here</li> <li>Maps go here</li>
-->
</ul>
<ol class="paginate paginateSelected"> <!--ordered would be better in this case, right?--> </ul>
<!-- <li><a href="">&laquo;</a></li> --> -->
<!--
<ol class="paginate paginateSelected">
<li><a href="">&laquo;</a></li>
<li><a href="">1</a></li> <li><a href="">1</a></li>
<li><a href="">2</a></li> <li><a href="">2</a></li>
<li><a href="">3</a></li> <li><a href="">3</a></li>
@ -62,14 +79,14 @@
<li><a href="">8</a></li> <li><a href="">8</a></li>
<li><a href="">9</a></li> <li><a href="">9</a></li>
<li><a href="">10</a></li> <li><a href="">10</a></li>
<!-- <li><a href="">&raquo;</a></li> --> <li><a href="">&raquo;</a></li>
</ol> </ol>
<div class="firstLast"> <div class="firstLast">
<span class="first">First</span> <span class="first">First</span>
<span class="last">Last</span> <span class="last">Last</span>
</div> </div>
-->
</div> </div>
<div class="map" id="map"> <div class="map" id="map">