107 lines
4.2 KiB
HTML
107 lines
4.2 KiB
HTML
{% import 'macros/form.html' as form %}
|
|
|
|
{# SCRIPT ADDED BY FRACESCO MANGIACRAPA, SEE 20425 #}
|
|
<script>
|
|
|
|
hideButton = false;
|
|
|
|
function hideEditButton() {
|
|
hideButton = true;
|
|
}
|
|
|
|
function hideFirstButton () {
|
|
console.log('hideButton: '+hideButton);
|
|
|
|
if(hideButton){
|
|
var theIdSection = document.getElementById('hide-edit');
|
|
console.log('theIdSection: '+theIdSection);
|
|
|
|
var el = theIdSection.getElementsByTagName('button')[0]
|
|
|
|
if(typeof el !== "undefined") {
|
|
el.style.display='none';
|
|
} else {
|
|
setTimeout(hideFirstButton, 200); // try again in 200 milliseconds
|
|
}
|
|
}
|
|
}
|
|
|
|
if(window.addEventListener){
|
|
window.addEventListener('load', hideFirstButton);
|
|
}else{
|
|
window.attachEvent('onload', hideFirstButton);
|
|
}
|
|
</script>
|
|
|
|
<form id="group-edit" class="dataset-form form-horizontal" method="post" data-module="basic-form" enctype="multipart/form-data">
|
|
{% block error_summary %}
|
|
{{ form.errors(error_summary) }}
|
|
{% endblock %}
|
|
|
|
{% block basic_fields %}
|
|
{% set attrs = {'data-module': 'slug-preview-target'} %}
|
|
{# DIV ADDED BY FRACESCO MANGIACRAPA, SEE 20425 #}
|
|
<div id="hide-edit">
|
|
{{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Group'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }}
|
|
</div>
|
|
{# Perhaps these should be moved into the controller? #}
|
|
{% set prefix = h.url_for(controller='group', action='read', id='') %}
|
|
{% set domain = h.url_for(controller='group', 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': '<group>'} %}
|
|
|
|
{# CODE ADDED BY FRACESCO MANGIACRAPA, SEE 20425 #}
|
|
{% set hide = h.get_cookie_value('ckan_hide_header') %}
|
|
{% if hide=='true' %}
|
|
<script>hideEditButton()</script>
|
|
{% endif %}
|
|
|
|
{{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-group'), value=data.name, error=errors.name, attrs=attrs, is_required=true) }}
|
|
|
|
{{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my group...'), value=data.description, error=errors.description) }}
|
|
|
|
{% set is_upload = data.image_url and not data.image_url.startswith('http') %}
|
|
{% set is_url = data.image_url and data.image_url.startswith('http') %}
|
|
|
|
{{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload) }}
|
|
|
|
{% endblock %}
|
|
|
|
{% block custom_fields %}
|
|
{% for extra in data.extras %}
|
|
{% set prefix = 'extras__%d__' % loop.index0 %}
|
|
{{ form.custom(
|
|
names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
|
|
id='field-extras-%d' % loop.index,
|
|
label=_('Custom Field'),
|
|
values=(extra.key, extra.value, extra.deleted),
|
|
error=errors[prefix ~ 'key'] or errors[prefix ~ 'value']
|
|
) }}
|
|
{% endfor %}
|
|
|
|
{# Add a max if 3 empty columns #}
|
|
{% for extra in range(data.extras|count, 3) %}
|
|
{% set index = (loop.index0 + data.extras|count) %}
|
|
{% set prefix = 'extras__%d__' % index %}
|
|
{{ form.custom(
|
|
names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
|
|
id='field-extras-%d' % index,
|
|
label=_('Custom Field'),
|
|
values=(extra.key, extra.value, extra.deleted),
|
|
error=errors[prefix ~ 'key'] or errors[prefix ~ 'value']
|
|
) }}
|
|
{% endfor %}
|
|
{% endblock %}
|
|
|
|
{{ form.required_message() }}
|
|
|
|
<div class="form-actions">
|
|
{% block delete_button %}
|
|
{% if h.check_access('group_delete', {'id': data.id}) %}
|
|
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this Group?')}) %}
|
|
<a class="btn btn-danger pull-left" href="{% url_for controller='group', action='delete', id=data.id %}" data-module="confirm-action" data-module-i18n="{{ locale }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
|
|
{% endif %}
|
|
{% endblock %}
|
|
<button class="btn btn-primary" name="save" type="submit">{% block save_text %}{{ _('Save Group') }}{% endblock %}</button>
|
|
</div>
|
|
</form> |