Skip to content
Snippets Groups Projects
Commit 2ecb57ed authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Enable editing of custom extra fields in the organization webform

parent ee2a79e5
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Configuration variable `ckanext.odsh.min_tag_length` indicating minimum characters allowed for tag length. - Configuration variable `ckanext.odsh.min_tag_length` indicating minimum characters allowed for tag length.
- Configuration variable `ckanext.odsh.max_tag_length` indicating maximum characters allowed - Configuration variable `ckanext.odsh.max_tag_length` indicating maximum characters allowed for tag length.
- Editing of custom extra fields alongside the fixed fields in organizations form.
### Removed ### Removed
......
...@@ -26,24 +26,57 @@ ...@@ -26,24 +26,57 @@
{% endblock %} {% endblock %}
{% block custom_fields %}
{% set extras = h.get_address_org(data) %} <div data-module="custom-fields">
{% set extras = h.get_address_org(data) %}
{{ form.input_address('person','Ansprechpartner', value= extras.person , index=0, placeholder='', type='text', attrs={}) }} {{ form.input_address('person','Ansprechpartner', value= extras.person , index=0, placeholder='', type='text', attrs={}) }}
{{ form.input_address('street','Straße', value= extras.street, index=1, placeholder='', type='text', attrs={}) }} {{ form.input_address('street','Straße', value= extras.street, index=1, placeholder='', type='text', attrs={}) }}
{{ form.input_address('location','Stadt', value=extras.location, index=2, placeholder='', type='text', attrs={}) }}
{{ form.input_address('telephone','Tel.-Nr.', value=extras.telephone, index=3, placeholder='', type='text', attrs={}) }}
{{ form.input_address('location','Stadt', value=extras.location, index=2, placeholder='', type='text', attrs={}) }} {{ form.input_address('mail','E-Mail', value=extras.mail, index=4, placeholder='', type='text', attrs={}) }}
{{ form.input_address('web','Website', value=extras.web, index=5, placeholder='', type='text', attrs={}) }}
{{ form.input_address('telephone','Tel.-Nr.', value=extras.telephone, index=3, placeholder='', type='text', attrs={}) }} {{ form.input_address('gnd','GND URI', value=extras.gnd, index=6, placeholder='https://d-nb.info/gnd/1136109587', type='text', attrs={}) }}
{{ form.input_address('mail','E-Mail', value=extras.mail, index=4, placeholder='', type='text', attrs={}) }} {% for extra in data.extras %}
{% if extra.key not in ['person','street','location','telephone','mail','web','gnd'] %}
{{ form.input_address('web','Website', value=extras.web, index=5, placeholder='', type='text', attrs={}) }} {% set prefix = 'extras__%d__' % (loop.index0 + 7) %}
{{ form.custom(
{{ form.input_address('gnd','GND URI', value=extras.gnd, index=6, placeholder='https://d-nb.info/gnd/1136109587', type='text', attrs={}) }} 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']
) }}
{% endif %}
{% endfor %}
{# Add a max of 3 empty columns #}
{% set total_extras = data.extras|count %}
{% set empty_extras = (limit or 3) - total_extras %}
{% if empty_extras <= 0 %}{% set empty_extras = 1 %}{% endif %}
{% for extra in range(total_extras, total_extras + empty_extras) %}
{% set index = loop.index0 + (data.extras|count) + 7 %}
{% 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 %}
</div>
{% endblock %}
{{ form.required_message() }} {{ form.required_message() }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment