Skip to content

Commit

Permalink
Merge branch '2956-resource-editing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Oct 16, 2012
2 parents b625eb5 + bab3906 commit 2a4969f
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 15 deletions.
11 changes: 11 additions & 0 deletions ckan/public/base/less/module.less
Expand Up @@ -14,6 +14,11 @@
#gradient > .vertical(@moduleHeadingBackgroundColorStart, @moduleHeadingBackgroundColorEnd);
}

.module-heading-secondary {
.border-radius(0);
border-top: 1px solid @moduleHeadingBorderColor;
}

.module-heading [class^=icon]:before {
font-size: 1.2em;
line-height: 1;
Expand Down Expand Up @@ -189,3 +194,9 @@
overflow: hidden;
}
}

.package-info {
h4 {
margin-bottom: 10px;
}
}
8 changes: 8 additions & 0 deletions ckan/templates/package/edit.html
Expand Up @@ -8,6 +8,14 @@
<li class="active">{% link_for _('Edit Dataset'), controller='package', action='edit', id=pkg.name %}</li>
{% endblock %}

{% block resources_module %}
{% snippet 'package/snippets/resources.html', pkg=pkg, action='resource_edit' %}
{% endblock %}

{% block actions_content %}
{% snippet 'package/snippets/back_to_package_action.html', pkg=pkg %}
{% endblock %}

{% block secondary_content %}
{% snippet 'package/snippets/info.html', pkg=pkg, action='package_edit' %}
{% endblock %}
18 changes: 10 additions & 8 deletions ckan/templates/package/new_resource.html
Expand Up @@ -11,14 +11,16 @@
{% block form %}{% snippet 'package/snippets/resource_form.html', data=data, errors=errors, error_summary=error_summary, include_metadata=false, pkg_name=pkg_name, stage=stage, allow_upload=logged_in %}{% endblock %}

{% block secondary_content %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What is data?') }}</h2>
<div class="module-content">
<p>{{ _('Data can be any file or link to a file containing useful data.') }}</p>
</div>
</section>

{% snippet 'package/snippets/resources.html', pkg=pkg_dict, action='resource_edit', active=data.id %}
{% if pkg_dict and pkg_dict.state != 'draft' %}
{% snippet 'package/snippets/info.html', pkg=pkg_dict, action='resource_new' %}
{% else %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What\'s a resource?') }}</h2>
<div class="module-content">
<p>{{ _('A resource can be any file or link to a file containing useful data.') }}</p>
</div>
</section>
{% endif %}
{% endblock %}

{% block scripts %}
Expand Down
5 changes: 1 addition & 4 deletions ckan/templates/package/read.html
Expand Up @@ -15,10 +15,7 @@
{# NOTE: Not implemented in stage 1 #}
{# <li>{% link_for _('History'), controller='package', action='history', id=pkg.name, class_='btn', icon='undo' %}</li> #}
{% if h.check_access('package_update', {'id':pkg.id }) %}
<li>{% link_for _('Edit'), controller='package', action='edit', id=pkg.name, class_='btn', icon='wrench' %}</li>
{% endif %}
{% if h.check_access('package_update', {'id':pkg.id }) %}
<li>{% link_for _('Add resource'), controller='package', action='new_resource', id=pkg.name, class_='btn', icon='plus' %}</li>
<li>{% link_for _('Edit'), controller='package', action='edit', id=pkg.name, class_='btn btn-primary', icon='wrench' %}</li>
{% endif %}
{% endblock %}

Expand Down
6 changes: 5 additions & 1 deletion ckan/templates/package/resource_edit.html
Expand Up @@ -12,8 +12,12 @@
{% endblock %}

{% block actions_content %}
<li>{% link_for _('Back to resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='caret-left' %}</li>
<li>{% link_for _('View resource'), controller='package', action='resource_read', id=pkg_dict.name, resource_id=res.id, class_='btn', icon='eye-open' %}</li>
{% endblock %}

{# logged_in is defined in new_resource.html #}
{% block form %}{{ h.snippet('package/snippets/resource_edit_form.html', data=data, errors=errors, error_summary=error_summary, pkg_name=pkg_dict.name, form_action=c.form_action, allow_upload=logged_in) }}{% endblock %}

{% block secondary_content %}
{% snippet 'package/snippets/info.html', pkg=pkg_dict, active=data.id, action='resource_edit' %}
{% endblock %}
@@ -1 +1 @@
<li>{% link_for _('Back to dataset'), controller='package', action='read', id=pkg.name, class_='btn', icon='caret-left' %}</li>
<li>{% link_for _('View dataset'), controller='package', action='read', id=pkg.name, class_='btn', icon='eye-open' %}</li>
32 changes: 32 additions & 0 deletions ckan/templates/package/snippets/info.html
@@ -0,0 +1,32 @@
{#
Displays a sidebard module with information for given package

pkg - The package dict that owns the resources.
active - The active resource.
action - The action that this is coming from.

Example:

{% snippet "package/snippets/info.html", pkg=pkg %}

#}
{% if pkg and h.check_access('package_update', {'id':pkg.id }) %}
<section class="module module-narrow package-info">
<h2 class="module-heading"><i class="icon-sitemap"></i> {{ _("Edit Dataset") }}</h2>
<ul class="unstyled nav nav-simple">
<li class="nav-item{% if action == 'package_edit' %} active{% endif %}">
{% link_for h.dataset_display_name(pkg)|truncate(30), controller='package', action='edit', id=pkg.name %}
</li>
</ul>
{% set resources = pkg.resources or [] %}
<h2 class="module-heading module-heading-secondary"><i class="icon-copy"></i> {{ _("Edit Resources") }}</h2>
<ul class="unstyled nav nav-simple">
{% for resource in resources %}
<li class="nav-item{{ ' active' if active == resource.id }}">
{% link_for h.resource_display_name(resource)|truncate(30), controller='package', action='resource_edit', id=pkg.name, resource_id=resource.id, inner_span=true %}
</li>
{% endfor %}
<li><a href="{{ h.url_for(controller='package', action='new_resource', id=pkg.name) }}" class="btn{% if action == 'resource_new' %} disabled{% endif %}"><i class="icon-plus"></i> {{ _('Add new resource') }}</a></li>
</ul>
</section>
{% endif %}
2 changes: 1 addition & 1 deletion ckan/templates/package/snippets/resources.html
Expand Up @@ -14,7 +14,7 @@
{% set resources = pkg.resources or [] %}
{% if resources %}
<section class="module module-narrow resources">
<h2 class="module-heading">{{ _("Resources") }}</h2>
<h2 class="module-heading"><i class="icon-copy"></i> {{ _("Resources") }}</h2>
<ul class="unstyled nav nav-simple">
{% for resource in resources %}
<li class="nav-item{{ ' active' if active == resource.id }}">
Expand Down

0 comments on commit 2a4969f

Please sign in to comment.