To recreate: -Do a search within the staff client -Click on any results and go to the detail page -Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnumber=117#edititem&searchid=scs_1619109565224' This URL has the '#edititem' anchor in it, but since it is in between 2 other params and the '&searchid=' param has been appended after the anchor it doesn't work. If you edit the URL manually to be this order it will work: /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnumber=117&searchid=scs_1619109565224#edititem The anchor must go last. This is an annoyance to librarians, particularly for records with lots items attached to it.
Some more info. about the hierarchical structure of URLs: https://tools.ietf.org/html/rfc3986#section-3 The anchor being the least important needs to be last
Created attachment 120027 [details] [review] Bug 28196: make sure hash is always appended last To test: -Do a search within the staff client -Click on any results and go to the detail page -Click the edit button on any item in that record, you will be taken to the edit item screen but you will not be taken to the <h2 id="edititem"> placeholder -Apply patch and try again -This time when taken to the edit item screen you should be placed right at the <h2 id="edititem"> placeholder
My patch fixes the problem by changing browser.js. Perhaps a better solution would be to add the searchid into the links inside each of the templates that call browser.js. It seems to only be called in a handful of templates: root@kohadevbox:koha(master)$ git grep 'Asset.js("js/browser.js")' koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/stockrotation.tt: [% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt:[% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt:[% Asset.js("js/browser.js") | $raw %] koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt: [% Asset.js("js/browser.js") | $raw %]
Since we don't support Internet Explorer, why not use the URL object, and let it do the work of parsing for you? Something like (untested, so I'll probably typo something) let parsedurl = new URL($(this).attr('href')); parsedurl.searchParams.set('searchid',me.searchid); window.location = parsedurl.href; Bonus advantage: if searchParams.set() sees that someone has screwed up and the URL already has two searchid params in it, it'll set one and delete the other, while doing it by hand would be adding a third.
(In reply to Phil Ringnalda from comment #4) > Since we don't support Internet Explorer, why not use the URL object, and > let it do the work of parsing for you? > > Something like (untested, so I'll probably typo something) > > let parsedurl = new URL($(this).attr('href')); > parsedurl.searchParams.set('searchid',me.searchid); > window.location = parsedurl.href; > > Bonus advantage: if searchParams.set() sees that someone has screwed up and > the URL already has two searchid params in it, it'll set one and delete the > other, while doing it by hand would be adding a third. Thanks Phil, As far as I understand it new URL() with a single argument must include an absolute path. You can give it a relative URL, but in that case you must always pass the base URL as the 2nd argument. If I'm wrong I am happy for someone to let me know of provide an alternate patch!
Sorry, let parsedurl = new URL($(this).attr('href'),document.baseURI); - I didn't actually look at what $(this).attr('href') was.
without the patch the problem exist when you try to search within the catalogues but it does not exist when you search for a catalogue then you try to edit an item from the same catalogue. after the patch it does not fix the problem.
Created attachment 122352 [details] [review] Bug 28196: make sure URL hash is appended last TO test: 1 Do a search within the staff client 2 Click on any results and go to the detail page 3 Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnumber=117#edititem&searchid=scs_1619109565224' 4 Apply patch 5 Do steps 1 & 2 again Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnum ber=117&searchid=scs_1619109565224#edititem' 6. If they URL hash is last the anchor should work and you'll be placed on the h2 element with and ID of edititem
Created attachment 122384 [details] [review] Bug 28196: make sure URL hash is appended last TO test: 1 Do a search within the staff client 2 Click on any results and go to the detail page 3 Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnumber=117#edititem&searchid=scs_1619109565224' 4 Apply patch 5 Do steps 1 & 2 again Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnum ber=117&searchid=scs_1619109565224#edititem' 6. If they URL hash is last the anchor should work and you'll be placed on the h2 element with and ID of edititem Signed-off-by: David Nind <david@davidnind.com>
Created attachment 122747 [details] [review] Bug 28196: make sure URL hash is appended last TO test: 1 Do a search within the staff client 2 Click on any results and go to the detail page 3 Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnumber=117#edititem&searchid=scs_1619109565224' 4 Apply patch 5 Do steps 1 & 2 again Click the edit button on any item in that record, it should take you to a URL like this: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=55&itemnum ber=117&searchid=scs_1619109565224#edititem' 6. If they URL hash is last the anchor should work and you'll be placed on the h2 element with and ID of edititem Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Oops, this breaks item editing, the form now has values like: <input type="hidden" name="itemnumber" value="974searchid=scs_1625837723086">
Created attachment 152478 [details] [review] Bug 28196: Insert searchid in URL correctly, so it doesn't follow the hash Test plan: 1. Search the catalog in the staff client for anything which will return at least two results 2. Click on any result to go to the bib detail page 3. Click the edit button for any item attached to the bib 4. Verify that the loaded URL contains &searchid=scs_(a number), and that the URL ends with #edititem 5. Make any change to the item, save, verify that your change was made
One handy feature of using searchParams.set rather than concatenating strings to form a URL is that you don't have to remember to include the ampersand.
Created attachment 152686 [details] [review] Bug 28196: Insert searchid in URL correctly, so it doesn't follow the hash Test plan: 1. Search the catalog in the staff client for anything which will return at least two results 2. Click on any result to go to the bib detail page 3. Click the edit button for any item attached to the bib 4. Verify that the loaded URL contains &searchid=scs_(a number), and that the URL ends with #edititem 5. Make any change to the item, save, verify that your change was made Signed-off-by: Sam Lau <samalau@gmail.com>
Created attachment 153295 [details] [review] Bug 28196: Insert searchid in URL correctly, so it doesn't follow the hash Test plan: 1. Search the catalog in the staff client for anything which will return at least two results 2. Click on any result to go to the bib detail page 3. Click the edit button for any item attached to the bib 4. Verify that the loaded URL contains &searchid=scs_(a number), and that the URL ends with #edititem 5. Make any change to the item, save, verify that your change was made Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 23.11. Nice work everyone, thanks!
Thanks for all the hard work! Pushed to 23.05.x for the next release
Nice work everyone! Pushed to oldstable for 22.11.x