diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d6c816cc3..51a250d49ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Text overrides for new report fields can be configured to apply when it is known the report will go to a particular cobrand. #4466, #4516 - Improve handling cache expiry for front page statistics. - Add geolocation button to centre map at user's location. #4671 + - WasteWorks PWA can now have a separate name from the FixMyStreet PWA. - Bugfixes: - Stop map panning breaking after long press. #4423 - Fix RSS feed subscription from alert page button. diff --git a/bin/update-schema b/bin/update-schema index ac4a735ede1..f4dfd3ef802 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -223,6 +223,7 @@ else { # (assuming schema change files are never half-applied, which should be the case) sub get_db_version { return 'EMPTY' if ! table_exists('problem'); + return '0087' if column_exists('manifest_theme', 'wasteworks_name'); return '0086' if constraint_contains('problem_send_state_check', 'processing'); return '0085' if column_exists('problem', 'send_state'); return '0084' if column_type_equals('problem', 'extra', 'jsonb'); diff --git a/db/downgrade_0087---0086.sql b/db/downgrade_0087---0086.sql new file mode 100644 index 00000000000..ec5b8658639 --- /dev/null +++ b/db/downgrade_0087---0086.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE manifest_theme DROP COLUMN wasteworks_name; +ALTER TABLE manifest_theme DROP COLUMN wasteworks_short_name; + +COMMIT; diff --git a/db/schema.sql b/db/schema.sql index f601c349ae3..236c6aea52f 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -614,5 +614,7 @@ CREATE TABLE manifest_theme ( short_name text not null, background_colour text, theme_colour text, - images text ARRAY + images text ARRAY, + wasteworks_name text, + wasteworks_short_name text ); diff --git a/db/schema_0087-add-wasteworks-name-to-manifest-theme.sql b/db/schema_0087-add-wasteworks-name-to-manifest-theme.sql new file mode 100644 index 00000000000..1c7fa3a2fa3 --- /dev/null +++ b/db/schema_0087-add-wasteworks-name-to-manifest-theme.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE manifest_theme ADD wasteworks_name text; +ALTER TABLE manifest_theme ADD wasteworks_short_name text; + +COMMIT; diff --git a/perllib/FixMyStreet/App/Controller/Offline.pm b/perllib/FixMyStreet/App/Controller/Offline.pm index a7b646e0ef3..42e5fefa83a 100644 --- a/perllib/FixMyStreet/App/Controller/Offline.pm +++ b/perllib/FixMyStreet/App/Controller/Offline.pm @@ -60,19 +60,24 @@ sub send_manifest: Private { $c->res->content_type('application/manifest+json'); - my $start_url; + my $theme = $c->stash->{manifest_theme}; + + my $start_url = '/?pwa'; + my $name = $theme->{name}; + my $short_name = $theme->{short_name}; + if ($app eq 'ww') { - $start_url = '/waste?pwa'; - } else { - $start_url = '/?pwa'; + $start_url = '/waste?pwa'; + $name = $theme->{wasteworks_name} if $theme->{wasteworks_name}; + $short_name = $theme->{wasteworks_short_name} if $theme->{wasteworks_short_name}; } my $data = { - name => $c->stash->{manifest_theme}->{name}, - short_name => $c->stash->{manifest_theme}->{short_name}, - background_color => $c->stash->{manifest_theme}->{background_colour}, - theme_color => $c->stash->{manifest_theme}->{theme_colour}, - icons => $c->stash->{manifest_theme}->{icons}, + name => $name, + short_name => $short_name, + background_color => $theme->{background_colour}, + theme_color => $theme->{theme_colour}, + icons => $theme->{icons}, lang => $c->stash->{lang_code}, display => "minimal-ui", start_url => $start_url, @@ -214,6 +219,8 @@ sub _find_manifest_theme : Private { theme_colour => $theme->theme_colour, name => $theme->name, short_name => $theme->short_name, + wasteworks_name => $theme->wasteworks_name, + wasteworks_short_name => $theme->wasteworks_short_name, }; unless ($ignore_cache_and_defaults) { diff --git a/perllib/FixMyStreet/App/Form/ManifestTheme.pm b/perllib/FixMyStreet/App/Form/ManifestTheme.pm index aa2d467d60d..19e93ec8c33 100644 --- a/perllib/FixMyStreet/App/Form/ManifestTheme.pm +++ b/perllib/FixMyStreet/App/Form/ManifestTheme.pm @@ -16,8 +16,10 @@ has '+widget_name_space' => ( default => sub { ['FixMyStreet::App::Form::Widget' has '+widget_tags' => ( default => sub { { wrapper_tag => 'p' } } ); has '+item_class' => ( default => 'ManifestTheme' ); has_field 'cobrand' => ( type => 'Select', empty_select => 'Select a cobrand', required => 1 ); -has_field 'name' => ( required => 1 ); -has_field 'short_name' => ( required => 1 ); +has_field 'name' => ( required => 1, label => 'FixMyStreet name' ); +has_field 'short_name' => ( required => 1, label => 'FixMyStreet short name' ); +has_field 'wasteworks_name' => ( required => 0, default => '' ); +has_field 'wasteworks_short_name' => ( required => 0, default => '' ); has_field 'background_colour' => ( required => 0 ); has_field 'theme_colour' => ( required => 0 ); has_field 'icon' => ( required => 0, type => 'Upload', label => "Add icon" ); diff --git a/perllib/FixMyStreet/DB/Result/ManifestTheme.pm b/perllib/FixMyStreet/DB/Result/ManifestTheme.pm index 3040c0a0344..1496b092d6b 100644 --- a/perllib/FixMyStreet/DB/Result/ManifestTheme.pm +++ b/perllib/FixMyStreet/DB/Result/ManifestTheme.pm @@ -35,13 +35,17 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "images", { data_type => "text[]", is_nullable => 1 }, + "wasteworks_name", + { data_type => "text", is_nullable => 1 }, + "wasteworks_short_name", + { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint("manifest_theme_cobrand_key", ["cobrand"]); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2020-10-14 22:49:08 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:el5l7426UkZ6ww/QFp1J+w +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2023-11-20 12:04:42 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bT9i4HHYfqs/4fo23OdZJg # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/t/app/controller/admin/manifesttheme.t b/t/app/controller/admin/manifesttheme.t index 4e96ac1a274..167f883c3ed 100644 --- a/t/app/controller/admin/manifesttheme.t +++ b/t/app/controller/admin/manifesttheme.t @@ -58,6 +58,8 @@ subtest "cobrand admin lets you create a new theme" => sub { my $fields = { name => "Lincolnshire FixMyStreet", short_name => "Lincs FMS", + wasteworks_name => "Lincolnshire WasteWorks", + wasteworks_short_name => "Lincs WW", }; $mech->submit_form_ok( { with_fields => $fields } ); is $mech->uri->path, '/admin/manifesttheme/lincolnshire', "redirected to edit page"; @@ -66,6 +68,8 @@ subtest "cobrand admin lets you create a new theme" => sub { my $theme = FixMyStreet::DB->resultset('ManifestTheme')->find({ cobrand => 'lincolnshire' }); is $theme->name, "Lincolnshire FixMyStreet"; is $theme->short_name, "Lincs FMS"; + is $theme->wasteworks_name, "Lincolnshire WasteWorks"; + is $theme->wasteworks_short_name, "Lincs WW"; is $theme->background_colour, undef; my $log = $superuser->admin_logs->search({}, { order_by => { -desc => 'id' } })->first; @@ -81,12 +85,16 @@ subtest "cobrand admin lets you update an existing theme" => sub { my $fields = { background_colour => "#663399", theme_colour => "rgb(102, 51, 153)", + wasteworks_name => "Lincolnshire Waste", + wasteworks_short_name => "Lincs Waste", }; $mech->submit_form_ok( { with_fields => $fields } ); my $theme = FixMyStreet::DB->resultset('ManifestTheme')->find({ cobrand => 'lincolnshire' }); is $theme->background_colour, "#663399"; is $theme->theme_colour, "rgb(102, 51, 153)"; + is $theme->wasteworks_name, "Lincolnshire Waste"; + is $theme->wasteworks_short_name, "Lincs Waste"; my $log = $superuser->admin_logs->search({}, { order_by => { -desc => 'id' } })->first; is $log->object_id, $theme->id; diff --git a/t/app/controller/offline.t b/t/app/controller/offline.t index eeaa83fb9ba..02389e3ed4d 100644 --- a/t/app/controller/offline.t +++ b/t/app/controller/offline.t @@ -24,36 +24,54 @@ FixMyStreet::override_config { }, 'correct icon'; }; + my $theme = FixMyStreet::DB->resultset('ManifestTheme')->create({ + cobrand => "test", + name => "My Test Cobrand FMS", + short_name => "Test FMS", + background_colour => "#ff00ff", + theme_colour => "#ffffff", + wasteworks_name => "My Test Cobrand Waste", + wasteworks_short_name => "Test Waste", + }); + for my $test ( { url => '/.well-known/manifest-fms.webmanifest', start_url => '/?pwa', + name => 'My Test Cobrand FMS', + short_name => 'Test FMS', }, { url => '/.well-known/manifest-waste.webmanifest', start_url => '/waste?pwa', + name => 'My Test Cobrand Waste', + short_name => 'Test Waste', }, ) { - subtest 'themed manifest' => sub { + subtest "checking webmanifest properties for $test->{url}" => sub { Memcached::delete("manifest_theme:test"); - my $theme = FixMyStreet::DB->resultset('ManifestTheme')->create({ - cobrand => "test", - name => "My Test Cobrand FMS", - short_name => "Test FMS", - background_colour => "#ff00ff", - theme_colour => "#ffffff", - }); my $j = $mech->get_ok_json($test->{url}); - is $j->{name}, 'My Test Cobrand FMS', 'correctly overridden name'; - is $j->{short_name}, 'Test FMS', 'correctly overridden short_name'; + is $j->{name}, $test->{name}, 'correctly overridden name'; + is $j->{short_name}, $test->{short_name}, 'correctly overridden short name'; is $j->{background_color}, '#ff00ff', 'correctly overridden background colour'; is $j->{theme_color}, '#ffffff', 'correctly overridden theme colour'; is $j->{start_url}, $test->{start_url}, 'correct start url'; - $theme->delete; }; - $theme_dir->remove_tree; } + $theme_dir->remove_tree; + + subtest "defaults to FMS name is WW name isn't set" => sub { + Memcached::delete("manifest_theme:test"); + $theme->update({ wasteworks_name => undef, wasteworks_short_name => undef }); + + my $j = $mech->get_ok_json('/.well-known/manifest-fms.webmanifest'); + is $j->{name}, 'My Test Cobrand FMS', 'correct name'; + is $j->{short_name}, 'Test FMS', 'correct short name'; + $j = $mech->get_ok_json('/.well-known/manifest-waste.webmanifest'); + is $j->{name}, 'My Test Cobrand FMS', 'correct name'; + is $j->{short_name}, 'Test FMS', 'correct short name'; + }; }; FixMyStreet::override_config { @@ -79,4 +97,4 @@ subtest 'offline fallback page' => sub { $mech->content_contains('offline_list'); }; -done_testing(); \ No newline at end of file +done_testing(); diff --git a/templates/web/base/admin/manifesttheme/form.html b/templates/web/base/admin/manifesttheme/form.html index 6d02487a6ca..7fdb4201e69 100644 --- a/templates/web/base/admin/manifesttheme/form.html +++ b/templates/web/base/admin/manifesttheme/form.html @@ -2,15 +2,25 @@
-

