From c469c681a4445bb30587407827d93d2249480cca Mon Sep 17 00:00:00 2001
From: Phil Ringnalda <phil@chetcolibrary.org>
Date: Fri, 16 Apr 2021 11:44:14 -0700
Subject: [PATCH] Bug 28160: Values from 150$a aren't prefilled in z39.50
 search form from an existing authority record

For names and uniform titles, when you do a z39.50 search from an authority
record, we prefill what's in the relevant tag's subfield a in the search
form, but for subjects, we don't, both because GetMandatoryFieldZ3950 thinks
the param is topic when it's actually subject, and because
z3950_auth_search.tt doesn't bother putting the value of &subject into the
form.

Test plan:

1) Authorities - New authority - Topical Term
2) Tab 1, click on HEADING-TOPICAL TERM to expand subfields
3) In subfield a, type goats
4) Click Z39.50/SRU search and verify that the Subject heading search field
   has goats prefilled
---
 authorities/authorities.pl                                      | 2 +-
 .../prog/en/modules/cataloguing/z3950_auth_search.tt            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/authorities/authorities.pl b/authorities/authorities.pl
index 103e10698a..3dd39f4e7f 100755
--- a/authorities/authorities.pl
+++ b/authorities/authorities.pl
@@ -336,7 +336,7 @@ sub GetMandatoryFieldZ3950 {
             '110a' => 'authorcorp',
             '111a' => 'authormeetingcon',
             '130a' => 'uniformtitle',
-            '150a' => 'topic',
+            '150a' => 'subject',
         };
     }else{
         return {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt
index 40902b33cc..30adbfa099 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt
@@ -39,7 +39,7 @@
                 <div class="row">
                     <fieldset class="rows">
                     <ol>
-                        <li><label for="subject">Subject heading: </label> <input type="text" id="subject" name="subject" value="" /></li>
+                        <li><label for="subject">Subject heading: </label> <input type="text" id="subject" name="subject" value="[% subject | html %]" /></li>
                         <li><label for="subjectsubdiv">Subject sub-division: </label> <input type="text" id="subjectsubdiv" name="subjectsubdiv" value="" /></li>
                         <li><label for="title">Title (any): </label> <input type="text" id="title"  name="title" value="[% title | html %]" /></li>
                         <li><label for="uniformtitle">Title (uniform): </label> <input type="text" id="uniformtitle"  name="uniformtitle" value="[% uniformtitle | html %]" /></li>
-- 
2.26.1