aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm8
-rw-r--r--templates/web/base/admin/report-category.html14
-rw-r--r--templates/web/base/admin/report_edit.html16
-rw-r--r--templates/web/base/report/_inspect.html16
-rw-r--r--templates/web/base/reports/_list-filters.html2
-rw-r--r--web/js/map-OpenLayers.js38
10 files changed, 69 insertions, 40 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index c49cafe7d..1f3307710 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -733,7 +733,7 @@ sub report_edit : Path('report_edit') : Args(1) {
}
}
- $c->stash->{categories} = $c->forward('categories_for_point');
+ $c->forward('categories_for_point');
if ( $c->cobrand->moniker eq 'zurich' ) {
my $done = $c->cobrand->admin_report_edit();
@@ -909,7 +909,8 @@ sub categories_for_point : Private {
# Remove the "Pick a category" option
shift @{$c->stash->{category_options}} if @{$c->stash->{category_options}};
- return $c->stash->{category_options};
+ $c->stash->{categories} = $c->stash->{category_options};
+ $c->stash->{categories_hash} = { map { $_ => 1 } @{$c->stash->{category_options}} };
}
sub templates : Path('templates') : Args(0) {
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 96854b17b..1fe35d0a3 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -182,7 +182,7 @@ sub display_location : Private {
my ( $on_map_all, $on_map, $nearby, $distance ) =
FixMyStreet::Map::map_features( $c,
latitude => $latitude, longitude => $longitude,
- interval => $interval, categories => $c->stash->{filter_category},
+ interval => $interval, categories => [ keys %{$c->stash->{filter_category}} ],
states => $c->stash->{filter_problem_states},
order => $c->stash->{sort_order},
);
@@ -264,8 +264,8 @@ sub check_and_stash_category : Private {
my %categories_mapped = map { $_ => 1 } @categories;
my $categories = [ $c->get_param_list('filter_category', 1) ];
- my @valid_categories = grep { $_ && $categories_mapped{$_} } @$categories;
- $c->stash->{filter_category} = \@valid_categories;
+ my %valid_categories = map { $_ => 1 } grep { $_ && $categories_mapped{$_} } @$categories;
+ $c->stash->{filter_category} = \%valid_categories;
}
=head2 /ajax
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index ffcdf829d..77711f807 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -111,7 +111,7 @@ sub get_problems : Private {
my $categories = [ $c->get_param_list('filter_category', 1) ];
if ( @$categories ) {
$params->{category} = $categories;
- $c->stash->{filter_category} = $categories;
+ $c->stash->{filter_category} = { map { $_ => 1 } @$categories };
}
my $rows = 50;
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index fe7576893..ad2702460 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -306,7 +306,7 @@ sub inspect : Private {
my $problem = $c->stash->{problem};
my $permissions = $c->stash->{_permissions};
- $c->stash->{categories} = $c->forward('/admin/categories_for_point');
+ $c->forward('/admin/categories_for_point');
$c->stash->{report_meta} = { map { $_->{name} => $_ } @{ $c->stash->{problem}->get_extra_fields() } };
my %category_body = map { $_->category => $_->body_id } map { $_->contacts->all } values %{$problem->bodies};
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 69a2ddb0f..ed851f71f 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -137,7 +137,7 @@ sub ward : Path : Args(2) {
} )->all;
@categories = map { $_->category } @categories;
$c->stash->{filter_categories} = \@categories;
- $c->stash->{filter_category} = [ $c->get_param_list('filter_category', 1) ];
+ $c->stash->{filter_category} = { map { $_ => 1 } $c->get_param_list('filter_category', 1) };
my $pins = $c->stash->{pins};
@@ -430,6 +430,12 @@ sub load_and_group_problems : Private {
$problems = $problems->to_body($c->stash->{body});
}
+ if (my $bbox = $c->get_param('bbox')) {
+ my ($min_lon, $min_lat, $max_lon, $max_lat) = split /,/, $bbox;
+ $where->{latitude} = { '>=', $min_lat, '<', $max_lat };
+ $where->{longitude} = { '>=', $min_lon, '<', $max_lon };
+ }
+
$problems = $problems->search(
$where,
$filter
diff --git a/templates/web/base/admin/report-category.html b/templates/web/base/admin/report-category.html
new file mode 100644
index 000000000..1e39236d7
--- /dev/null
+++ b/templates/web/base/admin/report-category.html
@@ -0,0 +1,14 @@
+<select class="form-control" name="category" id="category">
+ [% IF NOT problem.category OR NOT categories_hash.${problem.category} %]
+ <optgroup label="[% loc('Existing category') %]">
+ <option selected value="[% problem.category | html %]">[% (problem.category OR '-') | html %]</option>
+ </optgroup>
+ [% END %]
+ [% IF categories.size %]
+ <optgroup label="[% loc('Available categories') %]">
+ [% FOREACH cat IN categories %]
+ <option[% ' selected' IF problem.category == cat %]>[% cat | html %]</option>
+ [% END %]
+ </optgroup>
+ [% END %]
+</select>
diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html
index 911b1995a..3c8134b80 100644
--- a/templates/web/base/admin/report_edit.html
+++ b/templates/web/base/admin/report_edit.html
@@ -117,20 +117,8 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %]</a>
[% INCLUDE 'admin/state_groups_select.html' %]
</li>
<li><label class="inline-text" for="category">[% loc('Category:') %]</label>
-<select class="form-control" name="category" id="category">
- [% IF NOT problem.category OR NOT categories.grep(problem.category).size %]
- <optgroup label="[% loc('Existing category') %]">
- <option selected value="[% problem.category | html %]">[% (problem.category OR '-') | html %]</option>
- </optgroup>
- [% END %]
- [% IF categories.size %]
- <optgroup label="[% loc('Available categories') %]">
- [% FOREACH cat IN categories %]
- <option[% ' selected' IF problem.category == cat %]>[% cat | html %]</option>
- [% END %]
- </optgroup>
- [% END %]
-</select></li>
+ [% INCLUDE 'admin/report-category.html' %]
+</li>
<li><label class="inline-text" for="anonymous">[% loc('Anonymous:') %]</label>
<select class="form-control" name="anonymous" id="anonymous">
<option [% 'selected ' IF problem.anonymous %]value="1">[% loc('Yes') %]</option>
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index d2ba1cc88..b75394abd 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -36,21 +36,7 @@
<div class="inspect-section">
<p>
<label for="category">[% loc('Category') %]</label>
- [%# XXX this is duplicated from admin/report_edit.html, should be refactored %]
- <select name="category" id="category" class="form-control">
- [% IF NOT problem.category OR NOT categories.grep(problem.category).size %]
- <optgroup label="[% loc('Existing category') %]">
- <option selected value="[% problem.category | html %]">[% (problem.category OR '-') | html %]</option>
- </optgroup>
- [% END %]
- [% IF categories.size %]
- <optgroup label="[% loc('Available categories') %]">
- [% FOREACH cat IN categories %]
- <option[% ' selected' IF problem.category == cat %]>[% cat | html %]</option>
- [% END %]
- </optgroup>
- [% END %]
- </select>
+ [% INCLUDE 'admin/report-category.html' %]
</p>
[% FOREACH category IN categories %]
diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html
index ce4666156..e657e0375 100644
--- a/templates/web/base/reports/_list-filters.html
+++ b/templates/web/base/reports/_list-filters.html
@@ -19,7 +19,7 @@
[% IF filter_categories.size %]
<select class="form-control js-multiple" name="filter_category" id="filter_categories" multiple data-all="[% loc('Everything') %]">
[% FOR cat IN filter_categories %]
- <option value="[% cat | html %]"[% ' selected' IF filter_category.grep(cat).size %]>
+ <option value="[% cat | html %]"[% ' selected' IF filter_category.$cat %]>
[% cat | html %]
</option>
[% END %]
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 40539f385..b53246279 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -215,14 +215,21 @@ var fixmystreet = fixmystreet || {};
}
};
+ /* Make sure pins aren't going to reload just because we're zooming out,
+ * we already have the pins when the page loaded */
function zoomToBounds(bounds) {
if (!bounds) { return; }
+ fixmystreet.markers.strategies[0].deactivate();
var center = bounds.getCenterLonLat();
var z = fixmystreet.map.getZoomForExtent(bounds);
if ( z < 13 && $('html').hasClass('mobile') ) {
z = 13;
}
fixmystreet.map.setCenter(center, z);
+ // Reactivate the strategy and make it think it's done an update
+ fixmystreet.markers.strategies[0].activate();
+ fixmystreet.markers.strategies[0].calculateBounds();
+ fixmystreet.markers.strategies[0].resolution = fixmystreet.map.getResolution();
}
function sidebar_highlight(problem_id) {
@@ -391,7 +398,10 @@ var fixmystreet = fixmystreet || {};
f.geometry = new_geometry;
this.removeAllFeatures();
this.addFeatures([f]);
- zoomToBounds(extent);
+ var qs = parse_query_string();
+ if (!qs.bbox) {
+ zoomToBounds(extent);
+ }
} else {
fixmystreet.map.removeLayer(this);
}
@@ -478,8 +488,13 @@ var fixmystreet = fixmystreet || {};
format: new OpenLayers.Format.FixMyStreet()
});
}
- if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') {
+ if (fixmystreet.page == 'reports') {
+ pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetRefreshOnZoom() ];
+ }
+ if (fixmystreet.page == 'my') {
pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetFixed() ];
+ }
+ if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') {
pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({
url: fixmystreet.original.href.split('?')[0] + '?ajax=1',
format: new OpenLayers.Format.FixMyStreet()
@@ -781,6 +796,25 @@ OpenLayers.Strategy.FixMyStreet = OpenLayers.Class(OpenLayers.Strategy.BBOX, {
}
});
+/* This strategy will call for updates whenever the zoom changes,
+ * unlike the parent which only will if new area is included. It
+ * also does not update on load, as we already have the data. */
+OpenLayers.Strategy.FixMyStreetRefreshOnZoom = OpenLayers.Class(OpenLayers.Strategy.FixMyStreet, {
+ resFactor: 1.5,
+ activate: function() {
+ var activated = OpenLayers.Strategy.prototype.activate.call(this);
+ if (activated) {
+ this.layer.events.on({
+ "moveend": this.update,
+ "refresh": this.update,
+ "visibilitychanged": this.update,
+ scope: this
+ });
+ }
+ return activated;
+ }
+});
+
/* Copy of Strategy.Fixed, but with no initial load */
OpenLayers.Strategy.FixMyStreetFixed = OpenLayers.Class(OpenLayers.Strategy.Fixed, {
activate: function() {