From 38299e2dcc95af37f18a7a7780d52d85bdcf7a1f Mon Sep 17 00:00:00 2001 From: Benjamin Webb <40066515+webb-ben@users.noreply.github.com> Date: Mon, 27 Feb 2023 18:15:58 -0500 Subject: [PATCH] Show all columns in /items (#1148) - Show all columns on /items and overflow table in x direction. - Render properties missing keys as None in /items HTML table --- .../templates/collections/items/index.html | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/pygeoapi/templates/collections/items/index.html b/pygeoapi/templates/collections/items/index.html index e642aba..f81e4de 100644 --- a/pygeoapi/templates/collections/items/index.html +++ b/pygeoapi/templates/collections/items/index.html @@ -73,40 +73,61 @@ -
- - + +
+ {% set props = [] %} +
+ {% if data.get('uri_field') %} - - {% endif %} + {% set uri_field = data.uri_field %} + + {% elif data.get('title_field') %} + {% set title_field = data.title_field %} + + {% else %} - {% if data['title_field'] %} - - {% endif %} - {% for k, v in data['features'][0]['properties'].items() %} - {# start with id & title then take first 5 columns for table #} - {% if loop.index < 5 and k not in [data['id_field'], data['title_field'], data['uri_field'], 'extent'] %} + {% endif %} + + {% for k in data['features'][0]['properties'].keys() %} + {% if k not in [data.id_field, data.title_field, data.uri_field, 'extent'] %} + {% set props = props.append(k) %} - {% endif %} - {% endfor %} + {% endif %} + {% endfor %} - {% for ft in data['features'] %} + {% for ft in data.features %} {% if data.get('uri_field') %} - + {% set uri_field = data.uri_field %} + + {% elif data.get('title_field') %} + {% set title_field = data.title_field %} + + {% else %} + {% endif %} - - {% if data['title_field'] %} - - {% endif %} - {% for k, v in ft['properties'].items() %} - {% if loop.index < 5 and k not in [data['id_field'], data['title_field'], data['uri_field'], 'extent'] %} - - {% endif %} + + {% for prop in props %} + {% endfor %} + {% endfor %}
{{ data['uri_field'] }}{{ uri_field }}{{ title_field }}id{{ data['title_field'] }}{{ k }}
{{ft['properties'][data.get('uri_field')]}} + + {{ ft.properties.get(uri_field) }} + + + + {{ ft.properties.get(title_field) | string | truncate( 35 ) }} + + + + {{ ft.id | string | truncate( 12 ) }} + + {{ ft.id | string | truncate( 12 ) }}{{ ft['properties'][data['title_field']] | string | truncate( 35 ) }}{{ v | string | truncate( 35 ) }} + {{ ft.properties.get(prop, '') | string | truncate( 35 ) }} +