Bug 19360 - Give items URL a link text
Summary: Give items URL a link text
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alex Buckley
QA Contact: Josef Moravec
URL:
Whiteboard:
Keywords: Academy
Depends on:
Blocks:
 
Reported: 2017-09-24 20:51 UTC by Alex Buckley
Modified: 2018-03-12 10:12 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 19360 - Give items URL a link text (10.58 KB, patch)
2017-09-25 04:21 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 19360 - Added missing atomicupdate SQL file (3.12 KB, patch)
2017-10-06 00:41 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 19360 - Give items URL a link text (10.64 KB, patch)
2017-10-06 13:31 UTC, David Bourgault
Details | Diff | Splinter Review
Bug 19360 - Added missing atomicupdate SQL file (3.18 KB, patch)
2017-10-06 13:31 UTC, David Bourgault
Details | Diff | Splinter Review
OPAC with and without Link_text (37.62 KB, image/png)
2017-10-06 13:47 UTC, David Bourgault
Details
Bug 19360 - Give items URL a link text (11.58 KB, patch)
2018-01-26 16:33 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 19360 - Added missing atomicupdate SQL file (3.25 KB, patch)
2018-01-26 16:34 UTC, Nick Clemens
Details | Diff | Splinter Review
Schema changes (2.60 KB, patch)
2018-01-26 16:34 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Buckley 2017-09-24 20:51:32 UTC
Instead of directly displaying the URL entered into the URI (Uniform Resource Identifier) field the patch attached to this bug report will allow the user to input a link text to be displayed instead of the URL on the intranet and OPAC detail page.
Comment 1 Alex Buckley 2017-09-25 04:21:42 UTC
Created attachment 67343 [details] [review]
Bug 19360 - Give items URL a link text

This patch allows a user to write in a link text when adding an item to
a MARC record in addition to a URI. The link text is displayed instead
of the URI (only if a link text has been entered, otherwise the URI
value is displayed) which makes the link more readable.

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g. https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference to an
previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an item.
When adding the item notice there is a 'Link text' option write in an
appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT
Comment 2 Alex Buckley 2017-09-25 04:36:14 UTC
When running the QA test tool all files pass except the detail.tt (see below) I reverted the changes I made and it still fails, so I believe that it is a bug introduced by a previous patch. I have written a bug report for this template (bug 19363) 

 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
   OK	  forbidden patterns
   OK	  git manipulation
   OK	  spelling
   OK	  tt_valid
   FAIL	  valid_template
		Attempt to reload Koha/Template/Plugin/Koha.pm aborted.
Compilation failed in require at /usr/lib/x86_64-linux-gnu/perl5/5.20/Template/Plugins.pm line 206.
Comment 3 Katrin Fischer 2017-09-25 04:38:35 UTC
Hi Alex, I think this might be a duplicate to bug 15352. Maybe you could take a look and help fixing it?
Comment 4 Katrin Fischer 2017-09-25 04:40:32 UTC
Hm, maybe only touching the same area
Comment 5 David Bourgault 2017-10-05 14:04:47 UTC
I followed the test plan up to step 8, but I still got an database error message when trying to add an item :
DBIx::Class::Storage::DBI::_dbh_execute(): Unknown column 'me.link_text' in 'field list' at /inlibro/git/koha-master-dev-inlibro/Koha/Objects.pm line 92

Looking at the commit, I didn't see any SQL files, did you forget to add it?
Comment 6 Dominic Pichette 2017-10-05 18:14:01 UTC
Can't find any SQL either...
Comment 7 Alex Buckley 2017-10-06 00:41:47 UTC
Created attachment 67662 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g.
https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference
to an previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an
item.
When adding the item notice there is a 'Link text' option write in
an appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT
Comment 8 Alex Buckley 2017-10-06 00:43:14 UTC
Hi David

Sorry I missed the SQL atomicupdate files in the first patch, I have just attached them in this second patch, can you please test again?
Comment 9 David Bourgault 2017-10-06 13:31:14 UTC
Created attachment 67706 [details] [review]
Bug 19360 - Give items URL a link text

This patch allows a user to write in a link text when adding an item to
a MARC record in addition to a URI. The link text is displayed instead
of the URI (only if a link text has been entered, otherwise the URI
value is displayed) which makes the link more readable.

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g. https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference to an
previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an item.
When adding the item notice there is a 'Link text' option write in an
appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 10 David Bourgault 2017-10-06 13:31:17 UTC
Created attachment 67707 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g.
https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference
to an previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an
item.
When adding the item notice there is a 'Link text' option write in
an appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 11 David Bourgault 2017-10-06 13:34:49 UTC
Tested according to test plan, worked as announced.

Note: I find it easier to update the DB by running installer/data/mysql/updatedatabase.pl than by changing the version number.

I think it would be preferable to have the 'Link Text' input right under the 'URI' input, but from what I understand of the code this would require moving many things around, for a small benefit, so not a priority.
Comment 12 Owen Leonard 2017-10-06 13:35:41 UTC
In my test the link text didn't appear in the OPAC. It read "Link to resource" instead. David did you not find that to be the case?
Comment 13 David Bourgault 2017-10-06 13:47:55 UTC
Created attachment 67711 [details]
OPAC with and without Link_text

Are you editing the marc 856$u field or the item field?
When adding an item (cataloguing/additem.pl) I had an input field for "k - Link text" and "u - URI".

I attached a picture of what it looked like for me in the OPAC.
Comment 14 Josef Moravec 2017-12-22 16:14:02 UTC
Alex,
please make the changes to Koha::Schema namespace a separate patch. It always should be done this way and generated by misc/devel/update_dbix_class_files.pl.

