-
Notifications
You must be signed in to change notification settings - Fork 2k
/
resource_form.html
99 lines (83 loc) · 5.3 KB
/
resource_form.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{% import 'macros/form.html' as form %}
{% set data = data or {} %}
{% set errors = errors or {} %}
{% set action = form_action or h.url_for(controller='package', action='new_resource', id=pkg_name) %}
<form class="dataset-form dataset-resource-form form-horizontal" method="post" action="{{ action }}" data-module="basic-form resource-form">
{% block stages %}
{# An empty stages variable will not show the stages #}
{% if stage %}
{{ h.snippet('package/snippets/stages.html', stages=stage, pkg_name=pkg_name) }}
{% endif %}
{% endblock %}
{{ form.errors(error_summary) }}
<input name="id" value="{{ data.id }}" type="hidden"/>
<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
buttons which are wrapped _inside_ the labels here we place the label
after the input. This enables us to style the label based on the state
of the radio using css. eg. input[type=radio]+label {}
#}
<i class="ckan-icon ckan-icon-link-file"></i>
<input id="field-resource-type-file" type="radio" name="resource_type" checked="checked" value="file" />
<label class="radio inline" for="field-resource-type-file">{{ _('Link to a file') }}</label>
<i class="ckan-icon ckan-icon-link-plugin"></i>
<input id="field-resource-type-api" type="radio" name="resource_type" value="api" />
<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 %}
{% if include_metadata %}
{# TODO: Where do these come from, they don't exist in /package/new_package_form.html #}
{# {{ form.select('resource_type', id='field-type', label=_('Resource Type'), options=[{'value': 'empty', 'text': _('Select a type…')}], selected="empty", error=errors.type) }} #}
{{ form.input('last_modified', id='field-last-modified', label=_('Last Modified'), placeholder=_('eg. 2012-06-05'), value=data.last_modified, error=errors.last_modified, classes=[]) }}
{{ form.input('size', id='field-size', label=_('File Size'), placeholder=_('eg. 1024'), value=data.size, error=errors.size, classes=[]) }}
{{ form.input('mimetype', id='field-mimetype', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype, error=errors.mimetype, classes=[]) }}
{{ form.input('mimetype_inner', id='field-mimetype-inner', label=_('MIME Type'), placeholder=_('eg. application/json'), value=data.mimetype_inner, error=errors.mimetype_inner, classes=[]) }}
{% endif %}
{% endblock %}
<div class="form-actions">
{% block delete_button %}
{% if data.id %}
{% if h.check_access('resource_delete', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this resource?')}) %}
<a class="btn btn-danger pull-left" href="{% url_for controller='package', action='resource_delete', resource_id=data.id, id=pkg_name %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endif %}
{% endblock %}
{% if stage %}
{% block previous_button %}
<button class="btn" name="save" value="go-dataset" type="submit">{{ _('Previous') }}</button>
{% endblock %}
{% block again_button %}
<button class="btn" name="save" value="again" type="submit">{{ _('Save & add another') }}</button>
{% endblock %}
<button class="btn btn-primary" name="save" value="go-metadata" type="submit">{% block save_button_text %}{{ _('Next: Additional Info') }}{% endblock %}</button>
{% else %}
<button class="btn btn-primary" name="save" value="go-dataset-complete" type="submit">{{ _('Add') }}</button>
{% endif %}
</div>
</form>