diff --git a/perllib/FixMyStreet/App/Form/Licence/Banner.pm b/perllib/FixMyStreet/App/Form/Licence/Banner.pm index 056454c8e30..2c684ea54bd 100644 --- a/perllib/FixMyStreet/App/Form/Licence/Banner.pm +++ b/perllib/FixMyStreet/App/Form/Licence/Banner.pm @@ -47,34 +47,11 @@ has_page location_1 => ( }, ); -for my $page (2..5) { - my $next = 'dates'; - my $fields = ["building_name_number_$page", "street_name_$page", "borough_$page", "postcode_$page", 'continue']; - if ($page < 5) { - $next = sub { $_[1]->{add_another} ? 'location_' . ($page+1) : 'dates' }; - push @$fields, 'add_another'; - } - has_page "location_$page" => ( - step_number => 1, - fields => $fields, - title => "Location of the banners ($page)", - intro => 'location.html', - next => $next, - tags => { hide => sub { !$_[0]->form->saved_data->{"building_name_number_$page"} } }, - ); - has_field "building_name_number_$page" => ( type => 'Text', label => 'Building name / number', required => 1 ); - has_field "street_name_$page" => ( type => 'Text', label => 'Street name', required => 1 ); - has_field "borough_$page" => ( type => 'Text', label => 'Borough', required => 1 ); - has_field "postcode_$page" => ( type => 'Text', label => 'Postcode', required => 1 ); -} - -has_field 'add_another' => ( - type => 'Submit', - value => 'Add another', - element_attr => { - class => 'govuk-button govuk-button--secondary', - }, -); +with 'FixMyStreet::App::Form::Licence::Fields::MultipleLocations' => { + pages => 5, + title => 'Location of the banners', + template => 'banner/location.html', +}; # ========================================================================== # Extra questions diff --git a/perllib/FixMyStreet/App/Form/Licence/ColumnAttachments.pm b/perllib/FixMyStreet/App/Form/Licence/ColumnAttachments.pm index 79bcc278b7b..ff2aa37ac38 100644 --- a/perllib/FixMyStreet/App/Form/Licence/ColumnAttachments.pm +++ b/perllib/FixMyStreet/App/Form/Licence/ColumnAttachments.pm @@ -49,41 +49,11 @@ has_page location_1 => ( }, ); -foreach my $page (2..5) { - my $next = 'dates'; - my $fields = ["building_name_number_$page", "street_name_$page", "borough_$page", "postcode_$page", 'continue']; - if ($page < 5) { - $next = sub { $_[1]->{add_another} ? 'location_' . ($page+1) : 'dates' }; - push @$fields, 'add_another'; - } - has_page "location_$page" => ( - step_number => 1, - fields => $fields, - update_field_list => sub { - my $data = $_[0]->saved_data; - return { - "street_name_$page" => { default => $data->{street_name} }, - "borough_$page" => { default => $data->{borough} }, - } - }, - title => "Location of the Column Attachments ($page)", - intro => 'column-attachments/location.html', - next => $next, - tags => { hide => sub { !$_[0]->form->saved_data->{"building_name_number_$page"} } }, - ); - has_field "building_name_number_$page" => ( type => 'Text', label => 'Building name / number', required => 1 ); - has_field "street_name_$page" => ( type => 'Text', label => 'Street name', disabled => 1 ); - has_field "borough_$page" => ( type => 'Text', label => 'Borough', disabled => 1 ); - has_field "postcode_$page" => ( type => 'Text', label => 'Postcode', required => 1 ); -} - -has_field 'add_another' => ( - type => 'Submit', - value => 'Add another', - element_attr => { - class => 'govuk-button govuk-button--secondary', - }, -); +with 'FixMyStreet::App::Form::Licence::Fields::MultipleLocations' => { + pages => 5, + title => 'Location of the Column Attachments', + template => 'column-attachments/location.html', +}; # ========================================================================== # Column Attachments activity diff --git a/perllib/FixMyStreet/App/Form/Licence/Fields/MultipleLocations.pm b/perllib/FixMyStreet/App/Form/Licence/Fields/MultipleLocations.pm new file mode 100644 index 00000000000..32c3a20abc0 --- /dev/null +++ b/perllib/FixMyStreet/App/Form/Licence/Fields/MultipleLocations.pm @@ -0,0 +1,68 @@ +package FixMyStreet::App::Form::Licence::Fields::MultipleLocations; + +use utf8; +use HTML::FormHandler::Moose::Role; +use MooseX::Role::Parameterized; + +=head1 NAME + +FixMyStreet::App::Form::Licence::Fields::MultipleLocations - Further location pages for licence forms + +=head1 DESCRIPTION + +Provides further pages of location fields for TfL licence forms. + +=cut + +parameter pages => ( isa => 'Int' ); +parameter title => ( isa => 'Str' ); +parameter template => ( isa => 'Str' ); + +role { + my $p = shift; + my $pages = $p->pages; + my $title = $p->title; + my $template = $p->template; + + for my $page (2..$pages) { + my $next = 'dates'; + my $fields = ["building_name_number_$page", "street_name_$page", "borough_$page", "postcode_$page", 'continue']; + if ($page < $pages) { + $next = sub { $_[1]->{add_another} ? 'location_' . ($page+1) : 'dates' }; + push @$fields, 'add_another'; + } + + # has_page doesn't work in a role + __PACKAGE__->meta->add_to_page_list( { + name => "location_$page", + step_number => 1, + fields => $fields, + update_field_list => sub { + my $data = $_[0]->saved_data; + return { + "street_name_$page" => { default => $data->{street_name} }, + "borough_$page" => { default => $data->{borough} }, + } + }, + title => "$title ($page)", + intro => $template, + next => $next, + tags => { hide => sub { !$_[0]->form->saved_data->{"building_name_number_$page"} } }, + } ); + has_field "building_name_number_$page" => ( type => 'Text', label => 'Building name / number', required => 1 ); + has_field "street_name_$page" => ( type => 'Text', label => 'Street name', disabled => 1 ); + has_field "borough_$page" => ( type => 'Text', label => 'Borough', disabled => 1 ); + has_field "postcode_$page" => ( type => 'Text', label => 'Postcode', required => 1 ); + } +}; + +has_field 'add_another' => ( + type => 'Submit', + value => 'Add another', + element_attr => { + class => 'govuk-button govuk-button--secondary', + }, +); + +1; + diff --git a/perllib/FixMyStreet/App/Form/Licence/TemporaryTrafficSigns.pm b/perllib/FixMyStreet/App/Form/Licence/TemporaryTrafficSigns.pm index bfc91238ff2..6539923ae0a 100644 --- a/perllib/FixMyStreet/App/Form/Licence/TemporaryTrafficSigns.pm +++ b/perllib/FixMyStreet/App/Form/Licence/TemporaryTrafficSigns.pm @@ -47,34 +47,11 @@ has_page location_1 => ( }, ); -for my $page (2..10) { - my $next = 'dates'; - my $fields = ["building_name_number_$page", "street_name_$page", "borough_$page", "postcode_$page", 'continue']; - if ($page < 10) { - $next = sub { $_[1]->{add_another} ? 'location_' . ($page+1) : 'dates' }; - push @$fields, 'add_another'; - } - has_page "location_$page" => ( - step_number => 1, - fields => $fields, - title => "Location of the temporary traffic signs ($page)", - intro => 'location.html', - next => $next, - tags => { hide => sub { !$_[0]->form->saved_data->{"building_name_number_$page"} } }, - ); - has_field "building_name_number_$page" => ( type => 'Text', label => 'Building name / number', required => 1 ); - has_field "street_name_$page" => ( type => 'Text', label => 'Street name', required => 1 ); - has_field "borough_$page" => ( type => 'Text', label => 'Borough', required => 1 ); - has_field "postcode_$page" => ( type => 'Text', label => 'Postcode', required => 1 ); -} - -has_field 'add_another' => ( - type => 'Submit', - value => 'Add another', - element_attr => { - class => 'govuk-button govuk-button--secondary', - }, -); +with 'FixMyStreet::App::Form::Licence::Fields::MultipleLocations' => { + pages => 10, + title => 'Location of the temporary traffic signs', + template => 'temporary-traffic-signs/location.html', +}; # ========================================================================== # Activity/Sign Contents diff --git a/t/app/controller/licence/column-attachments.t b/t/app/controller/licence/column-attachments.t index 2fd0c8d0b1d..9ba197d5268 100644 --- a/t/app/controller/licence/column-attachments.t +++ b/t/app/controller/licence/column-attachments.t @@ -27,6 +27,7 @@ subtest 'Column attachments form submission - smoke test' => sub { PHONE_COUNTRY => 'GB', COBRAND_FEATURES => { licencing_forms => { tfl => 1 }, + licencing_payment_links => { tfl => { 'column-attachments' => 'LINK' } }, }, PHOTO_STORAGE_OPTIONS => { UPLOAD_DIR => $UPLOAD_DIR }, }, sub { @@ -121,10 +122,7 @@ subtest 'Column attachments form submission - smoke test' => sub { }}, 'Upload page'); # Payment page - TODO: { - local $TODO = "do not have link details yet"; - $mech->content_contains('1S1H8a', 'Correct payment link'); - } + $mech->content_contains('LINK', 'Correct payment link'); $mech->submit_form_ok({ with_fields => { payment_amount => 100, payment_transaction_id => 'TEST-TRANSACTION-12345', diff --git a/t/app/controller/licence/landscaping.t b/t/app/controller/licence/landscaping.t index 49e58bc8c51..2aaf397ac36 100644 --- a/t/app/controller/licence/landscaping.t +++ b/t/app/controller/licence/landscaping.t @@ -27,6 +27,7 @@ subtest 'Landscaping form submission - smoke test' => sub { PHONE_COUNTRY => 'GB', COBRAND_FEATURES => { licencing_forms => { tfl => 1 }, + licencing_payment_links => { tfl => { landscaping => 'LINK2' } }, }, PHOTO_STORAGE_OPTIONS => { UPLOAD_DIR => $UPLOAD_DIR }, }, sub { @@ -114,10 +115,7 @@ subtest 'Landscaping form submission - smoke test' => sub { }}, 'Upload page'); # Payment page - TODO: { - local $TODO = "do not have link details yet"; - $mech->content_contains('1S1H8a', 'Correct payment link'); - } + $mech->content_contains('LINK2', 'Correct payment link'); $mech->submit_form_ok({ with_fields => { payment_amount => 100, payment_transaction_id => 'TEST-TRANSACTION-12345', diff --git a/templates/web/base/licence/banner/location.html b/templates/web/base/licence/banner/location.html new file mode 100644 index 00000000000..1890c8aa8da --- /dev/null +++ b/templates/web/base/licence/banner/location.html @@ -0,0 +1,10 @@ +

+Please ensure you have checked the location is on the TfL Road Network using the following map: +TfL Road Network boundaries. +

+ +

+Multiple banners must be located within the same vicinity. +If not, a new licence will be required. +

+ diff --git a/templates/web/base/licence/temporary-traffic-signs/location.html b/templates/web/base/licence/temporary-traffic-signs/location.html new file mode 100644 index 00000000000..b4cd5eeae64 --- /dev/null +++ b/templates/web/base/licence/temporary-traffic-signs/location.html @@ -0,0 +1,10 @@ +

+Please ensure you have checked the location is on the TfL Road Network using the following map: +TfL Road Network boundaries. +

+ +

+Multiple temporary traffic signs must be located within the same vicinity. +If not, a new licence will be required. +

+