-
Notifications
You must be signed in to change notification settings - Fork 2k
/
organization_form.html
100 lines (81 loc) · 5.19 KB
/
organization_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
100
{% import 'macros/form.html' as form %}
<form 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'} %}
{{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Organization'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }}
{# Perhaps these should be moved into the controller? #}
{% set prefix = h.url_for(controller='organization', action='read', id='') %}
{% set domain = h.url_for(controller='organization', 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': '<organization>'} %}
{{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-organization'), 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 organization...'), 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) }}
<div class="control-group ">
<div class="controls">
<label class="checkbox" for="field-closed">
<input id="field-closed" type="checkbox" name="closed" value="true" {% if data.get('closed', False) %}checked{% endif %} class="collapse" data-toggle="collapse" data-target="#closed-properties">
Closed
</label>
</div>
</div>
<div id="closed-properties" {% if data.get('closed', False) %}class="collapse in"{% else %}class="collapse"{% endif %}>
{% set relationship_options = [{'value': ''},
{'value': _('replaced by') },
{'value': _('partially replaced') },
{'value': _('split up') },
{'value': _('merged into new organization')} ] %}
{{ form.select('related_group_relationship', label=_('Organization relationship'), options=relationship_options, selected=data.related_group_relationship, error=error) }}
<div class="control-group control-full">
{% set related_label = _("Related Organization") %}
<label class="control-label" for="related_group_id">{{ related_label }}</label>
<div class="controls">
{% set current_related_group_id = data.related_group_id %}
{% set current_related_group_title = h.group_name_to_title(current_related_group_id) %}
<input id="related_group_id" type="text" name="related_group_id" placeholder='{{related_label}}'
value="{{current_related_group_id}}" class="control-medium" data-module="autocomplete" data-module-label='title' data-module-key='id' data-module-defaultlabel='{{current_related_group_title}}' data-module-defaultvalue='{{data.related_group_id}}'
data-module-source="/api/2/util/group/autocomplete?type=organization&q=?">
</div>
</div>
</div>
{% 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('organization_delete', {'id': data.id}) %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this Organization? This will delete all the public and private datasets belonging to this organization.')}) %}
<a class="btn btn-danger pull-left" href="{% url_for controller='organization', 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 Organization') }}{% endblock %}</button>
</div>
</form>