diff options
-rw-r--r-- | chimere/static/chimere/css/styles.css | 11 | ||||
-rw-r--r-- | chimere/templates/search/search.html | 24 | ||||
-rw-r--r-- | chimere/views.py | 30 | ||||
-rw-r--r-- | version.py | 2 |
4 files changed, 49 insertions, 18 deletions
diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css index 23ed5f7..fb37249 100644 --- a/chimere/static/chimere/css/styles.css +++ b/chimere/static/chimere/css/styles.css @@ -1333,10 +1333,19 @@ table.inline-table td input[type=file]{ list-style-type:none; margin:0; padding:4px; - padding-bottom: 70px; overflow: auto; } +.result-category-name{ + font-size: 1.1em; + padding-top: 0.2em; + display: inline-block; +} + +#search-listing > ul{ + padding-bottom: 70px; +} + #search-listing ul li{ padding: 0; } diff --git a/chimere/templates/search/search.html b/chimere/templates/search/search.html index 6539700..ff013fd 100644 --- a/chimere/templates/search/search.html +++ b/chimere/templates/search/search.html @@ -8,11 +8,25 @@ var end_do_you_mean = "{% trans '?' %}"; <div id='search-listing'> <ul> {% for result in results %} - <li> - <a href="#" onclick="$('#main-map').chimere('showPopup', '{{result.properties.key}}');return false;"> - <img src='{{MEDIA_URL}}{{result.properties.icon_path}}'/>{{ result.properties.name }} - </a> - </li> + {% ifchanged result.properties.category_name %} + {% if not forloop.first %} + </ul> + </li> + {% endif %} + <li> + <img src='{{MEDIA_URL}}{{result.properties.icon_path}}'/> + <span class="result-category-name">{{result.properties.category_name}}</span> + <ul> + {% endifchanged %} + <li> + <a href="#" onclick="$('#main-map').chimere('showPopup', '{{result.properties.key}}');return false;"> + {{ result.properties.name }} + </a> + </li> + {% if forloop.last %} + </ul> + </li> + {% endif %} {% empty %} <li>{% trans "No results found." %}</li> {% endfor %} diff --git a/chimere/views.py b/chimere/views.py index f6014b2..cdf9b42 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -1369,21 +1369,29 @@ class SearchView(FormView): start = (page - 1) * self.results_per_page end = page * self.results_per_page - 1 for model in [models.Marker, models.Route, models.Polygon]: - if len(results) > end - len(results): - continue res, _has_next = model.search( query, area=area, get_json=True, - slice=[start, end], check_next=True) - if _has_next: - has_next = True - if res: - if start: - end = end - start - start = 0 - end -= len(res) results += res - return results, has_next + duplicate_res = [] + for r in results: + extra_icons = [] + if 'extra_icons' in r['properties']: + extra_icons = r['properties']['extra_icons'] + duplicate_res.append(r) + for extra_icon in extra_icons: + data = r.copy() + data['properties'] = r['properties'].copy() + data['properties'].update(extra_icon) + duplicate_res.append(data) + results = list( + sorted(duplicate_res, + key=lambda x: (x['properties']['category_name'], + x['properties']['name'])) + ) + if len(results) <= start: + return [], False + return results[start:end], len(results) > end def get_context_data(self, **kwargs): context = super(SearchView, self).get_context_data(**kwargs) @@ -1,4 +1,4 @@ -VERSION = (3, 1, 12) +VERSION = (3, 1, 13) def get_version(): |