diff --git a/CHANGELOG.md b/CHANGELOG.md index 6801c903a3c5386e9594c5bdcfa9e228d3ae8967..9897f2294ac46c77f5ec364177523e59d63bea06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - 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 diff --git a/ckanext/odsh/templates/organization/snippets/organization_form.html b/ckanext/odsh/templates/organization/snippets/organization_form.html index c0bf3069cf2826c1873480c3692c12954b297d82..a3cd0db79670eb990d1bb98a22c1495ddca45fb1 100644 --- a/ckanext/odsh/templates/organization/snippets/organization_form.html +++ b/ckanext/odsh/templates/organization/snippets/organization_form.html @@ -26,24 +26,57 @@ {% endblock %} - - - {% set extras = h.get_address_org(data) %} + {% block custom_fields %} + <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('street','Straße', value= extras.street, index=1, 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('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={}) }} - - {{ form.input_address('web','Website', value=extras.web, index=5, 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={}) }} + {% for extra in data.extras %} + {% if extra.key not in ['person','street','location','telephone','mail','web','gnd'] %} + {% set prefix = 'extras__%d__' % (loop.index0 + 7) %} + {{ 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'] + ) }} + {% 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() }}