Skip to content

Commit 74c899c

Browse files
authored
Merge pull request #244 from dpc-sdp/SXDEDPCXZIC-390
Sxdedpcxzic 390
2 parents c437031 + 79283ca commit 74c899c

4 files changed

Lines changed: 137 additions & 0 deletions

File tree

ckanext/datavic_odp_theme/grunt/sass/_resources.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ $primary-color: #0052C2;
207207
margin-bottom: 0;
208208
}
209209
}
210+
.data-dictionary-table {
211+
thead {
212+
background-color: #f2f2f2;
213+
}
214+
}
210215
}
211216

212217
@media (min-width: 576px) {

ckanext/datavic_odp_theme/helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,12 @@ def datavic_update_org_error_dict(
260260
)]
261261

262262
return error_dict
263+
264+
@helper
265+
def resource_attributes(attrs):
266+
try:
267+
attrs = json.loads(attrs)
268+
except ValueError:
269+
return None
270+
271+
return attrs
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{% extends "package/resource_read.html" %}
2+
3+
{%- set exclude_fields = [
4+
'name',
5+
'description',
6+
'url',
7+
'format',
8+
] -%}
9+
{%- set schema = h.scheming_get_dataset_schema(dataset_type) -%}
10+
11+
{% block resource_additional_information_inner %}
12+
{% if res.attributes %}
13+
{% set res_attrs = h.resource_attributes(res.attributes) %}
14+
{% if res_attrs %}
15+
<div class="module-content">
16+
<h2>{{ _('Data Dictionary') }}</h2>
17+
<table class="table table-bordered table-condensed data-dictionary-table" data-module="table-toggle-more">
18+
<thead>
19+
{% block resouce_data_dictionary_headers %}
20+
<tr>
21+
<th scope="col">{{ _('Column') }}</th>
22+
<th scope="col">{{ _('Name') }}</th>
23+
<th scope="col">{{ _('Type') }}</th>
24+
<th scope="col">{{ _('Description') }}</th>
25+
<th scope="col">{{ _('Fixed Values') }}</th>
26+
</tr>
27+
{% endblock %}
28+
</thead>
29+
{% for attr in res_attrs %}
30+
<tr>
31+
<td>{{ attr.db_name }}</td>
32+
<td>{{ attr.name }}</td>
33+
<td>{{ attr.db_format }}</td>
34+
<td>{{ attr.definition }}</td>
35+
<td>{{ attr.fixed_values }}</td>
36+
</tr>
37+
{% endfor %}
38+
</table>
39+
</div>
40+
{% endif %}
41+
{% else %}
42+
{% if res.datastore_active %}
43+
{% block resource_data_dictionary %}
44+
{{ super() }}
45+
{% endblock %}
46+
{% endif %}
47+
{% endif %}
48+
49+
<div class="module-content">
50+
{%- block additional_info_heading -%}<h2>{{ _('Additional Information') }}</h2>{%- endblock -%}
51+
<table class="table table-striped table-bordered table-condensed" data-module="table-toggle-more">
52+
{%- block additional_info_table_head -%}
53+
<thead>
54+
<tr>
55+
<th scope="col">{{ _('Field') }}</th>
56+
<th scope="col">{{ _('Value') }}</th>
57+
</tr>
58+
</thead>
59+
{%- endblock -%}
60+
<tbody>
61+
{%- block resource_last_updated -%}
62+
<tr>
63+
<th scope="row">{{ _('Data last updated') }}</th>
64+
<td>{{ h.render_datetime(res.last_modified) or h.render_datetime(res.created) or _('unknown') }}</td>
65+
</tr>
66+
{%- endblock -%}
67+
{%- block resource_metadata_last_updated -%}
68+
<tr>
69+
<th scope="row">{{ _('Metadata last updated') }}</th>
70+
<td>{{ h.render_datetime(res.metadata_modified) or h.render_datetime(res.created) or _('unknown') }}</td>
71+
</tr>
72+
{%- endblock -%}
73+
{%- block resource_created -%}
74+
<tr>
75+
<th scope="row">{{ _('Created') }}</th>
76+
<td>{{ h.render_datetime(res.created) or _('unknown') }}</td>
77+
</tr>
78+
{%- endblock -%}
79+
{%- block resource_format -%}
80+
<tr>
81+
<th scope="row">{{ _('Format') }}</th>
82+
<td>{{ res.format or res.mimetype_inner or res.mimetype or _('unknown') }}</td>
83+
</tr>
84+
{%- endblock -%}
85+
{%- block resource_license -%}
86+
<tr>
87+
<th scope="row">{{ _('License') }}</th>
88+
<td>{% snippet "snippets/license.html", pkg_dict=pkg, text_only=True %}</td>
89+
</tr>
90+
{%- endblock -%}
91+
{%- block resource_more_items -%}
92+
{% for key, value in h.format_resource_items(res.items()) %}
93+
{% if key not in ('created', 'metadata modified', 'last modified', 'format') %}
94+
<tr class="toggle-more"><th scope="row">{{ key | capitalize }}</th><td>{{ value }}</td></tr>
95+
{% endif %}
96+
{% endfor %}
97+
{%- endblock -%}
98+
{%- block resource_fields -%}
99+
{%- for field in schema.resource_fields -%}
100+
{%- if field.field_name not in exclude_fields
101+
and field.display_snippet is not none -%}
102+
<tr>
103+
<th scope="row">
104+
{{- h.scheming_language_text(field.label) -}}
105+
</th>
106+
<td>
107+
{%- snippet 'scheming/snippets/display_field.html',
108+
field=field, data=res, entity_type='dataset',
109+
object_type=dataset_type -%}
110+
</td>
111+
</tr>
112+
{%- endif -%}
113+
{%- endfor -%}
114+
{%- endblock -%}
115+
</tbody>
116+
</table>
117+
118+
119+
</div>
120+
{% endblock %}

ckanext/datavic_odp_theme/webassets/css/datavic_odp_theme.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,9 @@ nav {
17831783
.resource-read .table.table-striped p {
17841784
margin-bottom: 0; }
17851785

1786+
.resource-read .data-dictionary-table thead {
1787+
background-color: #f2f2f2; }
1788+
17861789
@media (min-width: 576px) {
17871790
.api-modal {
17881791
max-width: 80%; } }

0 commit comments

Comments
 (0)