-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8110 from ckan/8108-data-dictionary-preview
definition list for data dictionary view
- Loading branch information
Showing
8 changed files
with
97 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Use a definition list for the Data Dictionary view on resource pages to allow | ||
extra information for each field. Update example_idatadictionaryform plugin to | ||
display extra information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
ckanext/datastore/templates/datastore/snippets/dictionary_view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{% block dictionary_view %} | ||
<div class="module-content"> | ||
<h2>{{ _('Data Dictionary') }}</h2> | ||
|
||
{% macro dictionary_field(label) %} | ||
{% set content = caller().strip() %} | ||
{% if content %} | ||
<dt class="col-sm-3 text-secondary">{{ label }}</dt> | ||
<dd class="col-sm-9">{{ content }}</dd> | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% for field in ddict %} | ||
|
||
{% set field_type %}{% block dictionary_field_type scoped | ||
%}{{ field.type }}{% endblock %}{% endset %} | ||
{% set extra_info -%} | ||
{% call dictionary_field(_('Label')) %} | ||
{{ h.get_translated(field.get('info', {}), 'label') }} | ||
{% endcall %} | ||
{% call dictionary_field(_('Description')) %} | ||
{{ h.render_markdown(h.get_translated( | ||
field.get('info', {}), 'notes')) }} | ||
{% endcall %} | ||
{% block dictionary_field_extras scoped %} | ||
{% endblock %} | ||
{%- endset %} | ||
{# render_markdown to strip snippet comments and whitespace #} | ||
{% set has_extra=h.render_markdown(extra_info) %} | ||
|
||
<div class="accordion"> | ||
<div class="accordion-item"> | ||
<h3 class="accordion-header" id="field{{ prefix }}-{{ loop.index }}"> | ||
{%- if has_extra -%} | ||
<button class="accordion-button collapsed" type="button" | ||
data-bs-toggle="collapse" aria-expanded="false" | ||
data-bs-target="#collapse{{ prefix }}-{{ loop.index }}" | ||
aria-controls="collapse{{ prefix }}-{{ loop.index }}"> | ||
{%- else -%} | ||
<button class="accordion-button no-after" disabled> | ||
{%- endif -%} | ||
<div class="col-1">{{ loop.index }}.</div><div class="col-7"> | ||
{{- h.get_translated(field.get('info', {}), 'label') | ||
or field.id -}} | ||
</div> | ||
<div class="col-4">{{ field_type }}</div> | ||
</button> | ||
</h3> | ||
{% if has_extra %} | ||
<div id="collapse{{ prefix }}-{{ loop.index }}" | ||
class="accordion-collapse collapse" | ||
aria-labelledby="field{{ prefix }}-{{ loop.index }}"> | ||
<dl class="row accordion-body"> | ||
{% block resource_data_dictionary_field scoped %} | ||
{% call dictionary_field(_('ID')) %}{{ field.id }}{% endcall %} | ||
{% call dictionary_field(_('Type')) %}{{ field_type }}{% endcall %} | ||
{{ extra_info }} | ||
{% endblock %} | ||
</dl> | ||
</div> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
{% endfor %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
ckanext/datastore/templates/package/snippets/dictionary_table.html
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
ckanext/example_idatadictionaryform/templates/datastore/snippets/dictionary_view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% ckan_extends %} | ||
|
||
{% block dictionary_field_extras %} | ||
{{ super() }} | ||
{% call dictionary_field(_('An integer')) %}{{ field.an_int }}{% endcall %} | ||
{% call dictionary_field(_('JSON object')) %}{{ field.json_obj }}{% endcall %} | ||
{% call dictionary_field(_('Always increasing')) %}{{ field.only_up }}{% endcall %} | ||
{% call dictionary_field(_('Sticky input')) %}{{ field.sticky }}{% endcall %} | ||
{% endblock %} |