Bugzilla – Attachment 164962 Details for
Bug 14322
Can't link to an item search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14322: Add button to copy link to an item search
Bug-14322-Add-button-to-copy-link-to-an-item-searc.patch (text/plain), 4.11 KB, created by
Brendan Lawlor
on 2024-04-16 21:13:07 UTC
(
hide
)
Description:
Bug 14322: Add button to copy link to an item search
Filename:
MIME Type:
Creator:
Brendan Lawlor
Created:
2024-04-16 21:13:07 UTC
Size:
4.11 KB
patch
obsolete
>From d557c25f1ec8780c96faf3a795405890517f8ee9 Mon Sep 17 00:00:00 2001 >From: Brendan Lawlor <blawlor@clamsnet.org> >Date: Tue, 16 Apr 2024 20:18:10 +0000 >Subject: [PATCH] Bug 14322: Add button to copy link to an item search > >This work in progress patch adds a button to copy a url with all the parameters for an item search. The button currently works to copy a url with all the item search parameters url encoded, but the url returns 500.To make it work itemsearch.pl needs some updates to handle when the url parameter shareable=1, then it should process all the prameters from the url. > >Test plan: >1. Apply patch >2. Do an item search >3. On the results page see a new 'Copy shareable link' button >4. Click the button and confirm that you can paste a url with all parameters from the form url encoded >5. Paste the url in the browser and notice you get a 500 error :( >--- > .../prog/en/modules/catalogue/itemsearch.tt | 38 ++++++++++++++----- > 1 file changed, 28 insertions(+), 10 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >index 2b064b157f..37d76b3f0d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -368,6 +368,20 @@ > } > } > >+ function getParams($form) { >+ var params = []; >+ $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() { >+ if ( $(this).prop('tagName').toLowerCase() == 'option' ) { >+ var name = $(this).parents('select').first().attr('name'); >+ var value = $(this).val(); >+ params.push({ 'name': name, 'value': value }); >+ } else { >+ params.push({ 'name': $(this).attr('name'), 'value': $(this).val() }); >+ } >+ }); >+ return params; >+ } >+ > function submitForm($form) { > var tr = '' > + ' <tr>' >@@ -449,6 +463,18 @@ > $('#item-search-block').show(); > }); > >+ var getShareableLink = $('<a>') >+ .attr('href', '#') >+ .html("<i class='fa fa-link'></i> " + _("Copy shareable link") ) >+ .addClass('btn btn-default') >+ .on('click', function(e) { >+ e.preventDefault(); >+ var params = getParams( $('#itemsearchform') ); >+ params.push({ 'name': 'shareable', 'value': 1 }); >+ var url = window.location.href + '?' + $.param(params); >+ navigator.clipboard.writeText(url); >+ }); >+ > var results_heading = $('<div>').addClass('results-heading') > .append("<h1>" + _("Item search results") + "</h1>") > .append($('<p>').append(advSearchLink)) >@@ -456,21 +482,13 @@ > .addClass("btn-toolbar") > .attr("id","toolbar") > .append(editSearchLink) >+ .append(getShareableLink) > ); > $('#results-wrapper').empty() > .append(results_heading) > .append(table); > >- var params = []; >- $form.find('select:not(:disabled) option:selected,input[type="text"]:not(:disabled),input[type="hidden"]:not(:disabled),input[type="radio"]:checked').each(function() { >- if ( $(this).prop('tagName').toLowerCase() == 'option' ) { >- var name = $(this).parents('select').first().attr('name'); >- var value = $(this).val(); >- params.push({ 'name': name, 'value': value }); >- } else { >- params.push({ 'name': $(this).attr('name'), 'value': $(this).val() }); >- } >- }); >+ var params = getParams($form); > > $('#results').dataTable($.extend(true, {}, dataTablesDefaults, { > "destroy": true, >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14322
: 164962