Skip to content

Commit

Permalink
[2441] Add sort by field to search form
Browse files Browse the repository at this point in the history
  • Loading branch information
aron committed May 29, 2012
1 parent dfecb10 commit 7e280b2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
43 changes: 36 additions & 7 deletions ckan/public/base/less/dataset.less
Expand Up @@ -15,10 +15,14 @@

.dataset-item > .heading {
font-size: 14px;
line-height: 1;
line-height: 1.2;
float: left;
}

.dataset-item > .heading a {
color: #333;
}

.dataset-item > .content {
clear: both;
font-size: 12px;
Expand All @@ -38,17 +42,23 @@
background-color: #aaa;
}

.filter-list {
color: #aaa;
font-weight: bold;
margin-bottom: 20px;
padding-bottom: 10px;
.results {
margin-right: 360px;
border-bottom: 1px dotted #ccc;
margin-bottom: 20px;
padding-bottom: 25px;
}

.filter-list .results {
.results strong {
display: block;
font-size: 24px;
color: #000;
margin-bottom: 10px;
}

.filter-list {
color: #aaa;
font-weight: bold;
}

.filter-list .extra {
Expand All @@ -58,6 +68,10 @@
color: #000;
}

.dataset-search {
position: relative;
}

.search-giant {
position: relative;
}
Expand All @@ -84,6 +98,21 @@
text-indent: -900em;
}

.control-order-by {
position: absolute;
bottom: -60px;
right: 0;
}

.control-order-by label,
.control-order-by select {
display: inline;
}

.control-order-by select {
width: 160px;
}

// Resource List

.resource-list {
Expand Down
2 changes: 1 addition & 1 deletion ckan/public/base/less/module.less
Expand Up @@ -36,7 +36,7 @@
padding-bottom: @gutter-y;
}

.module > .content :last-child {
.module > .content > :last-child {
margin-bottom: 0;
}

Expand Down
39 changes: 24 additions & 15 deletions ckan/templates/package/search.html
Expand Up @@ -22,38 +22,47 @@
<section class="module">
<div class="content">
<form id="dataset-search" class="dataset-search clearfix" method="GET">
<span class="search-giant">
<span class="control-group search-giant">
<input type="text" class="search" name="q" value="${c.q}" autocomplete="off" results="0" placeholder="${_('Search...')}" />
<button type="submit" value="${_('Search')}">Submit</button>
</span>
<span class="control-group control-order-by">
<label for="field-order-by">Order by</label>
<select id="field-order-by" name="sort">
<option selected="selected">Relevance</option>
</select>
</span>
<span py:if="c.fields">
<py:for each="(k, v) in c.fields">
<input type="hidden" name="${k}" value="${v}" />
</py:for>
</span>
<div id="dataset-search-ext"></div>
</form>
<div class="filter-list">
<strong py:choose="" class="results">
<div class="results">
<strong py:choose="">
<py:when test="request.params and c.page.item_count">${c.page.item_count} datasets<py:if test="c.q"> found for &#147;${c.q}&#148;</py:if></py:when>
<py:when test="request.params and c.page.item_count == 0">Sorry no datasets found for &#147;${c.q}&#148;</py:when>
<py:otherwise>All datasets</py:otherwise>
</strong>
<py:for each="field in c.fields_grouped">
<span class="facet">${c.facet_titles.get(field)}:</span>
<py:for each="value in c.fields_grouped[field]">
<span class="filtered pill" py:choose="">
<py:when test="c.translated_fields and c.translated_fields.has_key((field,value))">
<div class="filter-list">
<py:for each="field in c.fields_grouped">
<span class="facet">${c.facet_titles.get(field)}:</span>
<py:for each="value in c.fields_grouped[field]">
<span class="filtered pill" py:choose="">
<py:when test="c.translated_fields and c.translated_fields.has_key((field,value))">
${c.translated_fields[(field,value)]}
</py:when>
<py:otherwise>${value}</py:otherwise>
<a href="${c.remove_field(field, value)}" class="remove icon-remove icon-white">[remove]</a>
</span>
</py:when>
<py:otherwise>${value}</py:otherwise>
<a href="${c.remove_field(field, value)}" class="remove icon-remove icon-white">[remove]</a>
</span>
</py:for>
</py:for>
</py:for>
<p class="extra" py:if="request.params and c.page.item_count == 0">Try another search term,
browse the datasets below or <a href="${h.url_for(action='new', id=None)}">add your own data</a>.</p>
<p class="extra" py:if="request.params and c.page.item_count == 0">Try another search term,
browse the datasets below or <a href="${h.url_for(action='new', id=None)}">add your own data</a>.</p>
</div>
</div>

<py:if test="c.query_error">
<p i18n:msg="item_count"><strong>There was an error while searching.</strong>
Please try again.</p>
Expand Down

0 comments on commit 7e280b2

Please sign in to comment.