Bug 32333

Summary: IdRef system preference revamping
Product: Koha Reporter: Frédéric Demians <f.demians>
Component: OPACAssignee: Frédéric Demians <f.demians>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: david, jonathan.druart, laurence.rault, m.de.rooy, matthias.meusburger
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34710
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 8290, 34710    
Attachments: Bug 32333: IdRef system preference revamping
Bug 32333: IdRef system preference revamping
Bug 32333: IdRef system preference revamping
Bug 32333: IdRef system preference revamping

Description Frédéric Demians 2022-11-23 11:53:47 UTC
IdRef system preference enables a Unimarc-only functionality. Authors
fields contain in $3 subfield a PPN, an unique identifier in IdRef a
French national authority file, similar to VIAF.

KohaLa, the Koha French users association, has designed a revamped
implementation of IdRef in Koha. The goal is to improve the visual and
to add a functionality.

- Visually — The author publications list is currently displayed in
  an old fashion dialog box. It uses greybox library, which is
  deprecated. See bug 8290. The list is displayed in a
  distinct tab of holdings block.

- Functionality — The title in the list are searched in Koha local
  catalog. So it's possible to mark titles locally available and link
  to them. PPN are searched directly in Elasticsearch for efficiency.
  Koha IdRef users are academic libraries or higher education school. So
  Zebra support is not required for them.
Comment 1 Frédéric Demians 2022-11-23 12:06:33 UTC Comment hidden (obsolete)
Comment 2 David Nind 2022-11-24 18:18:16 UTC
Changed assignee.
Comment 3 Matthias Meusburger 2023-01-25 16:08:52 UTC Comment hidden (obsolete)
Comment 4 Matthias Meusburger 2023-01-25 16:10:39 UTC
The patch works as expected, however, some additional information could be added to the test plan:

 - it only works with Elastic Search.
 - an extra "ppn" index must be created.
Comment 5 Marcel de Rooy 2023-03-03 08:02:08 UTC
Why does this depend on 8290 ?
Comment 6 Marcel de Rooy 2023-03-03 08:09:30 UTC
 FAIL   koha-tmpl/opac-tmpl/bootstrap/js/idref.js
   FAIL   ES template literals
                ES template literals found (        const url = `/cgi-bin/koha/svc/idref?ppn=${ppn}`;) - See bug 24725
                ES template literals found (                const navig = publications.roles.map(role => `<a href="#idref-role-${role.code}" style="font-size: 90%;">${role.label} (${role.docs.length})</a>`);) - See bug 24725
                ES template literals found (                        html += `</td><td>${doc.citation}</td></tr>`;) - See bug 24725
                ES template literals found (                html = `<div id="idref-publications">${html}</div>`;) - See bug 24725
Comment 7 Frédéric Demians 2023-03-03 10:48:10 UTC
(In reply to Marcel de Rooy from comment #5)
> Why does this depend on 8290 ?

Because if this patch is applied, Greybox dependence can be removed completely from Koha code base?
Comment 8 Frédéric Demians 2023-03-03 10:49:45 UTC
> FAIL   ES template literals

Sorry for this. Why is Javascript template literal usage prohibited?
Comment 9 Katrin Fischer 2023-03-03 13:39:43 UTC
(In reply to Frédéric Demians from comment #8)
> > FAIL   ES template literals
> 
> Sorry for this. Why is Javascript template literal usage prohibited?

The clue is in the message :) 
Bug 24725 - xgettext does not support (yet) ES template literals
Comment 10 Katrin Fischer 2023-03-03 13:40:36 UTC
(In reply to Frédéric Demians from comment #7)
> (In reply to Marcel de Rooy from comment #5)
> > Why does this depend on 8290 ?
> 
> Because if this patch is applied, Greybox dependence can be removed
> completely from Koha code base?

I moved it to Blocks - this patch blocks the removal.
Comment 11 Frédéric Demians 2023-03-04 15:28:05 UTC Comment hidden (obsolete)
Comment 12 Frédéric Demians 2023-03-04 15:30:10 UTC
Exactly the same patch without using JS template literals ``. Nothing else to test.
Comment 13 Frédéric Demians 2023-05-04 14:55:48 UTC
Created attachment 150675 [details] [review]
Bug 32333: IdRef system preference revamping

IdRef system preference enables a Unimarc-only functionality. Authors
fields contain in $3 subfield a PPN, an unique identifier in IdRef a
French national authority file, similar to VIAF.

KohaLa, the Koha French users association, has designed a revamped
implementation of IdRef in Koha. The goal is to improve the visual and
to add a functionality.

- Visually — The author publications list is currently displayed in
  an old fashion dialog box. It uses greybox library, which is
  deprecated. See bug 8290. With this patch, the list is displayed in a
  distinct tab of holdings block.

- Functionality — The title in the list are searched in Koha local
  catalog. So it's possible to mark titles locally available and link
  to them. PPN are searched directly in Elasticsearch for efficiency.
  Koha IdRef users are academic libraries or higher education school. So
  Zebra support is not required for them.

NOTE: After pushing this patch, greybox library could be removed
      completely for OPAC :
      /koha-tmpl/opac-tmpl/bootstrap/lib/greybox/

TO TEST :

- On a Unimarc Koha, with a Sudoc compliant Catalog, enable IdRef.
- Use default OPAC XSL.
- On opac-detail.pl page, you can see a logo IdRef next to authors
  having a $3 (ppn) subfield. Click on the logo.
- Confirm that a tab is added to holdings. It contains the author
  publications found in the Sudoc.
- A Sudoc logo is displayed in front of each title. Clicking the icon
  open the title in Sudoc web site.
- A Koha logo is displayed in from of each title available locally.
  Clicking the logo open the title in Koha OPAC.
Comment 14 Owen Leonard 2023-06-12 16:43:06 UTC
I can't finish testing this right now because I don't have Elasticsearch working, but I have a question: Why not display the IdRef tab right away? Why wait for the user to click the link by the author?
Comment 15 Frédéric Demians 2023-06-12 16:58:01 UTC
> Why not display the IdRef tab right away?
> Why wait for the user to click the link by the author?

From my perspective, two main reasons : (1) Need — A user viewing a biblio record, generally don't need/want to see all other publications from document's author. And how to deal with multiples authors... (2) Fair use — This plugin queries IdRef webservice. It's "polite" not to abuse this service usage.
Comment 16 Laurence Rault 2023-09-27 07:31:12 UTC
Tested on koha-testing-docker, works almost as expected

1) Should be added in the test plan : require to define a ppn index for the ppn of the record (to be able to do the back search of other existing records in Koha) (in BibLibre standard configuration it is for 009 field)
Maybe the index should be added by the patch, to add it if not already present in ES configuration ?

2) In the Idref results list, the link to Idref or to Koha contain target, so for Idref produce Not found : 
https://www.sudoc.fr/260997757%20target
http://localhost:8080/cgi-bin/koha/opac-detail.pl?biblionumber=21650%20target=

3) Maybe an alert : Idref results sometimes take a long time to display (depending on the searched author, on the moment when the search is done, ...)
Comment 17 Frédéric Demians 2023-09-27 13:41:50 UTC
Also available as part of a plugin:

https://github.com/fredericd/Koha-Plugin-KohaLa-AbesWS#publications-idref-%C3%A0-lopac

It may be preferable to exfiltrate idref code from Koha core.