Skip to content
Snippets Groups Projects
Commit db1184c4 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Add observation.is_positive [VIPSUTV-469]

parent b43f39b0
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,7 @@ var initMap = function( ...@@ -55,6 +55,7 @@ var initMap = function(
pestId, pestId,
cropId, cropId,
cropCategoryId, cropCategoryId,
includeNegative,
customAgeColors customAgeColors
) )
{ {
...@@ -142,6 +143,10 @@ var initMap = function( ...@@ -142,6 +143,10 @@ var initMap = function(
{ {
params.push("cropCategoryId=" + cropCategoryId); params.push("cropCategoryId=" + cropCategoryId);
} }
if(includeNegative == null || !includeNegative)
{
params.push("isPositive=true");
}
if(settings.userUuid != null) if(settings.userUuid != null)
{ {
params.push("userUUID=" + settings.userUuid); params.push("userUUID=" + settings.userUuid);
...@@ -617,15 +622,15 @@ var getDaysSince = function(JSONDate) ...@@ -617,15 +622,15 @@ var getDaysSince = function(JSONDate)
* Sets colors and values for the map legend * Sets colors and values for the map legend
* @returns * @returns
*/ */
function initMapLegend() function initMapLegend(includeNegative)
{ {
var lBox = document.getElementById("legend"); var lBox = document.getElementById("legend");
var html = "<div><strong>" + gettext("Days since observation") + "</strong></div><ul>"; var html = "<div><strong>" + gettext("Days since observation") + "</strong></div><ul>";
for(var i in ageColors) 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>"; html += "</ul>";
lBox.innerHTML = html; lBox.innerHTML = html;
} }
......
...@@ -54,6 +54,11 @@ ...@@ -54,6 +54,11 @@
<select name="cropCategoryId" id="cropCategoryList" style="min-width: 150px;" class="form-control chosen-select" data-placeholder="{% trans "Crop categories" %}"> <select name="cropCategoryId" id="cropCategoryList" style="min-width: 150px;" class="form-control chosen-select" data-placeholder="{% trans "Crop categories" %}">
</select> </select>
</div> </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> <button type="submit" class="btn btn-primary">{% trans "Filter" %}</button>
</form> </form>
<div class="table-responsive"> <div class="table-responsive">
...@@ -123,11 +128,12 @@ ...@@ -123,11 +128,12 @@
"{{to|safe}}", "{{to|safe}}",
{{pest_id|default:"null"}}, {{pest_id|default:"null"}},
{{crop_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}}, initForm({{settings.VIPS_ORGANIZATION_ID}},
{{pest_id|default:"null"}}, {{pest_id|default:"null"}},
......
...@@ -61,6 +61,7 @@ def index(request): ...@@ -61,6 +61,7 @@ def index(request):
"crop_id" : request.GET.get("cropId", None), "crop_id" : request.GET.get("cropId", None),
"crop_category_id": request.GET.get("cropCategoryId", None), "crop_category_id": request.GET.get("cropCategoryId", None),
"crop_categories": CropCategory.get_crop_categories(translation.get_language()), "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 "organization_id": organization_id
} }
return render(request, 'observations/index.html', context) return render(request, 'observations/index.html', context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment