From 499c7a0a8d35b060c7e320b17d46b4e6ab991e14 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 13 Jan 2022 12:33:34 +0000 Subject: [PATCH] Bug 7374: Add remote image option for authorized values This patch adds the option of using a remote image for an authorized value, just as you can with item types. To test, apply the patch and go to Administration -> Authorized values. - Click "CCODE" to view the collection authorized values. - Edit a collection code. - In the form, under "Choose an icon," there should now be a "Remote image" tab. - Enter a remote image url, e.g. https://via.placeholder.com/50/FF0000/FFFFFF.png - Click "Save." - After the page redirects to the list of collection codes you should see your image in the table next to the code you edited. - Test that you can still edit a collection to set "No image" or to use one of the local image sets. - Test that remote images can also be added when adding a new collection. - Make sure "ccode" is in the "AdvancedSearchTypes" sytem preference. - Go to the catalog's advanced search page and click the "Collection" tab. - You should see your collection image in the list of collections. - Perform the same check in the OPAC. Signed-off-by: Lucas Gass JD amended patch: fix indentation Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers --- admin/authorised_values.pl | 16 ++++--- .../en/modules/admin/authorised_values.tt | 43 +++++++++++++++---- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index b7ee5b4426..dd8339b568 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -78,10 +78,7 @@ if ($op eq 'add_form') { if ( $av ) { $template->param( category_name => $av->category, - authorised_value => $av->authorised_value, - lib => $av->lib, - lib_opac => $av->lib_opac, - id => $av->id, + av => $av, imagesets => C4::Koha::getImageSets( checked => $av->imageurl ), ); } else { @@ -97,8 +94,13 @@ if ($op eq 'add_form') { } elsif ($op eq 'add') { my $new_authorised_value = $input->param('authorised_value'); my $new_category = $input->param('category'); - my $imageurl = $input->param( 'imageurl' ) || ''; - $imageurl = '' if $imageurl =~ /removeImage/; + my $image = $input->param( 'image' ) || ''; + my $imageurl = + $image eq 'removeImage' ? '' + : ( + $image eq 'remoteImage' ? $input->param('remoteImage') + : $image + ); my $duplicate_entry = 0; my @branches = grep { $_ ne q{} } $input->multi_param('branches'); @@ -231,7 +233,7 @@ if ( $op eq 'list' ) { $row_data{authorised_value} = $av->authorised_value; $row_data{lib} = $av->lib; $row_data{lib_opac} = $av->lib_opac; - $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $av->imageurl ); + $row_data{image} = getitemtypeimagelocation( 'intranet', $av->imageurl ); $row_data{branches} = $av->library_limits ? $av->library_limits->as_list : []; $row_data{id} = $av->id; push(@loop_data, \%row_data); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt index 4aa7da0001..3bcd576083 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -119,17 +119,17 @@
  • [% IF ( action_modify ) %] - + [% END %] - +
  • - +
  • - +
  • +

  • @@ -174,11 +181,11 @@ [% ELSE %] [% END %] [% IF ( image.checked ) %] - + [% ELSE %] [% IF ( image.KohaImage ) %] - + [% END %] [% END %] @@ -188,12 +195,30 @@
    [% END # /FOREACH imageset %] + +
    +
      +
    • + + [% IF av.imageurl.match('^http') %] + + + + [% ELSE %] + + + [% END %] +
    • +
    +
    +
    + [% END # /IF action_add_category %]
    - + Cancel
    @@ -290,7 +315,7 @@ [% loo.lib | html %] [% loo.lib_opac | html %] - [% IF ( loo.imageurl ) %][% ELSE %] [% END %] + [% IF ( loo.image ) %][% ELSE %] [% END %] [% IF loo.branches.size > 0 %] [% branches_str = "" %] -- 2.39.5