diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-07-15 11:02:06 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-07-15 11:02:06 +0100 |
commit | fda6671e5f06f2b0e6031958695ac580c4b9d6ec (patch) | |
tree | d3c9aea06a1aafefa1ede5144e457018240d2d9d | |
parent | aa0a3912b17bdab7ea0df09873236c1978d8a682 (diff) |
Stop using collapse filter in category template.
If a category had eg. a double space, the use of the filter meant it
was output in the HTML with only a single space and so woudn't match
the database entry. Switch to more explicit template space chomping.
-rw-r--r-- | t/app/controller/report_new.t | 2 | ||||
-rw-r--r-- | templates/web/base/report/new/category.html | 20 | ||||
-rw-r--r-- | templates/web/eastsussex/report/new/category.html | 20 | ||||
-rw-r--r-- | templates/web/seesomething/report/new/category.html | 21 |
4 files changed, 30 insertions, 33 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 9b10de2bf..6ea4c9523 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -85,7 +85,7 @@ my $contact6 = $mech->create_contact_ok( ); my $contact7 = $mech->create_contact_ok( body_id => $body_ids{2227}, # Hampshire - category => 'Street lighting', + category => 'Street lighting', email => 'highways@example.com', ); my $contact8 = $mech->create_contact_ok( diff --git a/templates/web/base/report/new/category.html b/templates/web/base/report/new/category.html index 8cfbecdcd..ba6347d39 100644 --- a/templates/web/base/report/new/category.html +++ b/templates/web/base/report/new/category.html @@ -1,17 +1,15 @@ -[% FILTER collapse %] -[% IF category_options.size %] +[% IF category_options.size ~%] [% IF category; category = category | lower; - END; %] + END; ~%] <label for='form_category' id="form_category_label"> - [%- loc('Category') %] - </label> + [%~ loc('Category') ~%] + </label>[% =%] <select name='category' id='form_category'> - [% FOREACH cat_op IN category_options %] - [% cat_op_lc = cat_op | lower %] - <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category == cat_op_lc || (category_options.size == 2 AND loop.last) -%] + [%~ FOREACH cat_op IN category_options ~%] + [% cat_op_lc = cat_op | lower =%] + <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category == cat_op_lc || (category_options.size == 2 AND loop.last) ~%] >[% IF loop.first %][% cat_op %][% ELSE %][% cat_op | html %][% END %]</option> - [% END %] + [%~ END =%] </select> -[% END %] -[% END -%] +[%~ END ~%] diff --git a/templates/web/eastsussex/report/new/category.html b/templates/web/eastsussex/report/new/category.html index e4a7ed456..3c2ff4c36 100644 --- a/templates/web/eastsussex/report/new/category.html +++ b/templates/web/eastsussex/report/new/category.html @@ -1,18 +1,16 @@ -[% FILTER collapse %] -[% IF category_options.size %] +[% IF category_options.size ~%] [% IF category; category = category | lower; - END; %] + END; ~%] <label for='form_category' id="form_category_label"> Type - </label> + </label>[% =%] <select name='category' id='form_category'> - [% FOREACH cat_op IN category_options %] - [% cat_op_lc = cat_op | lower %] - [% IF loop.first; cat_op = '-- Pick a type --'; END %] - <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category == cat_op_lc || (category_options.size == 2 AND loop.last) -%] + [%~ FOREACH cat_op IN category_options ~%] + [% cat_op_lc = cat_op | lower =%] + [% IF loop.first; cat_op = '-- Pick a type --'; END ~%] + <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category == cat_op_lc || (category_options.size == 2 AND loop.last) ~%] >[% IF loop.first %][% cat_op %][% ELSE %][% cat_op | html %][% END %]</option> - [% END %] + [%~ END =%] </select> -[% END %] -[% END -%] +[%~ END ~%] diff --git a/templates/web/seesomething/report/new/category.html b/templates/web/seesomething/report/new/category.html index 691c38497..4b0589e17 100644 --- a/templates/web/seesomething/report/new/category.html +++ b/templates/web/seesomething/report/new/category.html @@ -1,14 +1,15 @@ -[% FILTER collapse %] -[% IF category_options.size %] +[% IF category_options.size ~%] [% IF category; category = category | lower; - END; %] - <label for='form_category' class="select">[% loc('Category') %]</label> + END; ~%] + <label for='form_category' class="select"> + [%~ loc('Category') ~%] + </label>[% =%] <select name='category' data-theme="c" id='form_category'> - [% FOREACH cat_op IN category_options %] - [% cat_op_lc = cat_op | lower %] - <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category == cat_op_lc %]>[% cat_op | html %]</option> - [% END %] + [%~ FOREACH cat_op IN category_options ~%] + [% cat_op_lc = cat_op | lower =%] + <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category == cat_op_lc ~%] + >[% cat_op | html %]</option> + [%~ END =%] </select> -[% END %] -[% END -%] +[%~ END ~%] |