Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Don't allow submitting without a shape
Browse files Browse the repository at this point in the history
  • Loading branch information
Egil Moeller committed Jan 30, 2015
1 parent 82347eb commit c1b41fb
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions digitizer/maphandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,35 @@ App.prototype.loadGuide = function() {

App.prototype.getAnswer = function(cb, isDone) {
var app = this;
var errs = [];
var drillpads = app.map.getLayer('drillpads');
if (!app.answer) app.answer = {};
if ((isDone || app.answer.selection == "done") && drillpads.features.length > 0) {
var geojson = new OpenLayers.Format.GeoJSON();
drillpads.mod.deactivate();
app.answer.shapes = drillpads.features.map(function(feature) {
return JSON.parse(geojson.write(feature.geometry.clone().transform(
app.map.getProjectionObject(), app.getTaskProjection()
)));
if (isDone || app.answer.selection == "done") {
if (drillpads.features.length > 0) {
var geojson = new OpenLayers.Format.GeoJSON();
drillpads.mod.deactivate();
app.answer.shapes = drillpads.features.map(function(feature) {
return JSON.parse(geojson.write(feature.geometry.clone().transform(
app.map.getProjectionObject(), app.getTaskProjection()
)));
});
drillpads.mod.activate();
} else {
errs.push("You have to finish marking at least one area to continue. Doubble click on the imagery to finish.");
}
}
if (errs.length == 0 || isDone) {
BaseOpenlayersApp.prototype.getAnswer.call(this, cb);
} else {
var dialog = $('<div class="modal fade" id="error" tabindex="-1" role="dialog" aria-labelledby="errorLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header bg-danger text-danger"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title" id="errorLabel">Unable to submit</h4></div><div class="modal-body alert"></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button></div></div></div></div>');
dialog.find(".modal-body").html(errs.join('<br>'));
$('body').append(dialog);
dialog.modal();
dialog.on('hidden.bs.modal', function (e) {
dialog.detach();
app.loadingEnded();
});
drillpads.mod.activate();
}
BaseOpenlayersApp.prototype.getAnswer.call(this, cb);
}

App.prototype.updateMap = function(info) {
Expand Down

0 comments on commit c1b41fb

Please sign in to comment.