diff options
author | Dave Arter <davea@mysociety.org> | 2019-06-24 17:30:30 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2019-07-09 20:26:38 +0100 |
commit | 0948389e5676300317bf49be14c0e7b8b48e8315 (patch) | |
tree | c44c6550437ef6e857fd715835ee7e906df75069 | |
parent | 0ea7e84beeea32c51b3592fcacd5824552dba15d (diff) |
Update UI text when selecting a private category
This makes it clearer that all details for a report made in a private
category will not be shown publicly.
Fixes mysociety/fixmystreet-commercial#1405
-rw-r--r-- | .cypress/cypress/integration/hounslow.js | 35 | ||||
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rwxr-xr-x | bin/browser-tests | 2 | ||||
-rwxr-xr-x | bin/fixmystreet.com/fixture | 9 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 17 | ||||
-rw-r--r-- | t/Mock/MapIt.pm | 2 | ||||
-rw-r--r-- | templates/web/base/report/new/councils_text_all.html | 13 | ||||
-rw-r--r-- | templates/web/base/report/new/form_report.html | 3 | ||||
-rw-r--r-- | templates/web/hounslow/report/new/councils_text_all.html | 9 | ||||
-rw-r--r-- | templates/web/oxfordshire/report/new/councils_text_all.html | 7 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 7 | ||||
-rw-r--r-- | web/cobrands/hounslow/js.js | 13 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 4 |
13 files changed, 100 insertions, 23 deletions
diff --git a/.cypress/cypress/integration/hounslow.js b/.cypress/cypress/integration/hounslow.js new file mode 100644 index 000000000..709ab69f1 --- /dev/null +++ b/.cypress/cypress/integration/hounslow.js @@ -0,0 +1,35 @@ +describe('private categories', function() { + + beforeEach(function() { + cy.server(); + cy.route('/report/new/ajax*').as('report-ajax'); + }); + + it('shows the correct UI text for private and public categories on cobrand', function() { + cy.visit('http://hounslow.localhost:3001/'); + cy.contains('Hounslow Highways'); + cy.get('[name=pc]').type('TW7 5JN'); + cy.get('[name=pc]').parents('form').submit(); + cy.get('.olMapViewport #fms_pan_zoom_zoomin').click(); + cy.get('#map_box').click(290, 307); + cy.wait('@report-ajax'); + cy.get('select:eq(4)').select('Potholes'); + cy.get("#js-councils_text").contains('sent to Hounslow Highways and also published online'); + cy.get('select:eq(4)').select('Other'); + cy.get("#js-councils_text").contains('sent to Hounslow Highways but not published online'); + }); + + it('shows the correct UI text for private and public categories on FMS.com', function() { + cy.visit('http://fixmystreet.localhost:3001/'); + cy.get('[name=pc]').type('TW7 5JN'); + cy.get('[name=pc]').parents('form').submit(); + cy.get('.olMapViewport #fms_pan_zoom_zoomin').click(); + cy.get('#map_box').click(290, 307); + cy.wait('@report-ajax'); + cy.get('select:eq(4)').select('Potholes'); + cy.contains('sent to Hounslow Borough Council and also published online'); + cy.get('select:eq(4)').select('Other'); + cy.contains('sent to Hounslow Borough Council but not published online'); + }); + +}); diff --git a/CHANGELOG.md b/CHANGELOG.md index 86edec034..525c350b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Mobile users can now filter the pins on the `/around` map view. #2366 - Maintain whitespace formatting in email report/update lists. - Improve keyboard accessibility. + - Report form now indicates that details are kept private if report is + made in a private category. #2528 - Admin improvements: - Add new roles system, to group permissions and apply to users. - New features: diff --git a/bin/browser-tests b/bin/browser-tests index b5241490e..6ce9159bf 100755 --- a/bin/browser-tests +++ b/bin/browser-tests @@ -11,7 +11,7 @@ my ($cobrand, $coords, $area_id, $name, $mapit_url); BEGIN { $config_file = 'conf/general.yml-example'; - $cobrand = [ 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire' ]; + $cobrand = [ 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow' ]; $coords = '51.532851,-2.284277'; $area_id = 2608; $name = 'Borsetshire'; diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture index 3c3336811..f4f33e679 100755 --- a/bin/fixmystreet.com/fixture +++ b/bin/fixmystreet.com/fixture @@ -98,6 +98,7 @@ if ($opt->test_fixtures) { { area_id => 2217, categories => ['Flytipping', 'Roads'], name => 'Buckinghamshire County Council' }, { area_id => 2257, categories => ['Flytipping', 'Graffiti'], name => 'Chiltern District Council' }, { area_id => 2397, categories => [ 'Graffiti' ], name => 'Northampton Borough Council' }, + { area_id => 2483, categories => [ 'Potholes', 'Other' ], name => 'Hounslow Borough Council' }, ) { $bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_); my $cats = join(', ', @{$_->{categories}}); @@ -134,6 +135,14 @@ if ($opt->test_fixtures) { ], }); $child_cat->update; + + $child_cat = FixMyStreet::DB->resultset("Contact")->find({ + body => $bodies->{2483}, + category => 'Other', + }); + $child_cat->update({ + non_public => 1 + }); } FixMyStreet::DB::Factory::ResponseTemplate->create({ diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 00cd91d03..7822f5cf3 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -262,12 +262,6 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { sub by_category_ajax_data : Private { my ($self, $c, $type, $category) = @_; - my $generate; - if (($c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1) or - $c->stash->{unresponsive}->{$category} or $c->stash->{report_extra_fields}) { - $generate = 1; - } - my $bodies = $c->forward('contacts_to_bodies', [ $category ]); my $list_of_names = [ map { $_->name } ($category ? @$bodies : values %{$c->stash->{bodies_to_list}}) ]; my $vars = { @@ -277,19 +271,21 @@ sub by_category_ajax_data : Private { my $non_public = $c->stash->{non_public_categories}->{$category}; my $body = { bodies => $list_of_names, - $non_public ? (non_public => JSON->true) : (), + $non_public ? ( non_public => JSON->true ) : (), }; - if ($generate) { + if (($c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1) or + $c->stash->{unresponsive}->{$category} or $c->stash->{report_extra_fields}) { $body->{category_extra} = $c->render_fragment('report/new/category_extras.html', $vars); $body->{category_extra_json} = $c->forward('generate_category_extra_json'); - } my $unresponsive = $c->stash->{unresponsive}->{$category}; $unresponsive ||= $c->stash->{unresponsive}->{ALL} || '' if $type eq 'one'; # unresponsive must return empty string if okay, as that's what mobile app checks + # councils_text.html must be rendered if it differs from the default output, + # which currently means for unresponsive and non_public categories. if ($type eq 'one' || ($type eq 'all' && $unresponsive)) { $body->{unresponsive} = $unresponsive; # Check for no bodies here, because if there are any (say one @@ -299,6 +295,9 @@ sub by_category_ajax_data : Private { $body->{councils_text_private} = $c->render_fragment( 'report/new/councils_text_private.html'); } } + if ($non_public) { + $body->{councils_text} = $c->render_fragment( 'report/new/councils_text.html', $vars); + } return $body; } diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 60ba30fe3..337b4049f 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -43,6 +43,8 @@ my @PLACES = ( [ 'NN1 2NS', 52.238301, -0.889992, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ], [ '?', 52.238827, -0.894970, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ], [ 'TW7 5JN', 51.482286, -0.328163, 2483, 'Hounslow Borough Council', 'LBO' ], + [ '?', 51.48111, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ], + [ '?', 51.482045, -0.327219, 2483, 'Hounslow Borough Council', 'LBO' ], [ '?', 50.78301, -0.646929 ], [ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ], [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], diff --git a/templates/web/base/report/new/councils_text_all.html b/templates/web/base/report/new/councils_text_all.html index d39288765..8b9abf1f3 100644 --- a/templates/web/base/report/new/councils_text_all.html +++ b/templates/web/base/report/new/councils_text_all.html @@ -2,12 +2,21 @@ [% DEFAULT list_of_names = default_list %] <p> -[% +[% UNLESS non_public_categories.$category; + tprintf( loc('These will be sent to <strong>%s</strong> and also published online for others to see, in accordance with our <a href="%s">privacy policy</a>.'), list_of_names.join( '</strong>' _ loc(' or ') _ '<strong>' ), c.cobrand.privacy_policy_url ); -%] + +ELSE; + + tprintf( + loc('These will be sent to <strong>%s</strong> but not published online.'), + list_of_names.join( '</strong>' _ loc(' or ') _ '<strong>' ) + ); + +END %] [% TRY %][% INCLUDE 'report/new/councils_extra_text.html' %][% CATCH file %][% END %] </p> diff --git a/templates/web/base/report/new/form_report.html b/templates/web/base/report/new/form_report.html index 39e29c723..910536fe8 100644 --- a/templates/web/base/report/new/form_report.html +++ b/templates/web/base/report/new/form_report.html @@ -10,7 +10,8 @@ <div class="js-hide-if-invalid-category"> [% TRY %][% PROCESS 'report/new/_form_labels.html' %][% CATCH file %][% END %] - <h2 class="form-section-heading">[% loc( 'Public details' ) %]</h2> + <h2 class="form-section-heading js-hide-if-private-category">[% loc( 'Public details' ) %]</h2> + <h2 class="form-section-heading form-section-heading--private js-hide-if-public-category">[% loc( 'Report details' ) %]</h2> <div class="form-section-description" id="js-councils_text"> [% IF js %] [% PROCESS 'report/new/councils_text_all.html' list_of_names = [ loc('the local council') ] %] diff --git a/templates/web/hounslow/report/new/councils_text_all.html b/templates/web/hounslow/report/new/councils_text_all.html index ae2d9191c..c434813f8 100644 --- a/templates/web/hounslow/report/new/councils_text_all.html +++ b/templates/web/hounslow/report/new/councils_text_all.html @@ -1,5 +1,8 @@ <p> - These will be sent to <strong>Hounslow Highways</strong> and also published - online for others to see, in accordance with our - <a href="[% c.cobrand.privacy_policy_url %]">privacy policy</a>. + [% UNLESS non_public_categories.$category %] + These will be sent to <strong>Hounslow Highways</strong> and also published online for others to see, in accordance with our + <a href="[% c.cobrand.privacy_policy_url %]">privacy policy</a>. + [% ELSE %] + These will be sent to <strong>Hounslow Highways</strong> but not published online. + [% END %] </p> diff --git a/templates/web/oxfordshire/report/new/councils_text_all.html b/templates/web/oxfordshire/report/new/councils_text_all.html index a8c81f39e..05bfbf0da 100644 --- a/templates/web/oxfordshire/report/new/councils_text_all.html +++ b/templates/web/oxfordshire/report/new/councils_text_all.html @@ -1,5 +1,8 @@ <p> All the information you provide here will be sent to the - <strong>relevant department</strong>. The summary and description - will also be made public, plus your name if you give us permission. + <strong>relevant department</strong>. + [% UNLESS non_public_categories.$category %] + The summary and description + will also be made public, plus your name if you give us permission. + [% END %] </p> diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 041d23c9e..d39b6a0e9 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -441,6 +441,13 @@ $.extend(fixmystreet.set_up, { } else { $category_meta.empty(); } + if (data && data.non_public) { + $(".js-hide-if-private-category").hide(); + $(".js-hide-if-public-category").show(); + } else { + $(".js-hide-if-private-category").show(); + $(".js-hide-if-public-category").hide(); + } // remove existing validation rules validation_rules = fixmystreet.validator.settings.rules; diff --git a/web/cobrands/hounslow/js.js b/web/cobrands/hounslow/js.js index e8772b691..7bd9fb91c 100644 --- a/web/cobrands/hounslow/js.js +++ b/web/cobrands/hounslow/js.js @@ -20,11 +20,14 @@ if (fixmystreet.cobrand == 'hounslow') { // as the destination for reports in the "Public details" section. // This is OK because the cobranded site only shows categories which // Hounslow Highways actually handle. - // Replacing this function with a no-op stops the changes made - // to the cobranded councils_text_all.html from being clobbered and - // the 'correct' (according to bodies set up within FMS) body names - // being shown. - fixmystreet.update_public_councils_text = function() {}; + // To achieve this we ignore the passed list of bodies and always + // use "Hounslow Highways" when calling the original function. + // NB calling the original function is required so that private categories + // cause the correct text to be shown in the UI. + var original_update_public_councils_text = fixmystreet.update_public_councils_text; + fixmystreet.update_public_councils_text = function(text, bodies) { + original_update_public_councils_text.call(this, text, ['Hounslow Highways']); + }; } })(); diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index ce81a8a08..8c1445b36 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -2103,6 +2103,10 @@ label .muted { } } +.js-hide-if-public-category { + display: none; +} + .asset-spot:before { content: ""; display: inline-block; |