Skip to content

Commit 73f2928

Browse files
committed
Adding green button and inset
1 parent d0f1271 commit 73f2928

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

application/core/filters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def digital_land_to_json(dict):
173173
if "geometry" in filtered_dict:
174174
filtered_dict[
175175
"geometry"
176-
] = "<i>Too large to display. Download JSON for full geometry.</i>"
176+
] = "<b>Too large to display. Download JSON for full geometry.</b>"
177177
# dict["geometry"] = dict["geometry"][:1000]
178178
return json.dumps(
179179
filtered_dict, default=str, indent=4, cls=NoneToEmptyStringEncoder

application/templates/entity.html

+14-8
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,15 @@ <h1 class="govuk-heading-xl">{{ row_name }}</h1>
131131
} %}
132132
{% set jsonHTML %}
133133
{% if is_truncated %}
134+
<div class="govuk-inset-text" style="font-size: 15px; margin-top: -10px;">
135+
The geometry is too large to be included in the JSON below. Download JSON for the full geometry.
136+
</div>
134137
<a href="{{geometry_json_url}}"
135138
id = "download-json-button"
136-
class="govuk-button govuk-button--secondary"
137-
style="margin-bottom: 10px;"
138-
download>
139-
<span id="download-text">Download JSON</span>
139+
class="govuk-button"
140+
style="margin-bottom: 10px; margin-top: -10px;"
141+
download>
142+
<span id="download-text">Download JSON</span>
140143
<div id="spinner" style="display: none;">
141144
<div class="dl-map__spinning-loader" style="width: 10px; height: 10px;margin-top: -25px "></div>
142145
</div>
@@ -406,12 +409,13 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
406409
})
407410
.catch(error => {
408411
console.error('Error loading GeoJSON:', error);
409-
geojsonContentElement.innerHTML = 'Too large to display. Download GeoJSON instead. ';
412+
geojsonContentElement.innerHTML = '<b>Too large to display. Download GeoJSON instead.</b ';
410413
// Create and append the download button
411414
const downloadButton = document.createElement('a');
412415
downloadButton.href = '{{ geometry_url }}';
413-
downloadButton.className = 'govuk-button govuk-button--secondary';
416+
downloadButton.className = 'govuk-button';
414417
downloadButton.style.marginTop = '10px';
418+
downloadButton.style.marginBottom = '10px';
415419
downloadButton.textContent = 'Download GeoJSON';
416420
downloadButton.setAttribute('download', '{{ row["entity"] }}.geojson');
417421
geojsonContentElement.parentElement.appendChild(downloadButton);
@@ -432,6 +436,7 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
432436
});
433437

434438
document.getElementById('download-json-button').addEventListener('click', async function (event) {
439+
event.preventDefault();
435440
const downloadButton = document.getElementById("download-json-button");
436441
//const downloadText = document.getElementById("download-text");
437442
const spinner = document.getElementById("spinner");
@@ -448,12 +453,13 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
448453
throw new Error("Failed to fetch the file");
449454
}
450455
const blob = await response.blob();
451-
452456
// Create a Blob URL and trigger the download
453457
const url = URL.createObjectURL(blob);
454458
const a = document.createElement("a");
455459
a.href = url;
460+
a.download = "{{ row['entity'] }}.json";
456461
document.body.appendChild(a);
462+
457463
a.click();
458464
document.body.removeChild(a);
459465

@@ -465,7 +471,7 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
465471
// Restore button and hide spinner
466472
downloadButton.disabled = false;
467473
spinner.style.display = "none";
468-
downloadText.style.display = "inline";
474+
//downloadText.style.display = "inline";
469475
}
470476
});
471477
</script>

0 commit comments

Comments
 (0)