Skip to content

Commit

Permalink
Keep invalid RWD AoI on map
Browse files Browse the repository at this point in the history
Previous behavior allowed the AoI generated via RWD to remain displayed
on the map, even if it was invalid for analysis and modelling.  In a
recent refactor, this behavior was lost.  This commit restores the
functionality by allowing options to the reset function, based on the
feature invoking it.
  • Loading branch information
Matthew McFarland committed Aug 22, 2017
1 parent e860700 commit 8f4a1ab
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/mmw/js/src/draw/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,12 @@ var DrawWindow = Marionette.LayoutView.extend({

onShow: function() {
var self = this,
resetDrawingState = function() {
self.resetDrawingState();
};
resetRwdDrawingState = function() {
self.resetDrawingState({
clearOnFailure: false
});
},
resetDrawingState = _.bind(self.resetDrawingState, self);

this.selectBoundaryRegion.show(new SelectBoundaryView({
model: this.model,
Expand All @@ -189,24 +192,34 @@ var DrawWindow = Marionette.LayoutView.extend({
this.watershedDelineationRegion.show(
new WatershedDelineationView({
model: this.model,
resetDrawingState: resetDrawingState,
resetDrawingState: resetRwdDrawingState,
rwdTaskModel: this.rwdTaskModel
})
);

this.uploadFileRegion.show(new AoIUploadView({
model: this.model,
resetDrawingState: resetDrawingState,
resetDrawingState: resetDrawingState
}));
},

resetDrawingState: function() {
this.model.clearRwdClickedPoint(App.getLeafletMap());
resetDrawingState: function(options) {
var opts = _.extend({
clearOnFailure: true,
}, options);

this.rwdTaskModel.reset();
this.model.reset();

utils.cancelDrawing(App.getLeafletMap());
clearAoiLayer();

// RWD typically does not clear the AoI generated, even if it
// not possible to move to analyze
if (opts.clearOnFailure) {
clearAoiLayer();
this.model.clearRwdClickedPoint(App.getLeafletMap());
}

clearBoundaryLayer(this.model);
}
});
Expand Down

0 comments on commit 8f4a1ab

Please sign in to comment.