diff --git a/observations/static/observations/js/observationList.js b/observations/static/observations/js/observationList.js index 563a0efb6e6e2221d267ace626564a5847d417b2..44e06cdb98bb3dfdc132fa9e9b5a7913c85efd73 100644 --- a/observations/static/observations/js/observationList.js +++ b/observations/static/observations/js/observationList.js @@ -55,6 +55,7 @@ var initMap = function( pestId, cropId, cropCategoryId, + includeNegative, customAgeColors ) { @@ -142,6 +143,10 @@ var initMap = function( { params.push("cropCategoryId=" + cropCategoryId); } + if(includeNegative == null || !includeNegative) + { + params.push("isPositive=true"); + } if(settings.userUuid != null) { params.push("userUUID=" + settings.userUuid); @@ -617,15 +622,15 @@ var getDaysSince = function(JSONDate) * Sets colors and values for the map legend * @returns */ -function initMapLegend() +function initMapLegend(includeNegative) { var lBox = document.getElementById("legend"); var html = "<div><strong>" + gettext("Days since observation") + "</strong></div><ul>"; for(var i in ageColors) { - html += '<li><i style="color: ' + ageColors[i][1] + ';" class="fa fa-square" aria-hidden="true"></i>/' + '<i style="color: ' + negativeObsAgeColors[i][1] + ';" class="fa fa-square" aria-hidden="true"></i> ' + (i > 0 ? ageColors[i-1][0] + 1 : '0') + '-' + ageColors[i][0] + ' ' + gettext("Days").toLowerCase() + '</li>'; + html += '<li><i style="color: ' + ageColors[i][1] + ';" class="fa fa-square" aria-hidden="true"></i>' + (includeNegative ? '/<i style="color: ' + negativeObsAgeColors[i][1] + ';" class="fa fa-square" aria-hidden="true"></i> ' : ' ') + (i > 0 ? ageColors[i-1][0] + 1 : '0') + '-' + ageColors[i][0] + ' ' + gettext("Days").toLowerCase() + '</li>'; } - html += '<li><i style="color: black;" class="fa fa-square" aria-hidden="true"></i>/<i style="color: black;" class="fa fa-square-o" aria-hidden="true"></i> ' + gettext("Older") + '</li>'; + html += '<li><i style="color: black;" class="fa fa-square" aria-hidden="true"></i>' + (includeNegative ? '/<i style="color: black;" class="fa fa-square-o" aria-hidden="true"></i> ' : ' ') + gettext("Older") + '</li>'; html += "</ul>"; lBox.innerHTML = html; } diff --git a/observations/templates/observations/index.html b/observations/templates/observations/index.html index 7ed854a2da83dfb5843e0511aabdeedeb0cf3aca..8a9026aa8e554ce924942bc1603a677bb8616c76 100644 --- a/observations/templates/observations/index.html +++ b/observations/templates/observations/index.html @@ -54,6 +54,11 @@ <select name="cropCategoryId" id="cropCategoryList" style="min-width: 150px;" class="form-control chosen-select" data-placeholder="{% trans "Crop categories" %}"> </select> </div> + <div class="checkbox"> + <label> + <input type="checkbox" name="includeNegative"{% if include_negative %}checked{% endif %}> {% trans "Include registrations without pest presence" %} + </label> + </div> <button type="submit" class="btn btn-primary">{% trans "Filter" %}</button> </form> <div class="table-responsive"> @@ -123,11 +128,12 @@ "{{to|safe}}", {{pest_id|default:"null"}}, {{crop_id|default:"null"}}, - {{crop_category_id|default:"null"}} + {{crop_category_id|default:"null"}}, + {% if include_negative %}true{%else%}false{% endif %}, ); }); - initMapLegend(); + initMapLegend({% if include_negative %}true{%else%}false{% endif %}); initForm({{settings.VIPS_ORGANIZATION_ID}}, {{pest_id|default:"null"}}, diff --git a/observations/views.py b/observations/views.py index b0486ab48974c6f92dbb9c174a70886819e1dbda..56d52329e2a2281777602497f208b5da6cee29c9 100755 --- a/observations/views.py +++ b/observations/views.py @@ -61,6 +61,7 @@ def index(request): "crop_id" : request.GET.get("cropId", None), "crop_category_id": request.GET.get("cropCategoryId", None), "crop_categories": CropCategory.get_crop_categories(translation.get_language()), + "include_negative": True if request.GET.get("includeNegative", None) is not None else False, "organization_id": organization_id } return render(request, 'observations/index.html', context)