Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ckanext-odsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
ckanext-odsh
Commits
10b22ac7
Commit
10b22ac7
authored
1 year ago
by
Thorge Petersen
Browse files
Options
Downloads
Patches
Plain Diff
Refactored autocomplete macro
parent
d9ab0059
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!52
Added applicableLegislation and hvdCategory support
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ckanext/odsh/templates/macros/form.html
+17
-15
17 additions, 15 deletions
ckanext/odsh/templates/macros/form.html
ckanext/odsh/templates/package/snippets/package_basic_fields.html
+7
-7
7 additions, 7 deletions
...odsh/templates/package/snippets/package_basic_fields.html
with
24 additions
and
22 deletions
ckanext/odsh/templates/macros/form.html
+
17
−
15
View file @
10b22ac7
...
...
@@ -165,20 +165,23 @@ is_required=false) %}
{# Creates a select with an input field for autocomplete #}
{% macro select_autocomplete(name, id='', label='', options='', selected='', error='', classes=[], attrs={},
is_required=false, is_multiple=false) %}
{% set classes = (classes|list) %}
{% do classes.append('control-select') %}
is_required=false, is_multiple=false, is_extra=false, index=0) %}
{% set classes = classes|default([]) + ['control-select'] %}
{%- set extra_html = caller() if caller -%}
{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required)
%}
{% call input_block(id or name, label or name, error, classes, extra_html=extra_html, is_required=is_required) %}
<div
class=
"row-fluid"
>
<div
class=
"span6"
>
<select
id=
"{{ id or name }}"
name=
"{{ name }}"
{{
attributes
(
attrs
)
}}
data-module=
"autocomplete"
{%
if
is_multiple
%}
multiple
{%
endif
%}
>
{% if is_extra %}
<input
id=
"field-{{ name }}-key"
type=
"hidden"
name=
"extras__{{ index }}__key"
value=
"{{ id or name }}"
/>
{% endif %}
<select
id=
"{{ 'field-' ~ (id or name) ~ '-value' if is_extra else (id or name) }}"
name=
"{{ 'extras__' ~ index ~ '__value' if is_extra else (name) }}"
{{
attributes
(
attrs
)
}}
data-module=
"autocomplete"
{%
if
is_multiple
%}
multiple
{%
endif
%}
>
{% for option in options %}
<option
value=
"{{ option.key }}"
{%
if
option.key
in
selected
%}
selected
{%
endif
%}
>
{{ option.text or
option.value }}
</option>
<option
value=
"{{ option.key }}"
{%
if
option.key
in
selected
%}
selected=
"selected"
{%
endif
%}
>
{{ option.text or option.value }}
</option>
{% endfor %}
</select>
</div>
...
...
@@ -194,7 +197,6 @@ is_required=false) %}
{% endmacro %}
{#
Creates all the markup required for a Markdown textarea element. Handles
matching labels to inputs, selected item and error messages.
...
...
This diff is collapsed.
Click to expand it.
ckanext/odsh/templates/package/snippets/package_basic_fields.html
+
7
−
7
View file @
10b22ac7
...
...
@@ -337,11 +337,6 @@ dataset_is_draft)) %}
</div>
</div>
{% block scripts %}
{% asset 'ckanext-odsh/odsh_datepicker_script' %}
{% asset 'ckanext-odsh/odsh_form_script' %}
{% endblock scripts %}
{# field reference #}
{% set field = 'reference' %}
{% set error_reference = h.odsh_extract_error(field, errors) %}
...
...
@@ -352,10 +347,15 @@ dataset_is_draft)) %}
{% set field = 'applicableLegislation' %}
{% set error_reference = h.odsh_extract_error(field, errors) %}
{% set value = h.odsh_extract_value_from_extras(data.extras,field) or '' %}
{{ form.select_autocomplete(field, label=_('Applicable Legislation'), selected=value, options=h.odsh_load_applicable_legislations(), error=error_reference, is_required=False, classes=['control-full', 'field-applicableLegislation'], is_multiple=True)}}
{{ form.select_autocomplete(field, label=_('Applicable Legislation'), selected=value, options=h.odsh_load_applicable_legislations(), error=error_reference, is_required=False, classes=['control-full', 'field-applicableLegislation'], is_multiple=True
, is_extra=True, index=5
)}}
{# field hvdCategory #}
{% set field = 'hvdCategory' %}
{% set error_reference = h.odsh_extract_error(field, errors) %}
{% set value = h.odsh_extract_value_from_extras(data.extras,field) or '' %}
{{ form.select_autocomplete(field, label=_('HVD Category'), selected=value, options=h.odsh_load_hvd_categories(), error=error_reference, is_required=False, classes=['control-full', 'field-hvdCategory'], is_multiple=True)}}
{{ form.select_autocomplete(field, label=_('HVD Category'), selected=value, options=h.odsh_load_hvd_categories(), error=error_reference, is_required=False, classes=['control-full', 'field-hvdCategory'], is_multiple=True, is_extra=True, index=6)}}
{% block scripts %}
{% asset 'ckanext-odsh/odsh_datepicker_script' %}
{% asset 'ckanext-odsh/odsh_form_script' %}
{% endblock scripts %}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment