From 485144ea03430d7d1cc15ab3034607ad3e606dd1 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. Signed-off-by: David Nind Signed-off-by: Helen Oliver Signed-off-by: Kyle M Hall --- .../data/mysql/atomicupdate/bug_31028.pl | 33 +++++++++++++++++++ .../data/mysql/en/optional/sample_news.yml | 33 +++++++++++++++++++ .../en/modules/tools/additional-contents.tt | 2 +- .../opac-tmpl/bootstrap/css/src/opac.scss | 7 ++++ .../en/includes/modals/catalog_concern.inc | 18 +++++++++- .../bootstrap/js/modals/catalog_concern.js | 8 +++++ 6 files changed, 99 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_31028.pl b/installer/data/mysql/atomicupdate/bug_31028.pl index 2b5204c692..459eaeb99f 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, expirationdate, number ) 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), '2099-01-10', 1 ) + } + ); + 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, expirationdate, number ) VALUES ('html_customizations', 'CatalogConcernTemplate_1', 'CatalogConcernTemplate', 'Catalog concern template text', "$cc_template", 'default', CAST(NOW() AS date), '2099-01-10', 1 ) + } + ); + 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..db10ad18e9 100644 --- a/installer/data/mysql/en/optional/sample_news.yml +++ b/installer/data/mysql/en/optional/sample_news.yml @@ -55,3 +55,36 @@ tables: published_on: "2007-10-29 05:34:45" expirationdate: "2099-01-10" number: 2 + + - title: "Catalog concern help text" + 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 + + - title: "Catalog concern template text" + category: "html_customizations" + location: "CatalogConcernTemplate" + code: "CatalogConcernTemplate_1" + content: + - "**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." + 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 30b0103a80..1a5e53bee4 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 @@ -493,7 +493,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 a927bff544..a3619f9d9c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -148,6 +148,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 6d6de1041e..cd9bf7b533 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,7 @@ +[% USE raw %] +[% 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 ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/modals/catalog_concern.js b/koha-tmpl/opac-tmpl/bootstrap/js/modals/catalog_concern.js index c5d264a84f..f5dab6aa13 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/modals/catalog_concern.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/modals/catalog_concern.js @@ -13,11 +13,19 @@ $(document).ready(function() { } $('#addConcernModal').on('show.bs.modal', function(e) { + // Redirect to login modal if not logged in if (logged_in_user_id === "") { $('#modalAuth').append(''); $('#loginModal').modal('show'); return false; } + + $('#addConfirm').prop('disabled', false); + let concern_body = $('#concern_body'); + if ( concern_body.val() === "" ) { + let template = $('#concern_template').text(); + concern_body.val(template); + } }); $('#addConcernModal').on('click', '#addConfirm', function(e) { -- 2.30.2