Bug 24352

Summary: Wrong labels displaying in result list with OpacItemLocation
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: OPACAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: aleisha, david, lucas, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16147
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the OPAC's MARC21 search results XSLT so that OPAC search result information is correctly labelled based on the OpacItemLocation preference. Previously, search results showed the label "Location(s)" whether the setting was "collection code" or "location."
Version(s) released in:
20.11.00, 20.05.02, 19.11.08, 19.05.14
Attachments: Screenshot of modified template
Bug 24352: OpacItemLocation is buggy
Bug 24352: OpacItemLocation is buggy
Bug 24352: Correct location and collection labels in OPAC search results
Bug 24352: Correct location and collection labels in OPAC search results
Bug 24352: Correct location and collection labels in OPAC search results

Description Katrin Fischer 2020-01-06 15:24:12 UTC
The different settings from the OpacItemLocation don't appear to work correctly. When "collection" is selected, collection is not visible, but a label 'Location(s)' shows up?

The callnumber never showed for me in my testing?
Comment 1 Owen Leonard 2020-01-10 13:58:10 UTC
Created attachment 97221 [details]
Screenshot of modified template

Does this look correct?

The screenshot shows the results from the three different OpacItemLocation settings:

 - Call number
 - Location
 - Collection
Comment 2 Owen Leonard 2020-01-10 14:21:56 UTC Comment hidden (obsolete)
Comment 3 David Nind 2020-01-11 00:54:32 UTC
These are the results for me from changing OpacItemLocation after applying the patch (searching for cat on koha-testing-docker):

call number only - doesn't show the call number:
Availability: Items available for loan: Fairview (2), Midway (1).

collection code:
Availability: Items available for loan: Fairview (2), Midway (1).
Collection(s): GEN , GEN .

location:
Availability: Items available for loan: Fairview (2), Midway (1).
Location(s): General Stacks , General Stacks .
Comment 4 Owen Leonard 2020-01-11 14:40:57 UTC
David, it sounds like you're seeing what Katrin was seeing, but I don't know what might be different about our setup/data to cause it--assuming you're looking at records which have call numbers?
Comment 5 David Nind 2020-01-11 23:14:12 UTC
Face palm - records didn't have call numbers!
Comment 6 David Nind 2020-01-11 23:16:10 UTC
Created attachment 97257 [details] [review]
Bug 24352: OpacItemLocation is buggy

This patch modifies the OPAC's MARC21 search results XSLT so that the
OpacItemLocation preference correctly controls what information
displays. Previously the code for distinguishing between the 'location'
and 'collection' settings was combined.

To test, apply the patch and set the OPACXSLTResultsDisplay system
preference to 'default.'

