From 4d3409066bdf9ad8e1c0714fc4ff6597700651d6 Mon Sep 17 00:00:00 2001 From: mutantsan Date: Wed, 19 Jun 2024 10:40:17 +0300 Subject: [PATCH] path resource_id to each chart field form snippet --- .../charts/snippets/charts_form_field.html | 14 ++++++++++++++ .../charts/snippets/charts_form_fields.html | 8 ++++++-- .../templates/charts/snippets/render_fields.html | 2 +- .../scheming/form_snippets/chart_filter.html | 3 --- 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 ckanext/charts/templates/charts/snippets/charts_form_field.html diff --git a/ckanext/charts/templates/charts/snippets/charts_form_field.html b/ckanext/charts/templates/charts/snippets/charts_form_field.html new file mode 100644 index 0000000..f0bf78c --- /dev/null +++ b/ckanext/charts/templates/charts/snippets/charts_form_field.html @@ -0,0 +1,14 @@ +{#- master snippet for all charts form fields -#} + +{%- set form_snippet = field.form_snippet|default('repeating_subfields.html' if field.repeating_subfields else 'text.html') -%} + +{%- if '/' not in form_snippet -%} + {%- set form_snippet = 'scheming/form_snippets/' + form_snippet -%} +{%- endif -%} + +{%- snippet form_snippet, + field=field, + data=data, + errors=errors, + resource_id=resource_id +-%} diff --git a/ckanext/charts/templates/charts/snippets/charts_form_fields.html b/ckanext/charts/templates/charts/snippets/charts_form_fields.html index 93a4e71..b80ea66 100644 --- a/ckanext/charts/templates/charts/snippets/charts_form_fields.html +++ b/ckanext/charts/templates/charts/snippets/charts_form_fields.html @@ -40,8 +40,12 @@ {% if tab_fields %}
- {% snippet 'charts/snippets/render_fields.html', fields=builder.get_fields_by_tab(tab), data=data, - errors=errors %} + {% snippet 'charts/snippets/render_fields.html', + fields=builder.get_fields_by_tab(tab), + data=data, + errors=errors, + resource_id=resource_id + %}
{% endif %} {% endfor %} diff --git a/ckanext/charts/templates/charts/snippets/render_fields.html b/ckanext/charts/templates/charts/snippets/render_fields.html index 75d21c9..ac4cfb8 100644 --- a/ckanext/charts/templates/charts/snippets/render_fields.html +++ b/ckanext/charts/templates/charts/snippets/render_fields.html @@ -1,3 +1,3 @@ {% for field in fields if field.form_snippet is not none %} - {% snippet 'scheming/snippets/form_field.html', field=field, data=data, errors=errors %} + {% snippet 'charts/snippets/charts_form_field.html', field=field, data=data, errors=errors, resource_id=resource_id %} {% endfor %} diff --git a/ckanext/charts/templates/scheming/form_snippets/chart_filter.html b/ckanext/charts/templates/scheming/form_snippets/chart_filter.html index e70b54e..68aa307 100644 --- a/ckanext/charts/templates/scheming/form_snippets/chart_filter.html +++ b/ckanext/charts/templates/scheming/form_snippets/chart_filter.html @@ -1,6 +1,3 @@ -{#} HACK, pass resource ID more explicitly #} -{% set resource_id = data.__extras.resource_id %} -