Skip to content

Commit

Permalink
Merge pull request #34842 from dimagi/ze/refresh-warning-on-save-polygon
Browse files Browse the repository at this point in the history
Refresh Warning After Saving Polygon (Geospatial)
  • Loading branch information
zandre-eng authored Jul 3, 2024
2 parents e743ec4 + de2862b commit 2a892a9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
4 changes: 2 additions & 2 deletions corehq/apps/geospatial/static/geospatial/js/geospatial_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ hqDefine("geospatial/js/geospatial_map", [
function showMapControls(state) {
$("#geospatial-map").toggle(state);
$("#case-buttons").toggle(state);
$("#mapControls").toggle(state);
$("#polygon-filters").toggle(state);
$("#user-filters-panel").toggle(state);
}

Expand Down Expand Up @@ -233,7 +233,7 @@ hqDefine("geospatial/js/geospatial_map", [

function initPolygonFilters() {
// Assumes `map` var is initialized
const $mapControlDiv = $("#mapControls");
const $mapControlDiv = $("#polygon-filters");
polygonFilterModel = new models.PolygonFilter(mapModel, false, true);
polygonFilterModel.loadPolygons(initialPageData.get('saved_polygons'));
if ($mapControlDiv.length) {
Expand Down
1 change: 1 addition & 0 deletions corehq/apps/geospatial/static/geospatial/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ hqDefine('geospatial/js/models', [
);
// redraw using mapControlsModelInstance
self.selectedSavedPolygonId(ret.id);
self.shouldRefreshPage(true);
},
error: function () {
alertUser.alert_user(gettext(unexpectedErrorMessage), 'danger');
Expand Down
19 changes: 1 addition & 18 deletions corehq/apps/geospatial/templates/case_grouping_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,7 @@
</div>
</div>

<div class="panel" id="polygon-filters">
<div class="row">
{% include 'geospatial/partials/saved_polygon_filter.html' %}
</div>
<div class="alert alert-info" style="margin-top:10px;" data-bind="visible: shouldRefreshPage">
{% blocktrans %}
Please
<a href="">refresh the page</a>
to apply the polygon filtering changes.
{% endblocktrans %}
</div>
<div class="alert alert-warning" data-bind="visible: hasUrlError">
{% blocktrans %}
There are too many polygons on the map. Please remove some before refreshing the page, otherwise the
newly added polygons will be lost.
{% endblocktrans %}
</div>
</div>
{% include 'geospatial/partials/saved_polygon_filter.html' with uses_disbursement='false' %}
<div id="case-grouping-map" style="height: 500px"></div>

<div class="panel-body-datatable">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
{% load i18n %}

<div class="col-sm-8">
<div class="row form-horizontal">
<label for="saved-polygons" class="control-label col-sm-2">
{% trans "Filter by Saved Area" %}
</label>
<div class="col-sm-5" style="display:flex">
<select id="saved-polygons"
class="form-control"
data-bind="select2: savedPolygons,value: selectedSavedPolygonId,">
</select>
<button class="btn btn-default" data-bind="click: clearSelectedPolygonFilter, visible: selectedSavedPolygonId">
<i class="fa fa-remove"></i>
</button>
</div>
<div class="col-sm-5">
<a class="btn btn-default" data-bind="click: exportSelectedPolygonGeoJson, visible: selectedSavedPolygonId">
{% trans 'Export Area' %}
</a>
<button class="btn btn-danger" data-toggle="modal" data-target="#delete-saved-area-modal"
data-bind="visible: selectedSavedPolygonId">
<i class="fa fa-trash"></i>
{% trans 'Delete Area' %}
</button>
<div class="panel" id="polygon-filters">
<div class="row">
<div class="col-sm-8">
<div class="row form-horizontal">
<label for="saved-polygons" class="control-label col-sm-2">
{% trans "Filter by Saved Area" %}
</label>
<div class="col-sm-5" style="display:flex">
<select id="saved-polygons"
class="form-control"
data-bind="select2: savedPolygons,value: selectedSavedPolygonId,">
</select>
<button class="btn btn-default" data-bind="click: clearSelectedPolygonFilter, visible: selectedSavedPolygonId">
<i class="fa fa-remove"></i>
</button>
</div>
<div class="col-sm-5">
<a class="btn btn-default" data-bind="click: exportSelectedPolygonGeoJson, visible: selectedSavedPolygonId">
{% trans 'Export Area' %}
</a>
<button class="btn btn-danger" data-toggle="modal" data-target="#delete-saved-area-modal"
data-bind="visible: selectedSavedPolygonId">
<i class="fa fa-trash"></i>
{% trans 'Delete Area' %}
</button>
</div>
</div>
</div>
<button id="btnSaveDrawnArea" class="btn btn-default" style="float:right; margin-right:1em"
data-bind="attr: { disabled: btnSaveDisabled }, click: saveGeoPolygon">
{% trans 'Save Area' %}
</button>
{% include 'geospatial/partials/delete_saved_area_modal.html' %}
{% if uses_disbursement == 'true' %}
<a id="btnRunDisbursement" class="col-sm-2 btn btn-primary" style="float:right; margin-right:1em" data-bind="attr: { disabled: btnRunDisbursementDisabled }">
{% trans 'Run Disbursement' %}
</a>
{% endif %}
</div>
<div class="alert alert-info" style="margin-top:10px;" data-bind="visible: shouldRefreshPage">
{% blocktrans %}
Please
<a href="">refresh the page</a>
to apply the polygon filtering changes.
{% endblocktrans %}
</div>
<div class="alert alert-warning" data-bind="visible: hasUrlError">
{% blocktrans %}
There are too many polygons on the map. Please remove some before refreshing the page, otherwise the
newly added polygons will be lost.
{% endblocktrans %}
</div>
</div>
<button id="btnSaveDrawnArea" class="btn btn-default" style="float:right; margin-right:1em"
data-bind="attr: { disabled: btnSaveDisabled }, click: saveGeoPolygon">
{% trans 'Save Area' %}
</button>
{% include 'geospatial/partials/delete_saved_area_modal.html' %}
7 changes: 1 addition & 6 deletions corehq/apps/geospatial/templates/map_visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@
</button>
</div>
</div>
<div class="row panel" id="mapControls">
{% include 'geospatial/partials/saved_polygon_filter.html' %}
<a id="btnRunDisbursement" class="col-sm-2 btn btn-primary" style="float:right; margin-right:1em" data-bind="attr: { disabled: btnRunDisbursementDisabled }">
{% trans 'Run Disbursement' %}
</a>
</div>
{% include 'geospatial/partials/saved_polygon_filter.html' with uses_disbursement='true' %}
<div id="disbursement-spinner">
<h4 id="loading" class="hide"
data-bind="visible: isBusy(), css: {hide: false}">
Expand Down

0 comments on commit 2a892a9

Please sign in to comment.