From 8dc0c1ac6bf329a6114b32a0d2ac6b1fbf9d8ee0 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Sat, 1 Aug 2020 03:09:33 +0000 Subject: [PATCH] Bug 23420: Add OPACSuggestionUnwantedFields option To test: -Apply patch -Check OPACSuggestionUnwantedFields -Check some fields as unwanted -Go to the OPAC suggestion page and make sure these correct fields are hidden -Go through each option and make sure it hides properly Signed-off-by: Lisette Scheer --- ...0_add_OPACSuggestionUnwantedFields_syspref.perl | 8 + .../prog/en/modules/admin/preferences/opac.pref | 16 ++ .../bootstrap/en/modules/opac-suggestions.tt | 201 ++++++++++++--------- opac/opac-suggestions.pl | 10 + 4 files changed, 146 insertions(+), 89 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl diff --git a/installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl b/installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl new file mode 100644 index 0000000000..9d6059492e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; # will be replaced by the RM + if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACSuggestionUnwantedFields','title','','Define the hidden fields for a patron purchase suggestions made via OPAC.','multiple'); + }); + + NewVersion($DBversion, 23420, "Allow configuration of hidden fields on the suggestion form in OPAC"); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index edc6ec4809..66dbf7b1a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -640,6 +640,22 @@ OPAC: note: Note - "
Note: if none of the above options are selected, 'Title' field would be mandatory anyway, by default." - + - "Fields that should be hidden for patron purchase suggestions:" + - pref: OPACSuggestionUnwantedFields + multiple: + title: Title + author: Author + copyrightdate: Copyright or publication date + isbn: ISBN, ISSN or other standard number + publishercode: Publisher name + collectiontitle: Collection title + place: Publication place + itemtype: Item type + quantity: Quantity + branch: Library or branch + patronreason: Patron reason + note: Note + - - pref: OpacHiddenItems type: textarea syntax: text/x-yaml diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index 499f330fb0..71fad804b8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -13,7 +13,6 @@ [% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-usersuggestions' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-suggestions' bodyclass='scrollto' %][% END %] [% INCLUDE 'masthead.inc' %] -
- -
  • - [% IF ( isbn_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( publishercode_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( collectiontitle_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • + + [% END %]
  • - [% IF ( place_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( quantity_required ) %] - - - Required - [% ELSE %] - - - [% END %] + [% UNLESS ( author_hidden ) %] + [% IF ( author_required ) %] + + + Required + [% ELSE %] + + + [% END %]
  • + [% END %] + [% UNLESS ( copyrightdate_hidden )%] +
  • +
    + [% IF ( copyrightdate_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
    +
  • + [% END %] + [% UNLESS ( isbn_hidden ) %] +
  • + [% IF ( isbn_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( publishercode_hidden ) %] +
  • + [% IF ( publishercode_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( collectiontitle_hidden ) %] +
  • + [% IF ( collectiontitle_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( place_hidden )%] +
  • + [% IF ( place_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( quantity_hidden )%] +
  • + [% IF ( quantity_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS (itemtype_hidden) %]
  • [% IF ( itemtype_required ) %] @@ -149,7 +165,9 @@ [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] [% END %]
  • + [% END %] [% IF branchcode %] + [% UNLESS ( branchcode_hidden )%]
  • [% IF ( branchcode_required ) %] @@ -165,7 +183,9 @@ [% END %]
  • [% END %] + [% END %] [% IF ( patron_reason_loop ) %] + [% UNLESS ( patronreason_hidden ) %]
  • [% IF ( patronreason_required ) %] @@ -187,16 +207,19 @@ [% END %]
  • [% END %] -
  • - [% IF ( note_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • + [% END %] + [% UNLESS ( note_hidden ) %] +
  • + [% IF ( note_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %]
  • diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 74e3079dfe..9c891384a0 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -257,6 +257,16 @@ my @mandatoryfields; } } +my @unwantedfields; +{ + last unless ($op eq 'add'); + my $fldsreq_sp = C4::Context->preference("OPACSuggestionUnwantedFields"); + @unwantedfields = sort split(/\s*\,\s*/, $fldsreq_sp); + foreach (@unwantedfields) { + $template->param( $_."_hidden" => 1); + } +} + $template->param( %$suggestion, suggestions_loop => $suggestions_loop, -- 2.11.0