aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-02-17 15:09:44 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-02-17 15:09:44 +0000
commitaf949b141ac8d48cac53b72070e63596f5cb5b3a (patch)
tree220b6df8c20e00812dc23ba69679a3017b5aa9a3
parent72727177baeb62be7973595aa98819cc7739a7b3 (diff)
parentacf3214f964a62f04ba40380a32ddb85c53d1a5c (diff)
Merge branch 'tfl-show-tlrn-to-staff'
-rw-r--r--perllib/FixMyStreet/Cobrand/TfL.pm13
-rw-r--r--t/cobrand/tfl.t2
-rw-r--r--templates/web/tfl/footer_extra_js.html7
-rw-r--r--templates/web/tfl/report/_item_heading.html3
-rw-r--r--web/cobrands/tfl/base.scss4
-rw-r--r--web/cobrands/tfl/js.js30
-rw-r--r--web/cobrands/tfl/staff.js20
7 files changed, 79 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Cobrand/TfL.pm b/perllib/FixMyStreet/Cobrand/TfL.pm
index 5c08cb540..1fa0aabe0 100644
--- a/perllib/FixMyStreet/Cobrand/TfL.pm
+++ b/perllib/FixMyStreet/Cobrand/TfL.pm
@@ -22,6 +22,19 @@ sub council_url { return 'tfl'; }
sub area_types { [ 'LBO' ] }
sub is_council { 0 }
+sub borough_for_report {
+ my ($self, $problem) = @_;
+
+ # Get relevant area ID from report
+ my %areas = map { $_ => 1 } split ',', $problem->areas;
+ my ($council_match) = grep { $areas{$_} } @{ $self->council_area_id };
+ return unless $council_match;
+
+ # Look up area names if not already fetched
+ my $areas = $self->{c}->stash->{children} ||= $self->fetch_area_children;
+ return $areas->{$council_match}{name};
+}
+
sub abuse_reports_only { 1 }
sub send_questionnaires { 0 }
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t
index e61c6d1bd..cdf3b1bab 100644
--- a/t/cobrand/tfl.t
+++ b/t/cobrand/tfl.t
@@ -551,11 +551,13 @@ subtest 'check correct base URL & title in AJAX pins' => sub {
};
subtest 'check report age on /around' => sub {
+ $mech->log_in_ok($staffuser->email);
my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'});
$report->update({ state => 'confirmed' });
$mech->get_ok( '/around?lat=' . $report->latitude . '&lon=' . $report->longitude );
$mech->content_contains($report->title);
+ $mech->content_contains('item-list__item__borough">Bromley');
$report->update({
confirmed => \"current_timestamp-'7 weeks'::interval",
diff --git a/templates/web/tfl/footer_extra_js.html b/templates/web/tfl/footer_extra_js.html
index a8ccc80d0..af38a5286 100644
--- a/templates/web/tfl/footer_extra_js.html
+++ b/templates/web/tfl/footer_extra_js.html
@@ -9,3 +9,10 @@ IF bodyclass.match('mappage');
);
END
%]
+[%~
+IF c.user_exists AND ((c.user.from_body AND c.user.from_body.name == 'TfL') OR c.user.is_superuser);
+ scripts.push(
+ version('/cobrands/tfl/staff.js'),
+ );
+END
+%]
diff --git a/templates/web/tfl/report/_item_heading.html b/templates/web/tfl/report/_item_heading.html
index c9575f0fd..17ded1110 100644
--- a/templates/web/tfl/report/_item_heading.html
+++ b/templates/web/tfl/report/_item_heading.html
@@ -1,4 +1,7 @@
<h3 class="item-list__heading">[% problem.title | html %]</h3>
+[% IF c.user.from_body || c.user.is_superuser %]
+ <small class="item-list__item__borough">[% c.cobrand.borough_for_report(problem) %]</small>
+[% END %]
[%~ IF c.user.has_permission_to('report_inspect', problem.bodies_str_ids) AND problem.get_extra_field_value('safety_critical') == 'yes' ~%]
<small class="item-list__safety-critical">Safety Critical</small>
[%~ END ~%]
diff --git a/web/cobrands/tfl/base.scss b/web/cobrands/tfl/base.scss
index 5e6f6426f..9c573f331 100644
--- a/web/cobrands/tfl/base.scss
+++ b/web/cobrands/tfl/base.scss
@@ -313,3 +313,7 @@ ol.big-numbers>li {
text-transform: uppercase;
}
}
+
+.item-list__item__borough {
+ font-style: normal;
+}
diff --git a/web/cobrands/tfl/js.js b/web/cobrands/tfl/js.js
index 248162597..e29b620b0 100644
--- a/web/cobrands/tfl/js.js
+++ b/web/cobrands/tfl/js.js
@@ -40,3 +40,33 @@ $(function() {
});
})();
+
+OpenLayers.Layer.TLRN = OpenLayers.Class(OpenLayers.Layer.XYZ, {
+ name: 'TLRN',
+ url: [
+ "//tilma.mysociety.org/tlrn/${z}/${x}/${y}.png",
+ "//a.tilma.mysociety.org/tlrn/${z}/${x}/${y}.png",
+ "//b.tilma.mysociety.org/tlrn/${z}/${x}/${y}.png",
+ "//c.tilma.mysociety.org/tlrn/${z}/${x}/${y}.png"
+ ],
+ sphericalMercator: true,
+ isBaseLayer: false,
+ CLASS_NAME: "OpenLayers.Layer.TLRN"
+});
+
+$(function() {
+ if (!fixmystreet.map) {
+ return;
+ }
+
+ // Can't use vector layer on reports, too big, use tiles instead
+ if (fixmystreet.page === 'reports') {
+ var layer = new OpenLayers.Layer.TLRN();
+ fixmystreet.map.addLayer(layer);
+ layer.setVisibility(true);
+ var pins_layer = fixmystreet.map.getLayersByName("Pins")[0];
+ if (pins_layer) {
+ layer.setZIndex(pins_layer.getZIndex()-1);
+ }
+ }
+});
diff --git a/web/cobrands/tfl/staff.js b/web/cobrands/tfl/staff.js
new file mode 100644
index 000000000..940feb986
--- /dev/null
+++ b/web/cobrands/tfl/staff.js
@@ -0,0 +1,20 @@
+$(function() {
+ if (!fixmystreet.map) {
+ return;
+ }
+
+ if (fixmystreet.page !== 'report') {
+ return;
+ }
+
+ for (var i = 0; i < fixmystreet.assets.layers.length; i++) {
+ var layer = fixmystreet.assets.layers[i];
+ if (layer.name === 'Red Routes') {
+ fixmystreet.map.addLayer(layer);
+ var pins_layer = fixmystreet.map.getLayersByName("Pins")[0];
+ if (pins_layer) {
+ layer.setZIndex(pins_layer.getZIndex()-1);
+ }
+ }
+ }
+});