From 8f4a1ab4b5957d0028612cee896f7b0547d2fb0f Mon Sep 17 00:00:00 2001 From: Matthew McFarland Date: Tue, 22 Aug 2017 09:32:49 -0400 Subject: [PATCH] Keep invalid RWD AoI on map 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. --- src/mmw/js/src/draw/views.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/mmw/js/src/draw/views.js b/src/mmw/js/src/draw/views.js index e6088b519..507ff3ead 100644 --- a/src/mmw/js/src/draw/views.js +++ b/src/mmw/js/src/draw/views.js @@ -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, @@ -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); } });