aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm5
-rw-r--r--t/app/controller/report_new.t14
-rw-r--r--web/cobrands/fixmystreet/staff.js3
3 files changed, 21 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 10c869aee..1c5aae647 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -201,6 +201,10 @@ sub report_form_ajax : Path('ajax') : Args(0) {
my $extra_titles_list = $c->cobrand->title_list($c->stash->{all_areas});
my @list_of_names = map { $_->name } values %{$c->stash->{bodies}};
+ my %display_names = map {
+ my $name = $_->get_cobrand_handler ? $_->get_cobrand_handler->council_name : $_->name;
+ ( $_->name ne $name ) ? ( $_->name => $name ) : ();
+ } values %{$c->stash->{bodies}};
my $contribute_as = {};
if ($c->user_exists) {
my @bodies = keys %{$c->stash->{bodies}};
@@ -227,6 +231,7 @@ sub report_form_ajax : Path('ajax') : Args(0) {
category => $category,
extra_name_info => $extra_name_info,
titles_list => $extra_titles_list,
+ %display_names ? (display_names => \%display_names) : (),
%$contribute_as ? (contribute_as => $contribute_as) : (),
$top_message ? (top_message => $top_message) : (),
unresponsive => $c->stash->{unresponsive}->{ALL} || '',
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index ae6f760d8..d13f9d9ea 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -52,6 +52,7 @@ for my $body (
{ area_id => 2237, name => 'Oxfordshire County Council' },
{ area_id => 2600, name => 'Rutland County Council' },
{ area_id => 2234, name => 'Northamptonshire County Council' },
+ { area_id => 2483, name => 'Hounslow Borough Council' },
) {
my $body_obj = $mech->create_body_ok($body->{area_id}, $body->{name});
push @bodies, $body_obj;
@@ -139,6 +140,11 @@ my $contact16 = $mech->create_contact_ok(
category => 'Trees',
email => 'trees-2234@example.com',
);
+my $contact17 = $mech->create_contact_ok(
+ body_id => $body_ids{2483}, # Hounslow
+ category => 'Trees',
+ email => 'trees-2483@example.com',
+);
# test that the various bit of form get filled in and errors correctly
# generated.
@@ -1387,6 +1393,14 @@ subtest "check map click ajax response" => sub {
is $extra_details->{category}, '', 'category is empty for council with no contacts';
is_deeply $extra_details->{bodies}, [ "Sandwell Borough Council" ], 'correct bodies for council with no contacts';
ok !$extra_details->{extra_name_info}, 'no extra name info';
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'hounslow',
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $extra_details = $mech->get_ok_json( '/report/new/ajax?latitude=51.482286&longitude=-0.328163' );
+ };
+ is_deeply $extra_details->{display_names}, { 'Hounslow Borough Council' => 'Hounslow Highways' }, 'council display name mapping correct';
};
#### test uploading an image
diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js
index 7dccedcd9..0bbf65aae 100644
--- a/web/cobrands/fixmystreet/staff.js
+++ b/web/cobrands/fixmystreet/staff.js
@@ -390,7 +390,8 @@ $(fixmystreet).on('display:report', function() {
$(fixmystreet).on('report_new:category_change', function(evt, $this) {
var category = $this.val();
var prefill_reports = $this.data('prefill');
- var body = $this.data('body');
+ var display_names = fixmystreet.reporting_data.display_names || {};
+ var body = display_names[ $this.data('body') ] || $this.data('body');
if (prefill_reports) {
var title = 'A ' + category + ' problem has been found';