diff options
-rw-r--r-- | t/cobrand/oxfordshire.t | 50 | ||||
-rw-r--r-- | templates/web/fixmystreet/my/my.html | 10 | ||||
-rw-r--r-- | templates/web/oxfordshire/my/_problem-list.html | 9 | ||||
-rw-r--r-- | templates/web/oxfordshire/reports/_list-filters.html | 23 |
4 files changed, 71 insertions, 21 deletions
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t new file mode 100644 index 000000000..d9f880d07 --- /dev/null +++ b/t/cobrand/oxfordshire.t @@ -0,0 +1,50 @@ +use strict; +use warnings; +use Test::More; + +use FixMyStreet::TestMech; +my $mech = FixMyStreet::TestMech->new; + +subtest 'check /ajax defaults to open reports only' => sub { + my $categories = [ 'Bridges', 'Fences', 'Manhole' ]; + my $params = { + postcode => 'OX28 4DS', + latitude => 51.7847208192, + longitude => -1.49445264029, + }; + my $bbox = ($params->{longitude} - 0.01) . ',' . ($params->{latitude} - 0.01) + . ',' . ($params->{longitude} + 0.01) . ',' . ($params->{latitude} + 0.01); + + # Create one open and one fixed report in each category + foreach my $category ( @$categories ) { + foreach my $state ( 'confirmed', 'fixed' ) { + my %report_params = ( + %$params, + category => $category, + state => $state, + ); + $mech->create_problems_for_body( 1, 2237, 'Around page', \%report_params ); + } + } + + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ], + MAPIT_URL => 'http://mapit.mysociety.org/', + }, sub { + my $json = $mech->get_ok_json( '/ajax?status=all&bbox=' . $bbox ); + my $pins = $json->{pins}; + is scalar @$pins, 6, 'correct number of reports created'; + + $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 3, 'correct number of reports returned with no filters'; + + $json = $mech->get_ok_json( '/ajax?filter_category=Fences&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 1, 'only one Fences report by default'; + } +}; + +# Clean up +$mech->delete_problems_for_body( 2237 ); +done_testing(); diff --git a/templates/web/fixmystreet/my/my.html b/templates/web/fixmystreet/my/my.html index b614963fe..16779e503 100644 --- a/templates/web/fixmystreet/my/my.html +++ b/templates/web/fixmystreet/my/my.html @@ -58,13 +58,3 @@ </div> [% INCLUDE 'footer.html' %] - -[% BLOCK problem %] - [% "<ul class='issue-list-a full-width'>" IF loop.first %] - [% IF c.cobrand.moniker == 'oxfordshire' %] - [% INCLUDE 'reports/_list-entry.html', problem = p, no_fixed =1 %] - [% ELSE %] - [% INCLUDE 'report/_item.html', problem = p, no_fixed =1 %] - [% END %] - [% "</ul>" IF loop.last %] -[% END %] diff --git a/templates/web/oxfordshire/my/_problem-list.html b/templates/web/oxfordshire/my/_problem-list.html new file mode 100644 index 000000000..1365dccd3 --- /dev/null +++ b/templates/web/oxfordshire/my/_problem-list.html @@ -0,0 +1,9 @@ +[% FOREACH p = problems.all %] + [% INCLUDE problem %] +[% END %] + +[% BLOCK problem %] + [% "<ul class='issue-list-a full-width'>" IF loop.first %] + [% INCLUDE 'reports/_list-entry.html', problem = p, no_fixed =1 %] + [% "</ul>" IF loop.last %] +[% END %] diff --git a/templates/web/oxfordshire/reports/_list-filters.html b/templates/web/oxfordshire/reports/_list-filters.html index 029b14144..5d610261b 100644 --- a/templates/web/oxfordshire/reports/_list-filters.html +++ b/templates/web/oxfordshire/reports/_list-filters.html @@ -6,23 +6,24 @@ <p class="report-list-filters"> <label> Show - <select name="status"> - <option value="">all reports</option> - <option value="open">unfixed reports</option> - <option value="fixed">fixed reports</option> + <select name="status" id="statuses"> + <option value="all"[% ' selected' IF filter_status == 'all' %]>all reports</option> + <option value="open"[% ' selected' IF filter_status == 'open' %]>unfixed reports</option> + <option value="fixed"[% ' selected' IF filter_status == 'fixed' %]>fixed reports</option> </select> </label> <label> about - <select name="category"> - <option value="">anything</option> - <option value="">bridges</option> - <option value="">carriageway defect</option> - <option value="">debris/spillage</option> - <option value="">…</option> + <select name="filter_category" id="filter_categories"> + <option value="">Everything</option> + [% FOR category IN filter_categories %] + <option value="[% category | html %]"[% ' selected' IF filter_category == category %]> + [% category | html %] + </option> + [% END %] </select> </label> - <input type=submit value="go" /> + <input type=submit value="Go" /> </p> [% IF use_section_wrapper %] |