0001-backoffice-display-demands-as-coloured-circle-marker.patch
tests/test_backoffice_pages.py | ||
---|---|---|
928 | 928 |
resp = app.get('/backoffice/management/form-title/geojson') |
929 | 929 |
assert len(resp.json['features']) == 1 |
930 | 930 |
assert resp.json['features'][0]['geometry']['coordinates'] == [2.32, 48.83] |
931 |
assert 'status_colour' in resp.json['features'][0]['properties'] |
|
932 |
assert resp.json['features'][0]['properties']['status_colour'] == '#66FF00' |
|
931 | 933 | |
932 | 934 |
resp = app.get('/backoffice/management/form-title/geojson?filter=pending&filter-status=on') |
933 | 935 |
assert len(resp.json['features']) == 1 |
wcs/backoffice/management.py | ||
---|---|---|
68 | 68 |
if not formdata.geolocations or not geoloc_key in formdata.geolocations: |
69 | 69 |
continue |
70 | 70 |
coords = formdata.geolocations[geoloc_key] |
71 |
try: |
|
72 |
status_colour = formdata.get_status().colour |
|
73 |
except AttributeError: |
|
74 |
status_colour = 'ffffff' |
|
75 | ||
71 | 76 |
feature = { |
72 | 77 |
'type': 'Feature', |
73 | 78 |
'properties': { |
74 | 79 |
'name': formdata.get_display_name(), |
75 | 80 |
'url': formdata.get_url(backoffice=True), |
81 |
'status_colour': '#%s' % status_colour |
|
76 | 82 |
}, |
77 | 83 |
'geometry': { |
78 | 84 |
'type': 'Point', |
wcs/qommon/static/css/dc2/admin.css | ||
---|---|---|
939 | 939 |
stroke-width: 2px; |
940 | 940 |
} |
941 | 941 | |
942 |
/* Styling for Leaflet's circle markers */ |
|
943 | ||
944 |
.leaflet-map-pane svg { |
|
945 |
width: auto; |
|
946 |
height: auto; |
|
947 |
} |
|
948 | ||
942 | 949 |
.foldable { |
943 | 950 |
cursor: pointer; |
944 | 951 |
} |
wcs/qommon/static/js/qommon.map.js | ||
---|---|---|
80 | 80 |
$map_widget.parent().parent().find('label').addClass('activity') |
81 | 81 |
map.locate({timeout: 10000, maximumAge: 300000, enableHighAccuracy: false}); |
82 | 82 |
} |
83 |
if ($(this).data('geojson-url')) { |
|
84 |
$.getJSON($(this).data('geojson-url'), function(data) { |
|
85 |
var geo_json = L.geoJson(data, { |
|
86 |
onEachFeature: function(feature, layer) { |
|
87 |
layer.on('click', function() { |
|
88 |
window.location = feature.properties.url; |
|
89 |
return false; |
|
90 |
}); |
|
91 |
} |
|
92 |
}); |
|
93 |
map.fitBounds(geo_json.getBounds()); |
|
94 |
geo_json.addTo(map); |
|
95 |
}); |
|
96 |
} |
|
97 | 83 | |
98 | 84 |
$(document).on('backoffice-filter-change', function(event, listing_settings) { |
99 | 85 |
$('.qommon-map').each(function() { |
... | ... | |
110 | 96 |
window.location = feature.properties.url; |
111 | 97 |
return false; |
112 | 98 |
}); |
99 |
}, |
|
100 |
pointToLayer: function (feature, latlng) { |
|
101 |
return L.circleMarker(latlng, { |
|
102 |
radius: 9, |
|
103 |
fillColor: feature.properties.status_colour, |
|
104 |
color: "#000", |
|
105 |
weight: 2, |
|
106 |
opacity: 1, |
|
107 |
fillOpacity: 0.9}); |
|
113 | 108 |
} |
114 | 109 |
}); |
115 | 110 |
map.fitBounds(geo_json.getBounds()); |
... | ... | |
117 | 112 |
}); |
118 | 113 |
}); |
119 | 114 |
}); |
115 |
if ($(this).data('geojson-url')) { |
|
116 |
$(document).trigger('backoffice-filter-change', $('form#listing-settings').serialize()); |
|
117 |
} |
|
120 | 118 |
}); |
121 | 119 |
}); |
122 |
- |