Skip to content

Commit

Permalink
[#2778] Tidy up the apps dashboard
Browse files Browse the repository at this point in the history
 * Update the markup to meet coding standards.
 * Move the filters to the sidebar to give them more space.
 * Display a message when there are no apps to view.
 * Added a breadcrumb.
 * Move select box options into the controller.
 * Attempted to reduce duplication in the controllers.
  • Loading branch information
aron committed Aug 1, 2012
1 parent b5db51f commit a555231
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 51 deletions.
28 changes: 21 additions & 7 deletions ckan/controllers/related.py
Expand Up @@ -65,6 +65,13 @@ def pager_url(q=None, page=None):

c.filters = dict(params_nopage)

c.type_options = self._type_options()
c.sort_options = ({'value': '', 'text': _('Most viewed')},
{'value': 'view_count_desc', 'text': _('Most Viewed')},
{'value': 'view_count_asc', 'text': _('Least Viewed')},
{'value': 'created_desc', 'text': _('Newest')},
{'value': 'created_asc', 'text': _('Oldest')})

return base.render( "related/dashboard.html")

def read(self, id):
Expand Down Expand Up @@ -188,13 +195,7 @@ def _edit_or_new(self, id, related_id, is_edit):
if is_edit:
data = related

c.types = (
{"text": "Application", "value": "application"},
{"text": "Idea", "value": "idea"},
{"text": "News Article", "value": "news_article"},
{"text": "Paper", "value": "paper"},
{"text": "Visualization", "value": "visualization"}
)
c.types = self._type_options()

c.pkg_id = id
vars = {'data': data, 'errors': errors, 'error_summary': error_summary}
Expand Down Expand Up @@ -227,3 +228,16 @@ def delete(self, id, related_id):
except logic.NotFound:
base.abort(404, _('Related item not found'))
return base.render('related/confirm_delete.html')

def _type_options(self):
'''
A tuple of options for the different related types for use in
the form.select() template macro.
'''
return ({"text": _("API"), "value": "api"},
{"text": _("Application"), "value": "application"},
{"text": _("Idea"), "value": "idea"},
{"text": _("News Article"), "value": "news_article"},
{"text": _("Paper"), "value": "paper"},
{"text": _("Post"), "value": "post"},
{"text": _("Visualization"), "value": "visualization"})
15 changes: 15 additions & 0 deletions ckan/public/base/css/main.css
Expand Up @@ -5125,6 +5125,17 @@ textarea {
.form-inline .btn {
margin-left: 5px;
}
.form-narrow label {
margin-bottom: 0;
}
.form-narrow select {
width: 100%;
}
.form-narrow .form-actions {
margin-left: -15px;
margin-right: -15px;
padding: 10px 15px 0;
}
.form-select label {
margin-right: 5px;
}
Expand Down Expand Up @@ -7076,6 +7087,10 @@ li .icon-large:before {
border-bottom: 1px solid #cccccc;
margin: 0 -12px;
}
.activity:last-of-type {
border-bottom: none;
padding-bottom: 0;
}
.activity .actor img {
margin-top: -2px;
margin-right: 5px;
Expand Down
16 changes: 16 additions & 0 deletions ckan/public/base/less/forms.less
Expand Up @@ -169,6 +169,22 @@ textarea {
margin-left: 5px;
}

// Form Narrow

.form-narrow label {
margin-bottom: 0;
}

.form-narrow select {
width: 100%;
}

.form-narrow .form-actions {
margin-left: -@gutterSmallX;
margin-right: -@gutterSmallX;
padding: 10px @gutterSmallX 0;
}

// Inline Select Forms

.form-select label {
Expand Down
109 changes: 65 additions & 44 deletions ckan/templates/related/dashboard.html
@@ -1,63 +1,84 @@
{% extends "page.html" %}

{% set page = c.page %}
{% set item_count = c.page.item_count %}

{% block title %}{{ _('Apps & Ideas') }} - {{ super() }}{% endblock %}

{% block breadcrumb_content %}
<li class="active">{{ _('Apps & Ideas') }}</li>
{% endblock %}

{% block primary %}
{% block primary_content %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Apps & Ideas') }}</h1>
{% if c.page.item_count %}

<h4>Showing items <strong>{{c.page.first_item}} - {{c.page.last_item}}</strong> of <strong>{{c.page.item_count}}</strong> related items found</h4>
{% if item_count %}
{% trans first=page.first_item, last=page.last_item, item_count=item_count %}
<p>Showing items <strong>{{ first }} - {{ item }}</strong> of <strong>{{ item_count }}</strong> related items found</p>
{% endtrans %}
{% elif c.filters.type %}
{% trans item_count=item_count %}
<p><strong>{{ item_count }}</strong> related items found</p>
{% endtrans %}
{% else %}
<h4><strong>{{c.page.item_count}}</strong> related items found</h4>
<p class="empty">{{ _('There have been no apps submitted yet.') }}
{% endif %}

<div class="well">
<form action="" method="get" class="form-inline">
<input type='hidden' name='page' value='1'/>

<label for="type">Filter by type</label>
<select name="type">
<option value="">All</option>
<option value="api" {% if c.filters.get('type') == 'api' %} selected="selected"{% endif %}>API</option>
<option value="application" {% if c.filters.get('type') == 'application' %} selected="selected"{% endif %}>Application</option>
<option value="idea" {% if c.filters.get('type') == 'idea' %} selected="selected"{% endif %}>Idea</option>
<option value="news-article" {% if c.filters.get('type') == 'news-article' %} selected="selected"{% endif %}>News Article</option>
<option value="paper" {% if c.filters.get('type') == 'paper' %} selected="selected"{% endif %}>Paper</option>
<option value="post" {% if c.filters.get('type') == 'post' %} selected="selected"{% endif %}>Post</option>
<option value="visualization" {% if c.filters.get('type') == 'visualization' %} selected="selected"{% endif %}>Visualization</option>
</select>

<label for="sort">Sort by</label>
<select name="sort">
<option value="">Default</option>
<option value="view_count_desc" {% if c.filters.get('sort') == 'view_count_desc' %} selected="selected"{% endif %}>Most viewed</option>
<option value="view_count_asc" {% if c.filters.get('sort') == 'view_count_asc' %} selected="selected"{% endif %}>Least viewed</option>

<option value="created_desc" {% if c.filters.get('sort') == 'on' %} selected="selected"{% endif %}>Newest</option>
<option value="created_asc" {% if c.filters.get('sort') == 'created_asc' %} selected="selected"{% endif %}>Oldest</option>

</select>


<label for="featured">Featured items only?</label>
<input type="checkbox" name="featured" {% if c.filters.get('featured') == 'on' %} checked="checked"{% endif %}></input>
<button class="btn btn-primary pull-right">Apply</button>
</form>
{% snippet "related/snippets/related_list.html", related_items=page.items %}
</div>

<ul class="related-items thumbnails">
{% snippet "related/snippets/related_list.html", related_items=c.page.items %}
</ul>

{{c.page.pager()}}

</div>
{{ page.pager() }}
</article>
{% endblock %}

{% block sidebar %}{% endblock %}
{% block secondary_content %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading">{{ _('What are applications?') }}</h2>
<div class="module-content">
{% trans %}
These are applications built with the datasets as well as ideas for
things that could be done with them.
{% endtrans %}
</div>
</section>

<section class="module module-narrow module-shallow">
<h2 class="module-heading">{{ _('Filter Results') }}</h2>
<form action="" method="get" class="module-content form-inline form-narrow">
<input type='hidden' name='page' value='1'/>

<div class="control-group">
<label for="field-type">{{ _('Filter by type') }}</label>
<select id="field-type" name="type">
<option value="">{{ _('All') }}</option>
{% for option in c.type_options %}
<option value="{{ option.value }}"{% if c.filters.type == option.value %} selected="selected"{% endif %}>{{ option.text or option.value }}</option>
{% endfor %}
</select>
</div>

<div class="control-group">
<label for="field-sort">{{ _('Sort by') }}</label>
<select id="field-sort" name="sort">
<option value="">{{ _('Default') }}</option>
{% for option in c.sort_options %}
<option value="{{ option.value }}"{% if c.filters.sort == option.value %} selected="selected"{% endif %}>{{ option.text or option.value }}</option>
{% endfor %}
</select>
</div>

<div class="control-group">
<label for="field-featured" class="checkbox">
<input type="checkbox" id="field-featured" name="featured" {% if c.filters.get('featured') == 'on' %} checked="checked"{% endif %}></input>
{{ _('Only show featured items') }}
</label>
</div>

<div class="form-actions">
<button class="btn btn-primary">{{ _('Apply') }}</button>
</div>
</form>
</section>
{% endblock %}

0 comments on commit a555231

Please sign in to comment.