Skip to content

Commit

Permalink
[#1251] Updates to the resource view admin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Nov 26, 2013
1 parent c78ff4a commit 679f8c8
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 97 deletions.
54 changes: 54 additions & 0 deletions ckan/public/base/less/dataset.less
Expand Up @@ -210,3 +210,57 @@
.label[data-format*=turtle] {
background-color: #0b4498;
}

// Views
.view-list {
.unstyled;
li {
margin-bottom: 10px;
a {
display: block;
min-height: 50px;
padding: 10px;
border: 1px solid @moduleHeadingBorderColor;
overflow: hidden;
.border-radius(3px);
.icon {
float: left;
width: 50px;
height: 50px;
overflow: hidden;
margin-right: 10px;
color: @layoutTextColor;
background-color: @layoutBackgroundColor;
.border-radius(3px);
i {
display: block;
text-align: center;
font-size: 28px;
line-height: 50px;
}
}
h3 {
font-weight: bold;
color: @layoutBoldColor;
font-weight: bold;
font-size: 16px;
margin: 0 0 3px 0;
}
p {
margin: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: @layoutTextColor;
}
&:hover {
text-decoration: none;
border-color: @layoutLinkColor;
.icon {
background-color: @layoutLinkColor;
color: @navActiveBackgroundColor;
}
}
}
}
}
27 changes: 14 additions & 13 deletions ckan/templates/package/edit_view.html
@@ -1,23 +1,24 @@
{% extends "package/view_edit_base.html" %}

{% block subtitle %}{{ _('Add View') }} - {{ h.resource_display_name(c.resource) }}{% endblock %}
{% block form_title %}{{ _('Add view') }}{% endblock %}
{% block subtitle %}{{ _('Edit view') }} - {{ h.resource_display_name(c.resource) }}{% endblock %}
{% block form_title %}{{ _('Edit view') }}{% endblock %}

{% block breadcrumb_content %}
<li class="active"><a href="#">{{ _('Edit View') }}</a></li>
{{ super() }}
<li class="active"><a href="#">{{ _('Edit view') }}</a></li>
{% endblock %}

{% block content_primary_nav %}
<li class="active"><a href="#"><i class="icon-edit"></i> {{ _('Edit view') }}</a></li>
{% endblock %}

{% block form %}
<form class="dataset-form dataset-resource-form form-horizontal" method="post" data-module="basic-form resource-form">
{% include 'package/snippets/view_form.html' %}
<div class="form-actions">
<form class="dataset-form dataset-resource-form form-horizontal" method="post" data-module="basic-form resource-form">
{% include 'package/snippets/view_form.html' %}
<div class="form-actions">
<button class="btn btn-danger pull-left" name="delete" value="Delete"> {{ _('Delete') }} </button>
<button class="btn btn-primary" name="preview" value="True" type="submit">{{ _('Preview Update') }}</button>
<button class="btn" name="preview" value="True" type="submit">{{ _('Preview') }}</button>
<button class="btn btn-primary" name="save" value="Save" type="submit">{{ _('Update') }}</button>
</div>
</form>
{% endblock %}

{% block content_primary_nav %}
<li class="active"><a href="#"><i class="icon-edit"></i> {{ _('Edit View') }}</a></li>
</div>
</form>
{% endblock %}
27 changes: 14 additions & 13 deletions ckan/templates/package/new_view.html
@@ -1,22 +1,23 @@
{% extends "package/view_edit_base.html" %}

{% block subtitle %}{{ _('Add View') }} - {{ h.resource_display_name(c.resource) }}{% endblock %}
{% block subtitle %}{{ _('Add view') }} - {{ h.resource_display_name(c.resource) }}{% endblock %}
{% block form_title %}{{ _('Add view') }}{% endblock %}

{% block breadcrumb_content %}
<li class="active"><a href="#">{{ _('Add New View') }}</a></li>
{{ super() }}
<li class="active"><a href="#">{{ _('Add view') }}</a></li>
{% endblock %}

{% block form %}
<form class="dataset-form dataset-resource-form form-horizontal" method="post" data-module="basic-form resource-form">
{% include 'package/snippets/view_form.html' %}
<div class="form-actions">
<button class="btn btn-primary" name="preview" value="True" type="submit">{{ _('Preview') }}</button>
<button class="btn btn-primary" name="save" value="Save" type="submit">{% block save_button_text %}{{ _('Add') }}{% endblock %}</button>
</div>
</form>
{% block content_primary_nav %}
<li class="active"><a href="#"><i class="icon-edit"></i> {{ _('Add view') }}</a></li>
{% endblock %}

{% block content_primary_nav %}
<li class="active"><a href="#"><i class="icon-edit"></i> {{ _('New View') }}</a></li>
{% endblock %}
{% block form %}
<form class="dataset-form dataset-resource-form form-horizontal" method="post" data-module="basic-form resource-form">
{% include 'package/snippets/view_form.html' %}
<div class="form-actions">
<button class="btn" name="preview" value="True" type="submit">{{ _('Preview') }}</button>
<button class="btn btn-primary" name="save" value="Save" type="submit">{% block save_button_text %}{{ _('Add') }}{% endblock %}</button>
</div>
</form>
{% endblock %}
2 changes: 1 addition & 1 deletion ckan/templates/package/resource_edit_base.html
Expand Up @@ -8,7 +8,7 @@
{% block breadcrumb_content %}
{{ super() }}
<li>{% link_for h.resource_display_name(res)|truncate(30), controller='package', action='resource_read', id=pkg.name, resource_id=res.id %}</li>
<li class="active"><a href="">{{ _('Edit') }}</a></li>
<li{% block breadcrumb_edit_selected %} class="active"{% endblock %}><a href="">{{ _('Edit') }}</a></li>
{% endblock %}

{% block content_action %}
Expand Down
10 changes: 5 additions & 5 deletions ckan/templates/package/resource_read.html
Expand Up @@ -73,11 +73,11 @@ <h3>{{ _('From the dataset abstract') }}</h3>
</div>
</div>
{% block resource_views %}
<div class="resource-views">
{% for resource_view in resource_views %}
{% snippet 'package/snippets/resource_view.html', resource_view=resource_view, resource=c.resource, package=c.package %}
{% endfor %}
</div>
<div class="resource-views" data-module="resource-views">
{% for resource_view in resource_views %}
{% snippet 'package/snippets/resource_view.html', resource_view=resource_view, resource=c.resource, package=c.package %}
{% endfor %}
</div>
{% endblock %}
</section>
{% endblock %}
Expand Down
51 changes: 32 additions & 19 deletions ckan/templates/package/resource_views.html
Expand Up @@ -4,32 +4,45 @@
{% block subtitle %}{{ _('View') }} - {{ h.resource_display_name(res) }}{% endblock %}

{% block page_primary_action %}

<form action={{ h.url_for(controller='package', action='edit_view', id=c.pkg_dict.name, resource_id=c.resource.id) }}>
<select id="field-view_type" name="view_type" data-module="autocomplete">
{% for option in h.get_allowed_view_types(c.resource, c.pkg_dict) %}
<option value="{{ option[0] }}"> {{ option[1] }}</option>
{% endfor %}
</select>
<button class="btn btn-primary" type="submit"> {{ _('New View') }}</button>
</form>

<div class="btn-group">
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-plus-sign-alt"></i>
{{ _('New view') }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% for option in h.get_allowed_view_types(c.resource, c.pkg_dict) %}
{% set url = h.url_for(controller='package', action='edit_view', id=c.pkg_dict.name, resource_id=c.resource.id, view_type=option[0]) %}
<li><a href="{{ url }}">{{ option[1] }}</a></li>
{% endfor %}
</ul>
</div>
{% endblock %}

{% block primary_content_inner %}

<hr>
{% if c.views %}
<ul class="resource-list">
<ul class="view-list">
{% for view in c.views %}
<li>
<a href="{{h.url_for(controller='package', action='edit_view', id=pkg.name, resource_id=view.resource_id, view_id=view.id)}}">
{{ view.title }}
</a>
</li>
{% set icon = view.icon or 'picture' %}
<li>
<a href="{{ h.url_for(controller='package', action='edit_view', id=pkg.name, resource_id=view.resource_id, view_id=view.id) }}">
<span class="icon">
<i class="icon icon-{{ icon }}"></i>
</span>
<h3>{{ view.title }}</h3>
<p class="description">
{% if view.description %}
{{ view.description }}
{% else %}
<span class="empty">No description for this resource</span>
{% endif %}
</p>
</a>
</li>
{% endfor %}
</ul>
{% else %}
<p class="empty">{{ _('This Resource has no Views') }}</p>
<p class="empty">{{ _('This resource has no views') }}</p>
{% endif %}

{% endblock %}
63 changes: 32 additions & 31 deletions ckan/templates/package/snippets/resource_view.html
@@ -1,34 +1,35 @@
<h1 class="resource-view-title">{{resource_view['title']}}</h1>
<div class="resource-view-description">{{resource_view['description']}}</div>

<div class="module-content ckanext-datapreview">
{% if not h.resource_view_is_iframed(resource_view) %}
{{ h.rendered_resource_view(resource_view, resource, package) }}
{% else %}
<div class="data-viewer-error js-hide">
<p class="text-error">
<i class="icon-info-sign"></i>
{{ _('This resource view is not available at the moment.') }}
<a href="#" data-toggle="collapse" data-target="#data-view-error">
{{ _('Click here for more information.') }}
</a>
</p>
<p id="data-view-error" class="collapse"></p>
<p>
<a href="{{ raw_resource_url }}" class="btn btn-large resource-url-analytics" target="_blank">
<i class="icon-large icon-download"></i>
{{ _('Download resource') }}
</a>
</p>
</div>
{% if not to_preview %}
{% set src = h.url(controller='package', action='resource_view', id=package['name'], resource_id=resource['id'], view_id=resource_view['id']) %}
<div class="resource-view" data-title="{{ resource_view['title'] }}" data-description="{{ resource_view['descripion'] }}">
<h1>{{ resource_view['title'] }}</h1>
<p class="desc">{{ resource_view['description'] }}</p>
<div class="ckanext-datapreview">
{% if not h.resource_view_is_iframed(resource_view) %}
{{ h.rendered_resource_view(resource_view, resource, package) }}
{% else %}
{# When previewing we neet to stick the whole resource_view as a param as there is no other way to pass to information on to the iframe #}
{% set src = h.url(controller='package', action='resource_view', id=package['name'], resource_id=resource['id']) + '?' + h.urlencode({'resource_view': h.dump_json(resource_view)}) %}
<div class="data-viewer-error js-hide">
<p class="text-error">
<i class="icon-info-sign"></i>
{{ _('This resource view is not available at the moment.') }}
<a href="#" data-toggle="collapse" data-target="#data-view-error">
{{ _('Click here for more information.') }}
</a>
</p>
<p id="data-view-error" class="collapse"></p>
<p>
<a href="{{ raw_resource_url }}" class="btn btn-large resource-url-analytics" target="_blank">
<i class="icon-large icon-download"></i>
{{ _('Download resource') }}
</a>
</p>
</div>
{% if not to_preview %}
{% set src = h.url(controller='package', action='resource_view', id=package['name'], resource_id=resource['id'], view_id=resource_view['id']) %}
{% else %}
{# When previewing we neet to stick the whole resource_view as a param as there is no other way to pass to information on to the iframe #}
{% set src = h.url(controller='package', action='resource_view', id=package['name'], resource_id=resource['id']) + '?' + h.urlencode({'resource_view': h.dump_json(resource_view)}) %}
{% endif %}
<iframe src="{{ src }}" frameborder="0" width="100%" data-module="data-viewer">
<p>{{ _('Your browser does not support iframes.') }}</p>
</iframe>
{% endif %}
<iframe src="{{ src }}" frameborder="0" width="100%" data-module="data-viewer">
<p>{{ _('Your browser does not support iframes.') }}</p>
</iframe>
{% endif %}
</div>
</div>
2 changes: 1 addition & 1 deletion ckan/templates/package/snippets/view_help.html
@@ -1,5 +1,5 @@
<section class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-info-sign"></i> {{ _('What\'s a View?') }}</h2>
<h2 class="module-heading"><i class="icon-info-sign"></i> {{ _('What\'s a view?') }}</h2>
<div class="module-content">
<p>{{ _('A view is a representation of the data held against a resource') }}</p>
</div>
Expand Down
35 changes: 21 additions & 14 deletions ckan/templates/package/view_edit_base.html
@@ -1,32 +1,39 @@
{% extends "package/base.html" %}
{% extends "package/resource_edit_base.html" %}

{% set logged_in = true if c.userobj else false %}
{% set res = c.resource %}

{% block breadcrumb_content_selected %}{% endblock %}

{% block breadcrumb_content %}
{{ super() }}
{% endblock %}
{% block breadcrumb_edit_selected %}{% endblock %}

{% block content_action %}
{% link_for _('All Views'), controller='package', action='resource_views', id=pkg.name, resource_id=res.id, class_='btn', icon='arrow-left' %}
{% link_for _('All views'), controller='package', action='resource_views', id=pkg.name, resource_id=res.id, class_='btn', icon='arrow-left' %}
{% if res %}
{% link_for _('View view'), controller='package', action='resource_read', id=pkg.name, resource_id=res.id, class_='btn', icon='eye-open' %}
{% endif %}
{% endblock %}

{% block content_primary_nav %}
{% endblock %}
{% block content_primary_nav %}{% endblock %}

{% block primary_content_inner %}
{% block form %}{% endblock %}
{% endblock %}

{% block main_content %}
{{ super() }}
{% if to_preview %}
{% snippet 'package/snippets/resource_view.html', resource_view=resource_view, resource=resource, package=package, to_preview=True %}
<div class="wrapper no-nav">
<section class="module module-narrow module-shallow">
<h2 class="module-heading">
<i class="icon-picture"></i> {{ _('View preview') }}
</h2>
<div class="module-content">
{% snippet 'package/snippets/resource_view.html', resource_view=resource_view, resource=resource, package=package, to_preview=True %}
</div>
</section>
</div>
{% endif %}
{% endblock %}

{% block secondary_content %}
{% snippet 'package/snippets/view_help.html' %}
{% endblock %}

{% block scripts %}
{{ super() }}
{% endblock %}

0 comments on commit 679f8c8

Please sign in to comment.