aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-02-08 13:49:41 +0000
committerMatthew Somerville <matthew@mysociety.org>2013-02-08 13:49:41 +0000
commitd41b500e09fcc5ca348e9f4f6886bfc1b1e50d8b (patch)
treefe2a7713683d4ac387c17e8536e369052344a837
parente3bce6312ed59ccd462cae69d214efdb1c19cbbc (diff)
Allow Zurich admin to change location of pin, with confirmation (fixes a1).
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm1
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm12
-rw-r--r--templates/web/zurich/admin/report_edit-sdm.html2
-rw-r--r--templates/web/zurich/admin/report_edit.html3
-rw-r--r--web/js/map-wmts-zurich.js29
5 files changed, 46 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 2ade99450..0f072b9a2 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -622,6 +622,7 @@ sub report_edit : Path('report_edit') : Args(1) {
$c->forward('get_token');
if ( $c->cobrand->moniker eq 'zurich' ) {
+ $c->stash->{page} = 'admin';
FixMyStreet::Map::display_map(
$c,
latitude => $problem->latitude,
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 9732e5329..daf52c151 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -340,6 +340,8 @@ sub admin_report_edit {
$problem->title( $c->req->param('title') );
$problem->detail( $c->req->param('detail') );
+ $problem->latitude( $c->req->param('latitude') );
+ $problem->longitude( $c->req->param('longitude') );
# Final, public, Update from DM
if (my $update = $c->req->param('status_update')) {
@@ -389,14 +391,22 @@ sub admin_report_edit {
} elsif ($c->req->param('submit')) {
$c->forward('check_token');
+ my $db_update = 0;
+ if ( $c->req->param('latitude') != $problem->latitude || $c->req->param('longitude') != $problem->longitude ) {
+ $problem->latitude( $c->req->param('latitude') );
+ $problem->longitude( $c->req->param('longitude') );
+ $db_update = 1;
+ }
+
my $extra = $problem->extra || {};
$extra->{internal_notes} ||= '';
if ($c->req->param('internal_notes') && $c->req->param('internal_notes') ne $extra->{internal_notes}) {
$extra->{internal_notes} = $c->req->param('internal_notes');
$problem->extra( { %$extra } );
- $problem->update;
}
+ $problem->update if $db_update;
+
# Add new update from status_update
if (my $update = $c->req->param('status_update')) {
FixMyStreet::App->model('DB::Comment')->create( {
diff --git a/templates/web/zurich/admin/report_edit-sdm.html b/templates/web/zurich/admin/report_edit-sdm.html
index afa6a206e..2d375a92a 100644
--- a/templates/web/zurich/admin/report_edit-sdm.html
+++ b/templates/web/zurich/admin/report_edit-sdm.html
@@ -28,6 +28,8 @@
[% END %]
</li>
<li>[% loc('Co-ordinates:') %] [% problem.local_coords.join(',') %]
+ <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% problem.latitude %]">
+ <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% problem.longitude %]">
([%
SET safe = problem.postcode | html;
tprintf( loc('originally entered: &ldquo;%s&rdquo;'), safe )
diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html
index e2e67e9e6..b48d315f1 100644
--- a/templates/web/zurich/admin/report_edit.html
+++ b/templates/web/zurich/admin/report_edit.html
@@ -41,6 +41,9 @@
[% END %]
<li><span class="mock-label">[% loc('Co-ordinates:') %]</span> [% problem.local_coords.join(',') %]
+ <input type="hidden" name="latitude" id="fixmystreet.latitude" value="[% problem.latitude %]">
+ <input type="hidden" name="longitude" id="fixmystreet.longitude" value="[% problem.longitude %]">
+
([%
SET safe = problem.postcode | html;
tprintf( loc('originally entered: &ldquo;%s&rdquo;'), safe )
diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js
index 682c62f39..b25a7da41 100644
--- a/web/js/map-wmts-zurich.js
+++ b/web/js/map-wmts-zurich.js
@@ -10,6 +10,35 @@ $(function(){
$(this).text('Stadtplan');
fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]);
});
+
+ /* Admin dragging of pin */
+ if (fixmystreet.page == 'admin') {
+ var admin_drag = new OpenLayers.Control.DragFeature( fixmystreet.markers, {
+ onComplete: function(feature, e) {
+ var lonlat = feature.geometry.clone();
+ lonlat.transform(
+ fixmystreet.map.getProjectionObject(),
+ new OpenLayers.Projection("EPSG:4326")
+ );
+ if (window.confirm( 'Richtiger Ort?' ) ) {
+ // Store new co-ordinates
+ document.getElementById('fixmystreet.latitude').value = lonlat.y;
+ document.getElementById('fixmystreet.longitude').value = lonlat.x;
+ } else {
+ // Put it back
+ var lat = document.getElementById('fixmystreet.latitude').value;
+ var lon = document.getElementById('fixmystreet.longitude').value;
+ lonlat = new OpenLayers.LonLat(lon, lat).transform(
+ new OpenLayers.Projection("EPSG:4326"),
+ fixmystreet.map.getProjectionObject()
+ );
+ fixmystreet.markers.features[0].move(lonlat);
+ }
+ }
+ } );
+ fixmystreet.map.addControl( admin_drag );
+ admin_drag.activate();
+ }
});
/*