Commit 8d3aef30 authored by Eric Duminil's avatar Eric Duminil
Browse files

Hide "select all" and "none" when required.

Refresh after download.
parent 9c10c90a
Showing with 17 additions and 12 deletions
+17 -12
...@@ -95,6 +95,8 @@ public void downloadRegionFromCityGMLs(String wktPolygon, String project, String ...@@ -95,6 +95,8 @@ public void downloadRegionFromCityGMLs(String wktPolygon, String project, String
} }
} }
} }
refreshHulls();
} }
public void selectRepository() { public void selectRepository() {
......
...@@ -163,7 +163,7 @@ var regionChooser = (function(){ ...@@ -163,7 +163,7 @@ var regionChooser = (function(){
intersections.addFeature(intersection); intersections.addFeature(intersection);
var link = '<li>' var link = '<li>'
// TODO: If possible, highlight the corresponding polygon when hovering above a name. // TODO: If possible, highlight the corresponding polygon when hovering above a name.
link += '<input type="checkbox" id="citygml_' + feature.getId() + '" class="select_citygml" onclick="regionChooser.canDownload();"><label for="citygml_' + feature.getId() + '">' + feature['name'] + '</label>'; link += '<input type="checkbox" id="citygml_' + feature.getId() + '" class="select_citygml" onclick="regionChooser.isDownloadPossible();"><label for="citygml_' + feature.getId() + '">' + feature['name'] + '</label>';
link += " (" + citygml_percentage + "%"; link += " (" + citygml_percentage + "%";
if (sketch_percentage == 100) { if (sketch_percentage == 100) {
...@@ -172,15 +172,14 @@ var regionChooser = (function(){ ...@@ -172,15 +172,14 @@ var regionChooser = (function(){
dataPanel.append(link + ")\n"); dataPanel.append(link + ")\n");
} }
publicScope.canDownload = function(){ publicScope.isDownloadPossible = function(){
var count = 0; var count = 0;
console.log("...");
document.querySelectorAll("input.select_citygml").forEach(c => { document.querySelectorAll("input.select_citygml").forEach(c => {
if (c.checked){ if (c.checked){
count += 1; count += 1;
} }
}); });
document.getElementById("download").disabled = (count == 0); document.getElementById("download_region_button").disabled = (count == 0);
} }
function findIntersection(feature, polygon) { function findIntersection(feature, polygon) {
...@@ -210,10 +209,10 @@ var regionChooser = (function(){ ...@@ -210,10 +209,10 @@ var regionChooser = (function(){
}); });
if (intersection_found) { if (intersection_found) {
document.getElementById("download").style.visibility = 'visible'; document.getElementById("download_region").style.visibility = 'visible';
} }
else { else {
document.getElementById("download").style.visibility = 'hidden'; document.getElementById("download_region").style.visibility = 'hidden';
dataPanel.append("No intersection found with any CityGML file.<br/>\n"); dataPanel.append("No intersection found with any CityGML file.<br/>\n");
} }
} }
...@@ -248,8 +247,9 @@ var regionChooser = (function(){ ...@@ -248,8 +247,9 @@ var regionChooser = (function(){
var time = end - start; var time = end - start;
console.log('Download Execution time: ' + (time / 1000).toFixed(3) + 's'); console.log('Download Execution time: ' + (time / 1000).toFixed(3) + 's');
setTimeout(function() { setTimeout(function() {
document.getElementById("download").disabled = false; document.getElementById("download_region_button").disabled = false;
document.documentElement.className = ''; // Stop waiting document.documentElement.className = ''; // Stop waiting
resetDrawing();
}, 100); }, 100);
} else { } else {
var msg = "ERROR : Unknown coordinate system : \"" + srsName + "\". Cannot extract any region"; var msg = "ERROR : Unknown coordinate system : \"" + srsName + "\". Cannot extract any region";
...@@ -277,10 +277,13 @@ var regionChooser = (function(){ ...@@ -277,10 +277,13 @@ var regionChooser = (function(){
dataPanel.append("WGS84 Coordinates<br/>"); dataPanel.append("WGS84 Coordinates<br/>");
dataPanel.append(wgs84_coords + "<br/>\n"); dataPanel.append(wgs84_coords + "<br/>\n");
} }
//NOTE: Could show m², ha or km² depending on magnitude
dataPanel.append("<h3 class='clean'>Area : " + (area / 10000).toFixed(1) + " ha\n"); dataPanel.append("<h3 class='clean'>Area : " + (area / 10000).toFixed(1) + " ha\n");
dataPanel.append('<button type="button" onclick="regionChooser.downloadFromSelectedCityGMLs()" id="download" style="visibility:hidden" disabled>Download Region</button><br/>\n'); dataPanel.append('<div style="visibility:hidden" id="download_region">' +
dataPanel.append('<a href="#" onclick="regionChooser.checkCityGMLS(true);">(Select All)</a>'); '<button type="button" onclick="regionChooser.downloadFromSelectedCityGMLs()" id="download_region_button" disabled>Download Region</button><br/>\n' +
dataPanel.append('<a href="#" onclick="regionChooser.checkCityGMLS(false);">(Select None)</a>'); '<a href="#" onclick="regionChooser.checkCityGMLS(true);">(Select All)</a>\n' +
'<a href="#" onclick="regionChooser.checkCityGMLS(false);">(Select None)</a>\n'+
'</div><br/>\n');
dataPanel.append('<br/>\n'); dataPanel.append('<br/>\n');
findIntersections(); findIntersections();
} }
...@@ -373,14 +376,14 @@ var regionChooser = (function(){ ...@@ -373,14 +376,14 @@ var regionChooser = (function(){
if (checkedBoxes.length === 0){ if (checkedBoxes.length === 0){
console.log("You should select at least one citygml, though."); console.log("You should select at least one citygml, though.");
} else{ } else{
document.getElementById("download").disabled = true; document.getElementById("download_region_button").disabled = true;
publicScope.downloadRegionFromCityGMLs(checkedBoxes.map(c => c.id)); publicScope.downloadRegionFromCityGMLs(checkedBoxes.map(c => c.id));
} }
} }
publicScope.checkCityGMLS = function(allOrNone) { publicScope.checkCityGMLS = function(allOrNone) {
document.querySelectorAll("input.select_citygml").forEach(c => c.checked = allOrNone); document.querySelectorAll("input.select_citygml").forEach(c => c.checked = allOrNone);
publicScope.canDownload(); publicScope.isDownloadPossible();
} }
publicScope.selectRepository = function() { publicScope.selectRepository = function() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment