diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index bd25081c0d..a8134712f4 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 and fill form } elsif (defined $format) { die "Unsupported format $format"; } @@ -119,7 +121,7 @@ if ( Koha::MarcSubfieldStructures->search( { frameworkcode => '', kohafield => ' $template->param( has_new_status => 1 ); } -if ( defined $format ) { +if ( defined $format and $format ne 'shareable') { # Parameters given, it's a search my $filter = { @@ -351,6 +353,7 @@ $template->param( damageds => \@damageds, items_search_fields => \@items_search_fields, authorised_values_json => to_json($authorised_values), + query => $cgi, ); output_html_with_http_headers $cgi, $cookie, $template->output; 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 c0909122f4..34cdb5d2ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -37,30 +37,59 @@
[% END %] [% BLOCK form_field_select_option %] - + [% IF query.param('f').$i == value || query.param('f') == value %] + + [% ELSE %] + + [% END %] [% END %] [% BLOCK form_field_select_text %] + [% SET i = loop.index %]
- + [% IF loop.first || !query.param('f') %] + + [% ELSE %] + [% SET j = i - 1 %] + + [% END %] - [% IF params.exists('op') %] - - [% ELSE %] - - [% END %] - + +
[% END %] @@ -210,16 +233,34 @@ [% END %]
- + [% IF query.param('onloan') == '' %] + + [% ELSE %] + + [% END %] - + [% IF query.param('onloan') == 'IS NOT NULL' %] + + [% ELSE %] + + [% END %] - + [% IF query.param('onloan') == 'IS NULL' %] + + [% ELSE %] + + [% END %]
- [% INCLUDE form_field_select_text %] + [% IF !query.param('f') %] + [% INCLUDE form_field_select_text %] + [% ELSE %] + [% FOREACH field IN query.param('f') %] + [% INCLUDE form_field_select_text %] + [% END %] + [% END %]

You can use the following wildcard characters: % _

% matches any number of characters

_ matches only a single character

@@ -227,12 +268,12 @@
- + (inclusive)
- + (inclusive)
[% IF ( has_new_status ) %] @@ -241,21 +282,49 @@
- +
- + ISO Format (YYYY-MM-DD)
@@ -368,6 +437,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 = '' + ' ' @@ -451,6 +534,24 @@ $('#item-search-block').show(); }); + var getShareableLink = $('') + .attr('href', '#') + .html(" " + _("Copy shareable link") ) + .addClass('btn btn-secondary') + .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.origin + window.location.pathname + '?' + $.param(params); + navigator.clipboard.writeText(url); + $(this).tooltip({trigger: 'manual', title: 'Copied!'}).tooltip('show'); + }); + var results_heading = $('
').addClass('results-heading') .append("

" + _("Item search results") + "

") .append($('

').append(advSearchLink)) @@ -458,21 +559,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,