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 @@ -
| {{ data['uri_field'] }} | - {% endif %} + {% set uri_field = data.uri_field %} +{{ uri_field }} | + {% elif data.get('title_field') %} + {% set title_field = data.title_field %} +{{ title_field }} | + {% else %}id | - {% if data['title_field'] %} -{{ 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) %}{{ k }} | - {% endif %} - {% endfor %} + {% endif %} + {% endfor %}||
|---|---|---|---|---|---|---|---|
| {{ft['properties'][data.get('uri_field')]}} | + {% set uri_field = data.uri_field %} ++ + {{ ft.properties.get(uri_field) }} + + | + {% elif data.get('title_field') %} + {% set title_field = data.title_field %} ++ + {{ ft.properties.get(title_field) | string | truncate( 35 ) }} + + | + {% else %} ++ + {{ ft.id | string | truncate( 12 ) }} + + | {% endif %} -{{ ft.id | string | truncate( 12 ) }} | - {% if data['title_field'] %} -{{ ft['properties'][data['title_field']] | string | truncate( 35 ) }} | - {% 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'] %} -{{ v | string | truncate( 35 ) }} | - {% endif %} + + {% for prop in props %} ++ {{ ft.properties.get(prop, '') | string | truncate( 35 ) }} + | {% endfor %} +