@@ -131,12 +131,15 @@ <h1 class="govuk-heading-xl">{{ row_name }}</h1>
131
131
} %}
132
132
{% set jsonHTML %}
133
133
{% 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 >
134
137
< a href ="{{geometry_json_url}} "
135
138
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 >
140
143
< div id ="spinner " style ="display: none; ">
141
144
< div class ="dl-map__spinning-loader " style ="width: 10px; height: 10px;margin-top: -25px "> </ div >
142
145
</ div >
@@ -406,12 +409,13 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
406
409
} )
407
410
. catch ( error => {
408
411
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 ' ;
410
413
// Create and append the download button
411
414
const downloadButton = document . createElement ( 'a' ) ;
412
415
downloadButton . href = '{{ geometry_url }}' ;
413
- downloadButton . className = 'govuk-button govuk-button--secondary ' ;
416
+ downloadButton . className = 'govuk-button' ;
414
417
downloadButton . style . marginTop = '10px' ;
418
+ downloadButton . style . marginBottom = '10px' ;
415
419
downloadButton . textContent = 'Download GeoJSON' ;
416
420
downloadButton . setAttribute ( 'download' , '{{ row["entity"] }}.geojson' ) ;
417
421
geojsonContentElement . parentElement . appendChild ( downloadButton ) ;
@@ -432,6 +436,7 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
432
436
} ) ;
433
437
434
438
document . getElementById ( 'download-json-button' ) . addEventListener ( 'click' , async function ( event ) {
439
+ event . preventDefault ( ) ;
435
440
const downloadButton = document . getElementById ( "download-json-button" ) ;
436
441
//const downloadText = document.getElementById("download-text");
437
442
const spinner = document . getElementById ( "spinner" ) ;
@@ -448,12 +453,13 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
448
453
throw new Error ( "Failed to fetch the file" ) ;
449
454
}
450
455
const blob = await response . blob ( ) ;
451
-
452
456
// Create a Blob URL and trigger the download
453
457
const url = URL . createObjectURL ( blob ) ;
454
458
const a = document . createElement ( "a" ) ;
455
459
a . href = url ;
460
+ a . download = "{{ row['entity'] }}.json" ;
456
461
document . body . appendChild ( a ) ;
462
+
457
463
a . click ( ) ;
458
464
document . body . removeChild ( a ) ;
459
465
@@ -465,7 +471,7 @@ <h3 class="govuk-heading-s">{{ type|capitalize }}</h3>
465
471
// Restore button and hide spinner
466
472
downloadButton . disabled = false ;
467
473
spinner . style . display = "none" ;
468
- downloadText . style . display = "inline" ;
474
+ // downloadText.style.display = "inline";
469
475
}
470
476
} ) ;
471
477
</ script >
0 commit comments