From cae98b47c0ca0de28bfe6167d4af4cf8f63f2ddf Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 25 Oct 2022 13:40:32 +0100 Subject: [PATCH] Bug 31028: Add configurable help text and templates This patch adds configurable help text and a template option to the catalog concern report modal in the OPAC. Test plan 1) Enable `OpacCatalogConcerns` preference 2) Build the CSS for the OPAC 3) Check that there is a 'CatalogConcernHelp' block listed in the HTML Customisations page. 4) On the OPAC navigate to a record and click the 'Report a concern' button. 5) Confirm that the content of 'CatalogConcernHelp' displays beneath the detail entry box and that it displays as expected. 6) Check that there is a 'CatalogConcernTemplate' block listed in the HTML customisations page. 7) On the OPAC 'Report a concern' modal, you should see the content of the 'CatalogConcernTemplate' block pre-filled in the details textarea. Note: There is a caveat to the template.. as textarea can only be used to submit plaintext with this patch and as such the template needs to not utilise the WYSIWYG editor else you will be faced with raw HTML inside your textarea. --- .../data/mysql/atomicupdate/bug_31028.pl | 33 +++++++++++++++++++ .../data/mysql/en/optional/sample_news.yml | 11 +++++++ .../en/modules/tools/additional-contents.tt | 2 +- .../opac-tmpl/bootstrap/css/src/opac.scss | 7 ++++ .../en/includes/modals/catalog_concern.inc | 16 ++++++++- 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_31028.pl b/installer/data/mysql/atomicupdate/bug_31028.pl index 93568be1d6..a4e328c147 100644 --- a/installer/data/mysql/atomicupdate/bug_31028.pl +++ b/installer/data/mysql/atomicupdate/bug_31028.pl @@ -52,5 +52,38 @@ return { } ); say $out "`OpacCatalogConcerns` preference added"; + + if ( ( $dbh->selectrow_array('SELECT COUNT(*) FROM additional_contents WHERE location=?', undef, 'CatalogConcernHelp') )[0] == 0 ) { # Check to make idempotent + $dbh->do( + q{ + INSERT INTO additional_contents ( category, code, location, title, content, lang, published_on ) VALUES ('html_customizations', 'CatalogConcernHelp_1', 'CatalogConcernHelp', 'Catalog concern help text', 'Please describe your concern clearly and the library will try to deal with it as quickly as possible', 'default', CAST(NOW() AS date) ) + } + ); + say $out "`CatalogConcernHelp` block added to html_customization"; + } + + if ( ( $dbh->selectrow_array('SELECT COUNT(*) FROM additional_contents WHERE location=?', undef, 'CatalogConcernTemplate') )[0] == 0 ) { # Check to make idempotent + my $cc_template = <<~ 'END_TEMPLATE'; + **Describe the concern** + A clear and concise description of what the concern is. + + **To Reproduce** + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + + **Expected behavior** + A clear and concise description of what you expected to happen. + END_TEMPLATE + + $dbh->do( + qq{ + INSERT INTO additional_contents ( category, code, location, title, content, lang, published_on ) VALUES ('html_customizations', 'CatalogConcernTemplate_1', 'CatalogConcernTemplate', 'Catalog concern template text', "$cc_template", 'default', CAST(NOW() AS date) ) + } + ); + say $out "`CatalogConcernTemplate` block added to html_customization"; + } } } diff --git a/installer/data/mysql/en/optional/sample_news.yml b/installer/data/mysql/en/optional/sample_news.yml index 7023d8c02a..543e9faf87 100644 --- a/installer/data/mysql/en/optional/sample_news.yml +++ b/installer/data/mysql/en/optional/sample_news.yml @@ -55,3 +55,14 @@ tables: published_on: "2007-10-29 05:34:45" expirationdate: "2099-01-10" number: 2 + + - title: "" + category: "html_customizations" + location: "CatalogConcernHelp" + code: "CatalogConcernHelp_1" + content: + - "Please describe your concern clearly and the library will try to deal with it as quickly as possible" + lang: "default" + published_on: "2007-10-29 05:25:58" + expirationdate: "2099-01-10" + number: 1 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index 4db2b9e5d5..0a10acb3d7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -487,7 +487,7 @@ [% END %] [% END %] [% ELSE %] - [% SET available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo' ] %] + [% SET available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'CatalogConcernHelp', 'CatalogConcernTemplate' ] %] [% FOREACH l IN available_options.sort %] [% IF l == location %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 63434d3cbf..e101328bf7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -147,6 +147,13 @@ textarea { width: 50%; } +.help-block { + display: block; + margin-top: 5px; + margin-bottom: 10px; + color: #737373; +} + legend { color: #727272; font-size: 110%; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc index e11bc57c97..52a9362c70 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/modals/catalog_concern.inc @@ -1,3 +1,6 @@ +[% USE AdditionalContents %] +[% SET CatalogConcernHelp = AdditionalContents.get( location => "CatalogConcernHelp", lang => lang, library => logged_in_user.branchcode || default_branch ) %] +[% SET CatalogConcernTemplate = AdditionalContents.get( location => "CatalogConcernTemplate", lang => lang, library => logged_in_user.branchcode || default_branch ) %] -- 2.20.1