Also the patches need rebase.
Comment 15 Nick Clemens 2018-01-26 16:33:59 UTC
Created attachment 70967 [details] [review]
Bug 19360 - Give items URL a link text

This patch allows a user to write in a link text when adding an item to
a MARC record in addition to a URI. The link text is displayed instead
of the URI (only if a link text has been entered, otherwise the URI
value is displayed) which makes the link more readable.

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g. https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference to an
previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an item.
When adding the item notice there is a 'Link text' option write in an
appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 16 Nick Clemens 2018-01-26 16:34:03 UTC
Created attachment 70968 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g.
https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference
to an previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an
item.
When adding the item notice there is a 'Link text' option write in
an appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 17 Nick Clemens 2018-01-26 16:34:06 UTC
Created attachment 70969 [details] [review]
Schema changes
Comment 18 Nick Clemens 2018-01-26 16:35:22 UTC
Was an easy rebase, split the schema updtaes to separate patch and added cfhanges to kohastructure and deleteditems table - very cool feature
Comment 19 Josef Moravec 2018-02-05 08:51:38 UTC
Comment on attachment 70967 [details] [review]
Bug 19360 - Give items URL a link text

Review of attachment 70967 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
@@ +1215,4 @@
>                  <th id="item_priority" data-colname="item_priority">Item hold queue priority</th>
>          [% END %]
>          [% IF ( ShowCourseReservesHeader ) %]
> +                <th id="item_coursereserves">Course reserves</th>

Why do you changed this line? How it is related to this issue?
Comment 20 Josef Moravec 2018-02-05 08:54:43 UTC
Comment on attachment 70968 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Review of attachment 70968 [details] [review]:
-----------------------------------------------------------------

::: installer/data/mysql/atomicupdate/Bug-19360_Add_Link_text_field_to_items.sql
@@ +9,5 @@
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'IR', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'KT', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'SER', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'SR', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'VR', NULL)

I think you should add this field only to frameworks that does exist, have field 952 defined and 952$k not defined.

Also, this field needs to be added to installer data.
Comment 21 Katrin Fischer 2018-02-05 09:36:09 UTC
Hm, we don't have a lot of subfields left and $k and $u are rather far apart in the form, so editing won't be nice. I'd prefer something like url|text and maybe make the field repeatable as well in the future. with $k and $u separate, this would be a lot harder. We could also think about a plugin hiding the way we store the data but displaying it nicely.

This patch is in competition with bug 18760 for the last available free subfield $k.
Comment 22 Josef Moravec 2018-02-05 09:46:59 UTC
(In reply to Katrin Fischer from comment #21)
> Hm, we don't have a lot of subfields left and $k and $u are rather far apart
> in the form, so editing won't be nice. I'd prefer something like url|text
> and maybe make the field repeatable as well in the future. with $k and $u
> separate, this would be a lot harder. We could also think about a plugin
> hiding the way we store the data but displaying it nicely.
> 
> This patch is in competition with bug 18760 for the last available free
> subfield $k.

I agree, the plugin and only one field in database looks like better aproach here. We need the link text to bind with the URL - imagine somebody wants to have more then one URL field on item...
Comment 23 Alex Buckley 2018-02-28 02:15:59 UTC
Thanks for the comments. Sorry I have been travelling for the last few months and so haven't worked on this for a little while, however I am back into it now and am keen to push it forward. 

So Katrin and Josef to clarify would you like a single database field holding both the uri and link text with a delimiter? 

Then when the user loads the item page the value of this field is split at the delimiter and the URL is set as the form action and the link text is displayed?

If so, couldn't I simply remove the $k subfield and store this data value (with a data delimiter) in the $u subfield, rather than adding a brand new field url|text?

I am not familiar with Koha plugins so I've had a look at the kitchen sink example plugin and it looks like I'd need to make a tool plugin and it would need to be accessed via a link in the cataloguing/addbiblio.tt file.

The .tt file of this plugin will contain two inputs (url and link text inputs) which the backend logic concatenates and separates with a delimiter before this data value is stored in the 952$u database field of marc_subfield_structure database table.
Comment 24 Katrin Fischer 2018-02-28 06:28:40 UTC
Hi Alex, welcome back!

> If so, couldn't I simply remove the $k subfield and store this data value
> (with a data delimiter) in the $u subfield, rather than adding a brand new
> field url|text?

Yes, I think that was the thought, also to keep the last subfield $k free for now.

> 
> I am not familiar with Koha plugins so I've had a look at the kitchen sink
> example plugin and it looks like I'd need to make a tool plugin and it would
> need to be accessed via a link in the cataloguing/addbiblio.tt file.

Sorry, need to clarify. There are different kinds of plugins in Koha :) I was thinking of a value builder that you can link to the subfield via the framework configuration (look for plugin as an option there). It's older and a bit simpler than the new plugins. We use one for dateacccessioned in items, and some others are present in the record, as the helpers for the 00x fields or the authority linker.

> The .tt file of this plugin will contain two inputs (url and link text
> inputs) which the backend logic concatenates and separates with a delimiter
> before this data value is stored in the 952$u database field of
> marc_subfield_structure database table.

That was the idea - but my initial suggestion of | is not good I think. If you mark $u repeatable in the frameworks, Koha uses | for sorting multiples. Might have to think about something else, that is no tin a URL.
Comment 25 Alex Buckley 2018-03-12 10:12:58 UTC
Thanks very much Katrin! I started work on writing the value builder this evening, based on dateacccessioned.pl. Will hopefully have it ready to test by the end of the week.