Skip to content

Commit 78f7a50

Browse files
committed
review metadata view
1 parent fa0a4f4 commit 78f7a50

File tree

7 files changed

+67
-106
lines changed

7 files changed

+67
-106
lines changed

geonode_mapstore_client/client/themes/geonode/less/_metadata.less

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,31 +145,15 @@
145145
font-size: 1.5rem;
146146
padding: 0.5rem 0.75rem;
147147
}
148-
.gn-metadata-group {
148+
.gn-metadata-group:not(.gn-metadata-group-view) {
149149
max-width: 60ch;
150150
}
151151
.field-description {
152152
font-size: @font-size-sm;
153153
font-style: italic;
154154
}
155-
.gn-metadata-group-value {
156-
padding: 0.5rem 0;
157-
}
158155
.field {
159156
padding: 0 0.75rem;
160-
> label {
161-
a {
162-
position: absolute;
163-
transform: translate(-100%);
164-
opacity: 0;
165-
padding: 0 0.2rem;
166-
}
167-
&:hover {
168-
a {
169-
opacity: 1;
170-
}
171-
}
172-
}
173157
}
174158
.gn-metadata-group > .field-object {
175159
padding: 0.75rem;
@@ -181,6 +165,35 @@
181165
font-size: 0.9rem;
182166
border: none;
183167
}
168+
169+
dl {
170+
display: grid;
171+
grid-template-columns: max-content auto;
172+
padding: 0 0.75rem;
173+
dt {
174+
padding: 0.25rem;
175+
text-align: right;
176+
grid-column-start: 1;
177+
> label {
178+
margin: 0;
179+
a {
180+
position: absolute;
181+
transform: translate(-100%);
182+
opacity: 0;
183+
padding: 0 0.2rem;
184+
}
185+
&:hover {
186+
a {
187+
opacity: 1;
188+
}
189+
}
190+
}
191+
}
192+
dd {
193+
padding: 0.25rem;
194+
grid-column-start: 2;
195+
}
196+
}
184197
}
185198

186199
.gn-metadata-page {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<dt>
2+
<label id="{{prefix}}_{{name}}__label" class="control-label" for="{{prefix}}_{{name}}">
3+
<a href="#{{prefix}}_{{name}}__label"><i class="fa fa-link"></i></a>
4+
{{ property.schema.title|default:name }}
5+
</label>
6+
</dt>
7+
<dd>
8+
<div class="gn-metadata-group-value" id="{{prefix}}_{{name}}">
9+
{% include 'geonode-mapstore-client/snippets/metadata_field_value.html' with name=name property=property %}
10+
</div>
11+
</dd>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% if property.schema.format == 'date-time' %}
2+
{{property.value|date:"DATETIME_FORMAT"}}
3+
{% elif name == 'tkeywords' %}
4+
<ul>
5+
{% for t_id, tkeyword in property.value.items %}
6+
<li>{{tkeyword.schema.title|default:t_id}}</li>
7+
<ul>
8+
{%for tkeyword_item in tkeyword.value %}
9+
<li>
10+
{{tkeyword_item.label}}
11+
</li>
12+
{% endfor %}
13+
</ul>
14+
{% endfor %}
15+
</ul>
16+
{% else %}
17+
{{property.value}}
18+
{% endif %}
Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,7 @@
1-
1+
<dl>
22
{% for name, property in metadata.items %}
3-
<div class="form-group field field-{{property.schema.type}}">
4-
<label id="{{prefix}}_{{name}}__label" class="control-label" for="{{prefix}}_{{name}}">
5-
<a href="#{{prefix}}_{{name}}__label"><i class="fa fa-link"></i></a>
6-
{{ property.schema.title|default:name }}
7-
</label>
8-
{% if property.schema.description %}
9-
<p id="{{prefix}}_{{name}}__description" class="field-description">
10-
{{property.schema.description}}
11-
</p>
12-
{% endif %}
13-
{% if property.schema.type == 'object' %}
14-
<div class="gn-metadata-group-value" id="{{prefix}}_{{name}}">
15-
{%with prefix=""|add:prefix|add:'_'|add:name metadata=property.value template_name="geonode-mapstore-client/snippets/metadata_fields.html" %}
16-
{%include template_name %}
17-
{%endwith%}
18-
</div>
19-
{% elif property.schema.type == 'array' %}
20-
<div class="gn-metadata-group-value" id="{{prefix}}_{{name}}">
21-
{% if property.schema.items.type == 'object' %}
22-
<table class="table">
23-
<thead>
24-
{% for entry in property.schema.items.properties %}
25-
<th>{{entry}}</th>
26-
{% endfor %}
27-
</thead>
28-
<tbody>
29-
{% for entry in property.value %}
30-
<tr>
31-
{% for key, val in entry.items %}
32-
<td>{{val}}</td>
33-
{% endfor %}
34-
</tr>
35-
{% endfor %}
36-
</tbody>
37-
</table>
38-
{% else %}
39-
{% for entry in property.value %}
40-
{{entry}}
41-
{% endfor %}
42-
{% endif %}
43-
</div>
44-
{% else %}
45-
<div class="gn-metadata-group-value" id="{{prefix}}_{{name}}">
46-
{{property.value}}
47-
</div>
48-
{% endif %}
49-
</div>
3+
{% block property %}
4+
{% include 'geonode-mapstore-client/snippets/metadata_field.html' with prefix=prefix name=name property=property %}
5+
{% endblock property %}
506
{% endfor %}
7+
</dl>

geonode_mapstore_client/templates/geonode-mapstore-client/snippets/metadata_list.html

Lines changed: 0 additions & 36 deletions
This file was deleted.

geonode_mapstore_client/templates/geonode-mapstore-client/snippets/metadata_view.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<div class="gn-metadata">
33
<div class="gn-metadata-container">
44
<div class="gn-metadata-layout">
5-
{% include 'geonode-mapstore-client/snippets/metadata_list.html' with metadata_groups=metadata_groups prefix='metadata' title=resource.title title_id='gn-metadata-title' %}
65
<div class="gn-metadata-groups">
76
<div id="gn-metadata-title" class="gn-metadata-title">Metadata: {{resource.title}}</div>
87
{% for group_key, metadata in metadata_groups.items %}
9-
<div class="gn-metadata-group">
8+
<div class="gn-metadata-group gn-metadata-group-view">
109
<div class="gn-metadata-group-title">{{group_key}}</div>
1110
{% include 'geonode-mapstore-client/snippets/metadata_fields.html' with metadata=metadata prefix='metadata' %}
1211
</div>

geonode_mapstore_client/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11

22
from django.shortcuts import render
33
from django.utils.translation.trans_real import get_language_from_request
4-
from django.utils import formats
54
from dateutil import parser
65

76
def _parse_value(value, schema):
87
schema_type = schema.get('type')
98
format = schema.get('format')
109
if schema_type == 'string' and format in ['date-time']:
1110
if type(value) == str:
12-
return formats.date_format(parser.parse(value), "DATETIME_FORMAT")
13-
return formats.date_format(value, "DATETIME_FORMAT")
11+
return parser.parse(value)
12+
return value
1413
if schema_type == 'string':
1514
if 'oneOf' in schema:
1615
for option in schema.get('oneOf'):

0 commit comments

Comments
 (0)