Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions perllib/FixMyStreet/App/Form/Licence/Banner.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 5 additions & 35 deletions perllib/FixMyStreet/App/Form/Licence/ColumnAttachments.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 68 additions & 0 deletions perllib/FixMyStreet/App/Form/Licence/Fields/MultipleLocations.pm
Original file line number Diff line number Diff line change
@@ -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;

33 changes: 5 additions & 28 deletions perllib/FixMyStreet/App/Form/Licence/TemporaryTrafficSigns.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions t/app/controller/licence/column-attachments.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 2 additions & 4 deletions t/app/controller/licence/landscaping.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions templates/web/base/licence/banner/location.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p>
Please ensure you have checked the location is on the TfL Road Network using the following map:
<a href="https://tfl.maps.arcgis.com/apps/webappviewer/index.html?id=99bc8bbbe8c94af291f5a5bfc77a00dd" target="_blank" rel="noopener">TfL Road Network boundaries</a>.
</p>

<p>
Multiple banners must be located within the same vicinity.
If not, a new licence will be required.
</p>

10 changes: 10 additions & 0 deletions templates/web/base/licence/temporary-traffic-signs/location.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p>
Please ensure you have checked the location is on the TfL Road Network using the following map:
<a href="https://tfl.maps.arcgis.com/apps/webappviewer/index.html?id=99bc8bbbe8c94af291f5a5bfc77a00dd" target="_blank" rel="noopener">TfL Road Network boundaries</a>.
</p>

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

Loading