Skip to content

Commit

Permalink
feat(templates): recombinant datatable headers;
Browse files Browse the repository at this point in the history
- Started working with recombinant dictionaries into datatable headers.
  • Loading branch information
JVickery-TBS committed May 14, 2024
1 parent 3508fce commit 927119c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions ckanext/canada/templates/public/datatables/datatables_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,47 @@
</div>
{% endblock %}

{%- block datatable_field_headers -%}

{% set chromo = h.recombinant_published_resource_chromo(resource.id) %}
{% if chromo %}

{% set chromo_keyed = {} %}
{% for recombinant_field in chromo.fields %}
{% set _ = chromo_keyed.update({recombinant_field.datastore_id: {description: recombinant_field.description,
label: recombinant_field.label}}) %}
{% endfor %}

{% set datadictionary_fields = h.datastore_dictionary(resource.id) %}

{% for field in datadictionary_fields %}

{% if 'show_fields' not in resource_view or field.id in resource_view.show_fields -%}

{% if field.id in chromo_keyed %}
{# the DS field is a Recombinant field, use chromo #}
{% set description = h.recombinant_language_text(chromo_keyed[field.id].description) | replace('\n', '<br>' | safe) %}
{% set label = h.recombinant_language_text(chromo_keyed[field.id].label) | trim %}
<th scope="col">{{ label }}&nbsp;<i class="fa fa-info-circle" title="{{ h.markdown_extract(description, 300) }}"></i>&nbsp;</th>
{% else %}
{# the DS field is NOT a Recombinant field, use parent #}
{# TODO: solve issue with passing field over to scoped block #}
<th scope="col">{{ self.datatable_column_label(field) }}</th>
{% endif %}

{%- endif %}

{% endfor %}

{% else %}

{{ super() }}

{% endif %}

{%- endblock -%}


{%- block datatable_column_label -%}
{%- set label = 'label_' + h.lang() -%}
{%- set description = 'notes_' + h.lang() -%}
Expand Down

0 comments on commit 927119c

Please sign in to comment.