Set the OpacItemLocation preference to 'call number only.'
 - On the OPAC search results page, each result with items should show
   information in this format:
   - "Availability: Items available for loan: {library} [Call number:
     {call number} ]

  With the OpacItemLocation preference set to 'collection code,'
   - "Availability: Items available for loan: {library}
      Collection(s): {collection description} [{ call number }]"

  With the OpacItemLocation preference set to 'location,'
   - "Availability: Items available for loan: {library}
      Location(s): {shelving location} [{ call number }]"

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Katrin Fischer 2020-01-14 21:59:05 UTC
I sorry Owen, not having a good run on your patches tonight :(

In my setup this doesn't work when there are no collections set on any of the items on the record:

Collection(s): . 

Could you have another look please?
Comment 8 Owen Leonard 2020-01-15 17:44:04 UTC
(In reply to Katrin Fischer from comment #7)
> Collection(s): . 

It still sounds to me like the item must not have a call number. Even if the items have no location, for instance, the call numbers show up for me:

https://zivotdesign.com/p/view.php?p=15791100203899
Comment 9 Katrin Fischer 2020-01-15 22:16:20 UTC
Hi Owen, you were right, but still struggling a bit with these patches, can you help?

These are my items:
Books 	Centerville Fiction 	Non-fiction 	782.42166092 B (Browse shelf) 	Available 	
Books 	Centerville New Materials Shelf 	Non-fiction 	782.42166092 B (Browse shelf) 	Pending hold 	
Books 	Union Fiction 	Reference 	782.42166092 B (Browse shelf) 	Available

So all 3 have locations, one is a pending hold, 2 are available. In the result list, only reference shows:

Availability: Items available for loan: Centerville (2). Pending hold (1). Collection(s): Reference [782.42166092 B]. 

Can you tell why the collection Non-fiction doesn't show?
Comment 10 Owen Leonard 2020-06-16 19:58:29 UTC
Created attachment 105931 [details] [review]
Bug 24352: Correct location and collection labels in OPAC search results

This patch modifies the OPAC's MARC21 search results XSLT so that
OPAC search result information is correctly labeled
based on the OpacItemLocation preference.

Previously, search results showed the label "Location(s)" whether the
setting was "collection code" or "location."

To test, apply the patch and set the OPACXSLTResultsDisplay system
preference to 'default.'

On the OPAC search results page, each result with items should show
information in this format:

   With the OpacItemLocation preference set to 'call number only,'
    - "Availability: Items available for loan: {library} [Call number:
      {call number} ]

   With the OpacItemLocation preference set to 'collection code,'
     - "Availability: Items available for loan: {library}
        Collection(s): {collection description} [{ call number }]"

   With the OpacItemLocation preference set to 'location,'
     - "Availability: Items available for loan: {library}
        Location(s): {shelving location} [{ call number }]"
Comment 11 Owen Leonard 2020-06-16 20:06:43 UTC
The new patch changes much less, in part because the XSL markup has changed a lot since I submitted the original patch. I'm still not certain I understand the original bug report, but I fixed what problem I could see.
Comment 12 David Nind 2020-06-17 11:50:31 UTC
Created attachment 105948 [details] [review]
Bug 24352: Correct location and collection labels in OPAC search results

This patch modifies the OPAC's MARC21 search results XSLT so that
OPAC search result information is correctly labeled
based on the OpacItemLocation preference.

Previously, search results showed the label "Location(s)" whether the
setting was "collection code" or "location."

To test, apply the patch and set the OPACXSLTResultsDisplay system
preference to 'default.'

On the OPAC search results page, each result with items should show
information in this format:

   With the OpacItemLocation preference set to 'call number only,'
    - "Availability: Items available for loan: {library} [Call number:
      {call number} ]

   With the OpacItemLocation preference set to 'collection code,'
     - "Availability: Items available for loan: {library}
        Collection(s): {collection description} [{ call number }]"

   With the OpacItemLocation preference set to 'location,'
     - "Availability: Items available for loan: {library}
        Location(s): {shelving location} [{ call number }]"

Signed-off-by: David Nind <david@davidnind.com>
Comment 13 Martin Renvoize 2020-06-19 13:37:26 UTC
Leaving QA to Katrin as the original bug reporter.
Comment 14 Katrin Fischer 2020-06-22 22:28:43 UTC
There are still some oddities (punctuation, repeating the same location/collection), but I believe this is a great improvement :)
Comment 15 Katrin Fischer 2020-06-22 22:29:21 UTC
Created attachment 106171 [details] [review]
Bug 24352: Correct location and collection labels in OPAC search results

This patch modifies the OPAC's MARC21 search results XSLT so that
OPAC search result information is correctly labeled
based on the OpacItemLocation preference.

Previously, search results showed the label "Location(s)" whether the
setting was "collection code" or "location."

To test, apply the patch and set the OPACXSLTResultsDisplay system
preference to 'default.'

On the OPAC search results page, each result with items should show
information in this format:

   With the OpacItemLocation preference set to 'call number only,'
    - "Availability: Items available for loan: {library} [Call number:
      {call number} ]

   With the OpacItemLocation preference set to 'collection code,'
     - "Availability: Items available for loan: {library}
        Collection(s): {collection description} [{ call number }]"

   With the OpacItemLocation preference set to 'location,'
     - "Availability: Items available for loan: {library}
        Location(s): {shelving location} [{ call number }]"

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 16 Jonathan Druart 2020-06-24 13:31:47 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 17 Lucas Gass 2020-07-10 16:00:52 UTC
backported to 20.05.x for 20.05.02
Comment 18 Aleisha Amohia 2020-07-13 01:57:36 UTC
backported to 19.11.x for 19.11.08
Comment 19 Victor Grousset/tuxayo 2020-07-23 23:37:01 UTC
Backported to 19.05.x branch for 19.05.14