[% loc("The name is a string that represents the name of the web application as it is usually displayed to the user (e.g., amongst a list of other applications, or as a label for an icon).") %]

+

[% loc("The FixMyStreet name is a string that represents the name of the web application as it is usually displayed to the user (e.g., amongst a list of other applications, or as a label for an icon).") %]

[% form.field('name').render | safe %]
-

[% loc("The short name is a string that represents the name of the web application displayed to the user if there is not enough space to display name (e.g., as a label for an icon on the phone home screen).") %]

+

[% loc("The FixMyStreet short name is a string that represents the name of the web application displayed to the user if there is not enough space to display name (e.g., as a label for an icon on the phone home screen).") %]

[% form.field('short_name').render | safe %] +
+

[% loc("The WasteWorks name is a string that represents the name of the web application as it is usually displayed to the user (e.g., amongst a list of other applications, or as a label for an icon).") %]

+
+ [% form.field('wasteworks_name').render | safe %] + +
+

[% loc("The WasteWorks short name is a string that represents the name of the web application displayed to the user if there is not enough space to display name (e.g., as a label for an icon on the phone home screen).") %]

+
+ [% form.field('wasteworks_short_name').render | safe %] +

[% loc("The theme colour defines the default theme colour for the application. This sometimes affects how the OS displays the site (e.g., on Android's task switcher, the theme colour surrounds the site). Colours should be specified with CSS syntax, e.g. #ff00ff or rgb(255, 0, 255) or a named colour like fuchsia.") %]

diff --git a/templates/web/base/admin/manifesttheme/index.html b/templates/web/base/admin/manifesttheme/index.html index df94c394fb8..bab8fbd569b 100644 --- a/templates/web/base/admin/manifesttheme/index.html +++ b/templates/web/base/admin/manifesttheme/index.html @@ -4,8 +4,10 @@ [% loc('Cobrand') %] - [% loc('Name') %] - [% loc('Short Name') %] + [% loc('FixMyStreet Name') %] + [% loc('FixMyStreet Short Name') %] + [% loc('WasteWorks Name') %] + [% loc('WasteWorks Short Name') %] [% loc('Background Colour') %] [% loc('Theme Colour') %]   @@ -17,6 +19,8 @@ [% theme.cobrand %] [% theme.name %] [% theme.short_name %] + [% theme.wasteworks_name %] + [% theme.wasteworks_short_name %] [% theme.background_colour %] [% theme.theme_colour %] [% loc('Edit') %] @@ -30,6 +34,6 @@

[% loc('Create') %]

- + [% INCLUDE 'admin/footer.html' %]