Bugzilla – Attachment 168084 Details for
Bug 14322
Add option to create a shareable link for item searches
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), 5.00 KB, created by
Brendan Lawlor
on 2024-06-25 15:42:29 UTC
(
hide
)
Description:
Bug 14322: Add button to copy link to an item search
Filename:
MIME Type:
Creator:
Brendan Lawlor
Created:
2024-06-25 15:42:29 UTC
Size:
5.00 KB
patch
obsolete
>From 0814609f7bc60a9295911c88eeffc1a24c8f4930 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 format=shareable, then it should handle authentication process all the prameters from the url. It would be really cool to also parameterize the state of the data table so the link could go straight to a filtered sorted result. > >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 :( >--- > catalogue/itemsearch.pl | 2 + > .../prog/en/modules/catalogue/itemsearch.tt | 43 ++++++++++++++----- > 2 files changed, 35 insertions(+), 10 deletions(-) > >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index bd25081c0d..d32faa550d 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -90,6 +90,8 @@ if (defined $format and $format eq 'json') { > } elsif (defined $format and $format eq 'barcodes') { > # Retrieve all results > $cgi->param('rows', 0); >+} elsif (defined$format and $format eq 'shareable') { >+ # get the item search parameters from the url!?!? > } elsif (defined $format) { > die "Unsupported format $format"; > } >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 59b4c9225a..88e53477a7 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>' >@@ -451,6 +465,23 @@ > $('#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 = params.map(p => { >+ if(p.name === 'format') { >+ return { ...p, value: 'shareable' }; >+ } >+ return p; >+ }) >+ 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)) >@@ -458,21 +489,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
|
168084
|
168768
|
168863
|
169029
|
169033
|
169304
|
169305
|
169306
|
169948
|
169949
|
169950
|
169951
|
169952
|
169969
|
169970
|
169971
|
169972
|
169973
|
170347
|
170348
|
170349
|
170350
|
170351
|
170352
|
170721
|
170722
|
170723
|
170724
|
170725
|
170726
|
170727