Skip to content

Commit

Permalink
[#688] Adds loads more blocks around editing/adding dataset form
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin authored and amercader committed Mar 27, 2013
1 parent 5f9db2b commit 1cf6f61
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ckan/templates/package/snippets/package_basic_fields.html
@@ -1,19 +1,28 @@
{% import 'macros/form.html' as form %}

{% block package_basic_fields_title %}
{{ form.input('title', id='field-title', label=_('Title'), placeholder=_('eg. A descriptive title'), value=data.title, error=errors.title, classes=['control-full', 'control-large'], attrs={'data-module': 'slug-preview-target'}) }}
{% endblock %}

{% block package_basic_fields_url %}
{% set prefix = h.url_for(controller='package', action='read', id='') %}
{% set domain = h.url_for(controller='package', action='read', id='', qualified=true) %}
{% set domain = domain|replace("http://", "")|replace("https://", "") %}
{% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<dataset>'} %}

{{ form.prepend('name', id='field-name', label=_('URL'), prepend=prefix, placeholder=_('eg. my-dataset'), value=data.name, error=errors.name, attrs=attrs) }}
{% endblock %}

{% block package_basic_fields_description %}
{{ form.markdown('notes', id='field-notes', label=_('Description'), placeholder=_('eg. Some useful notes about the data'), value=data.notes, error=errors.notes) }}
{% endblock %}

{% block package_basic_fields_tags %}
{% set tag_attrs = {'data-module': 'autocomplete', 'data-module-tags': '', 'data-module-source': '/api/2/util/tag/autocomplete?incomplete=?'} %}
{{ form.input('tag_string', id='field-tags', label=_('Tags'), placeholder=_('eg. economy, mental health, government'), value=data.tag_string, error=errors.tags, classes=['control-full'], attrs=tag_attrs) }}
{% endblock %}

{% block package_basic_fields_license %}
<div class="control-group">
{% set error = errors.license_id %}
<label class="control-label" for="field-license">{{ _("License") }}</label>
Expand All @@ -33,7 +42,9 @@
</span>
</div>
</div>
{% endblock %}

{% block package_basic_fields_org %}
{# if we have a default group then this wants remembering #}
{% if data.group_id %}
<input type="hidden" name="groups__0__id" value="{{ data.group_id }}" />
Expand All @@ -57,3 +68,4 @@
</div>
{% endif %}
{% endif %}
{% endblock %}
8 changes: 8 additions & 0 deletions ckan/templates/package/snippets/package_metadata_fields.html
@@ -1,6 +1,7 @@
{% import 'macros/form.html' as form %}


{% block package_metadata_fields_visibility %}
{% if data.owner_org %}
<div class="control-group">
<label for="field-private" class="control-label">{{ _('Visibility') }}</label>
Expand All @@ -13,18 +14,25 @@
</div>
</div>
{% endif %}
{% endblock %}

{% block package_metadata_author %}
{{ form.input('author', label=_('Author'), id='field-author', placeholder=_('Joe Bloggs'), value=data.author, error=errors.author, classes=['control-medium']) }}

{{ form.input('author_email', label=_('Author Email'), id='field-author-email', placeholder=_('joe@example.com'), value=data.author_email, error=errors.author_email, classes=['control-medium']) }}
{% endblock %}

{% block package_metadata_fields_maintainer %}
{{ form.input('maintainer', label=_('Maintainer'), id='field-maintainer', placeholder=_('Joe Bloggs'), value=data.maintainer, error=errors.maintainer, classes=['control-medium']) }}

{{ form.input('maintainer_email', label=_('Maintainer Email'), id='field-maintainer-email', placeholder=_('joe@example.com'), value=data.maintainer_email, error=errors.maintainer_email, classes=['control-medium']) }}
{% endblock %}

{% block package_metadata_fields_custom %}
{% block custom_fields %}
{% snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 %}
{% endblock %}
{% endblock %}


{% block dataset_fields %}
Expand Down
11 changes: 11 additions & 0 deletions ckan/templates/package/snippets/resource_form.html
Expand Up @@ -18,6 +18,8 @@

<div class="control-group dataset-form-resource-types">
{% block basic_fields %}

{% block basic_fields_data %}
<div class="controls"{% if allow_upload %} data-module="resource-upload-field"{% endif %}>
{#
This block uses a slightly odd pattern. Unlike the rest of the radio
Expand All @@ -33,20 +35,29 @@
<label class="radio inline" for="field-resource-type-api">{{ _('Link to an API') }}</label>
</div>
</div>
{% endblock %}

{% block basic_fields_url %}
{{ form.input('url', id='field-url', label=_('Resource'), placeholder=_('eg. http://example.com/gold-prices-jan-2011.json'), value=data.url, error=errors.url, classes=['control-full', 'control-large']) }}
{% endblock %}

{% block basic_fields_name %}
{{ form.input('name', id='field-name', label=_('Name'), placeholder=_('eg. January 2011 Gold Prices'), value=data.name, error=errors.name, classes=['control-full']) }}
{% endblock %}

{% block basic_fields_description %}
{{ form.markdown('description', id='field-description', label=_('Description'), placeholder=_('Some useful notes about the data'), value=data.description, error=errors.description) }}
{% endblock %}

{% block basic_fields_format %}
{% set format_attrs = {'data-module': 'autocomplete', 'data-module-source': '/api/2/util/resource/format_autocomplete?incomplete=?'} %}
{% call form.input('format', id='field-format', label=_('Format'), placeholder=_('eg. CSV, XML or JSON'), value=data.format, error=errors.format, classes=['control-medium'], attrs=format_attrs) %}
<span class="info-block info-block-small">
<i class="icon-info-sign"></i>
{{ _('This is generated automatically. You can edit if you wish') }}
</span>
{% endcall %}
{% endblock %}
{% endblock %}

{% block metadata_fields %}
Expand Down

0 comments on commit 1cf6f61

Please sign in to comment.