diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 19 | ||||
-rw-r--r-- | perllib/Open311.pm | 4 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/new/extra_name.html | 15 | ||||
-rw-r--r-- | templates/web/fixmystreet/report/new/fill_in_details_form.html | 3 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 4 |
5 files changed, 42 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index af4cdd5aa..68a30ca2c 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -124,12 +124,14 @@ sub report_form_ajax : Path('ajax') : Args(0) { my $category = $c->render_fragment( 'report/new/category.html'); my $councils_text = $c->render_fragment( 'report/new/councils_text.html'); my $has_open311 = keys %{ $c->stash->{category_extras} }; + my $extra_name_info = $c->render_fragment('report/new/extra_name.html'); my $body = JSON->new->utf8(1)->encode( { councils_text => $councils_text, category => $category, has_open311 => $has_open311, + extra_name_info => $extra_name_info, } ); @@ -542,7 +544,7 @@ sub setup_categories_and_councils : Private { ); $category_label = _('Property type:'); - } elsif ($first_council->{type} eq 'LBO') { + } elsif ($first_council->{id} != 2482 && $first_council->{type} eq 'LBO') { $area_ids_to_list{ $first_council->{id} } = 1; @category_options = ( @@ -589,6 +591,7 @@ sub setup_categories_and_councils : Private { $c->stash->{category_options} = \@category_options; $c->stash->{category_extras} = \%category_extras; $c->stash->{category_extras_json} = encode_json \%category_extras; + $c->stash->{extra_name_info} = $first_council->{id} == 2482 ? 1 : 0; my @missing_details_councils = grep { !$area_ids_to_list{$_} } # @@ -733,7 +736,7 @@ sub process_report : Private { $councils = join( ',', @{ $c->stash->{area_ids_to_list} } ) || -1; $report->council( $councils ); - } elsif ( $first_council->{type} eq 'LBO') { + } elsif ( $first_council->{id} != 2482 && $first_council->{type} eq 'LBO') { unless ( Utils::london_categories()->{ $report->category } ) { $c->stash->{field_errors}->{category} = _('Please choose a category'); @@ -785,6 +788,16 @@ sub process_report : Private { }; } + if ( $contacts[0]->area_id == 2482 ) { + for my $field ( qw/ fms_extra_title / ) { + push @extra, { + name => $field, + description => uc( $field), + value => $c->request->param( $field ) || '', + }; + } + } + if ( @extra ) { $c->stash->{report_meta} = \@extra; $report->extra( \@extra ); @@ -916,6 +929,8 @@ sub check_for_errors : Private { %{ $c->stash->{report}->check_for_errors }, ); + # FIXME: need to check for required bromley fields here + # if they're got the login details wrong when signing in then # we don't care about the name field even though it's validated # by the user object diff --git a/perllib/Open311.pm b/perllib/Open311.pm index 16576726c..09ab8b326 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -75,7 +75,9 @@ EOT my $extras = $problem->extra; for my $attr ( @$extras ) { - my $name = sprintf( 'attribute[%s]', $attr->{name} ); + my $attr_name = $attr->{name}; + $attr_name =~ s/fms_extra_//; + my $name = sprintf( 'attribute[%s]', $attr_name ); $params->{ $name } = $attr->{value}; } } diff --git a/templates/web/fixmystreet/report/new/extra_name.html b/templates/web/fixmystreet/report/new/extra_name.html new file mode 100644 index 000000000..7b057a831 --- /dev/null +++ b/templates/web/fixmystreet/report/new/extra_name.html @@ -0,0 +1,15 @@ +[% IF extra_name_info %] +<label for="form_fms_extra_title">Title</label> +[% IF field_errors.fms_extra_title %] + <p class='form-error'>[% field_errors.fms_extra_title %]</p> +[% END %] +<select class="form-focus-trigger" id="form_fms_extra_title" + name="fms_extra_title" required> + <option></option> + <option value="Mr">Mr</option> + <option value="Miss">Miss</option> + <option value="Mrs">Mrs</option> + <option value="Ms">Ms</option> + <option value="Dr">Dr</option> +</select> +[% END %] diff --git a/templates/web/fixmystreet/report/new/fill_in_details_form.html b/templates/web/fixmystreet/report/new/fill_in_details_form.html index 283f748ba..5ee11fb57 100644 --- a/templates/web/fixmystreet/report/new/fill_in_details_form.html +++ b/templates/web/fixmystreet/report/new/fill_in_details_form.html @@ -168,10 +168,13 @@ <div id="form_sign_in_no" class="form-box"> <h5>[% loc('<strong>No</strong> Let me confirm my report by email') %]</h5> + [% INCLUDE 'report/new/extra_name.html' %] + <label for="form_may_show_nameme">[% loc('Name') %]</label> [% IF field_errors.name %] <p class='form-error'>[% field_errors.name %]</p> [% END %] + <input type="text" class="form-focus-trigger validName" value="[% report.name | html %]" name="name" id="form_name" placeholder="[% loc('Your name') %]"> [%# if there is nothing in the name field then set check box as default on form %] diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 272fd6c12..79740de78 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -440,6 +440,10 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { } $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); + if ( data.extra_name_info ) { + var lb = $('#form_name').prev(); + lb.before(data.extra_name_info); + } }); $('#side-form, #site-logo').show(); |