diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2015-03-13 12:27:17 +0000 |
---|---|---|
committer | Hakim Cassimally <hakim@mysociety.org> | 2015-03-20 16:20:59 +0000 |
commit | 10b3a899af00205e46e177509a0b4c13bf746299 (patch) | |
tree | 7ab16ee9ebbf4c0494baa93923bca7d747bb1b51 | |
parent | afe94a2eff801b769e55d5527a1367406810958a (diff) |
[Harrogate] show warning banner for NYCC categories
Harrogate asked for NYCC managed issues to be linked to that
council's website. We don't prevent the issue from being logged,
but do show a warning banner.
As this is at Harrogate's request, we only do this for the Harrogate
cobrand, not the whole site, using a new cobrand hook
`munge_category_list`
Unfortunately, categories are currently passed to the template as
plain text, e.g. not structured data. As a simple implementation,
we append "( NYCC)" to the appropriate category names.
JS could then strip the names back in future, if required (though
we're not doing this.) Instead we add a jQuery hook to show the
most appropriate link provided.
See https://github.com/mysociety/FixMyStreet-Commercial/issues/703
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 3 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Harrogate.pm | 36 | ||||
-rw-r--r-- | templates/web/harrogate/report/new/after_category.html | 48 | ||||
-rw-r--r-- | web/cobrands/harrogate/base.scss | 12 |
4 files changed, 99 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index ee643a03a..b5a6745b2 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -651,6 +651,9 @@ sub setup_categories_and_bodies : Private { } } + $c->cobrand->munge_category_list(\@category_options, \@contacts, \%category_extras) + if $c->cobrand->can('munge_category_list'); + if ($c->cobrand->can('hidden_categories')) { my %hidden_categories = map { $_ => 1 } $c->cobrand->hidden_categories; diff --git a/perllib/FixMyStreet/Cobrand/Harrogate.pm b/perllib/FixMyStreet/Cobrand/Harrogate.pm index 8c0639ee7..4dc041c89 100644 --- a/perllib/FixMyStreet/Cobrand/Harrogate.pm +++ b/perllib/FixMyStreet/Cobrand/Harrogate.pm @@ -242,5 +242,41 @@ sub send_questionnaires { return 0; } +sub munge_category_list { + my ($self, $categories_ref, $contacts_ref, $extras_ref) = @_; + + # we want to know which contacts *only* belong to NYCC + # that's because for shared responsibility, we don't expect + # the user to have to figure out which authority to contact. + + # so we start building up the list of both + my (%harrogate_contacts, %nycc_contacts); + + my $harrogate_id = $self->council_id; # XXX: note reference to council_id as body id! + for my $contact (@$contacts_ref) { + my $category = $contact->category; + if ($contact->body_id == $harrogate_id) { + $harrogate_contacts{$category} = 1; + } + else { + $nycc_contacts{$category}++; + } + } + + # and then remove any that also have Harrogate involvement + delete $nycc_contacts{$_} for keys %harrogate_contacts; + + # here, we simply *mark* the text with (NYCC) at the end, and + # the rest will get done in the template with javascript + my @categories = map { + $nycc_contacts{$_} ? + "$_ (NYCC)" + : $_ + } @$categories_ref; + + # replace the entire list with this transformed one + @$categories_ref = @categories; +} + 1; diff --git a/templates/web/harrogate/report/new/after_category.html b/templates/web/harrogate/report/new/after_category.html new file mode 100644 index 000000000..b67019353 --- /dev/null +++ b/templates/web/harrogate/report/new/after_category.html @@ -0,0 +1,48 @@ +<script> + // we link to the informational articles rather than the forms, because in some + // cases the former have more information or links to track progress of faults + // etc.. + var links = { + 'Bus stops': 'http://www.northyorks.gov.uk/article/25853/Bus-stops-and-shelters', + // Pavements/footpaths (multiple options) + 'Potholes': 'http://www.northyorks.gov.uk/article/25215/Roads---potholes', + // Roads/highways (multiple options) + 'Road traffic signs': 'http://www.northyorks.gov.uk/article/25667/Road-signs-and-bollards', + // Street lighting (not considered, as also a Harrogate category) + 'Traffic lights': 'http://www.northyorks.gov.uk/article/25626/Traffic-lights', + 'default': 'http://www.northyorks.gov.uk/article/28237/Report-it-online' + }; + $(function () { + var notice = $('.nycc-notice'); + $("#problem_form").on("change.category", "select#form_category", function(){ + var cat = $(this).val(); + if (cat.search(/NYCC/) > 0) { + cat = cat.replace(' (NYCC)', ''); + var link = links[cat] || links ['default']; + notice.find('a').attr({ href: link }); + notice.show(); + } + else { + notice.hide(); + } + + }); + }); +</script> +<noscript> + <p class="nycc-notice"> + Please report issues for categories labelled <b>(NYCC)</b> directly to + <a href="http://www.northyorks.gov.uk/article/28237/Report-it-online"> + North Yorkshire County Council. + </a> + </p> +</noscript> + +<p class="nycc-notice" style="display:none"> + Please report issues for <b>NYCC</b> managed categories directly to + <a href="http://www.northyorks.gov.uk/article/28237/Report-it-online"> + North Yorkshire County Council. + </a> +</p> + +<p><small>[% loc("Remember that FixMyStreet is primarily for reporting physical problems that can be fixed. If your problem is not appropriate for submission via this site remember that you can contact your council directly using their own website.") %]</small></p> diff --git a/web/cobrands/harrogate/base.scss b/web/cobrands/harrogate/base.scss index eccb1a84f..318ee33ee 100644 --- a/web/cobrands/harrogate/base.scss +++ b/web/cobrands/harrogate/base.scss @@ -63,3 +63,15 @@ label[for=form_INFO_TEXT] { padding: 0.5em; font-size: 0.8em; } + +.nycc-notice { + border: solid 1px black; + background: #00539F; + color: white; + padding: 0.5em; + margin-top: 1em; + a { + color: white; + text-decoration: underline; + } +} |