From cb993cdfba74072dbd8b3e0c99dd5279e0302ee3 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 --- 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 f772a84be7..83bbf22821 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'); @@ -229,7 +231,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 aa09e7603e..315e74ee80 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 @@ -118,17 +118,17 @@
  • [% IF ( action_modify ) %] - + [% END %] - +
  • - +
  • - +
  • +

  • @@ -173,11 +180,11 @@ [% ELSE %] [% END %] [% IF ( image.checked ) %] - + [% ELSE %] [% IF ( image.KohaImage ) %] - + [% END %] [% END %] @@ -187,12 +194,30 @@
    [% END # /FOREACH imageset %] + +
    +
      +
    • + + [% IF av.imageurl.match('^http') %] + + + + [% ELSE %] + + + [% END %] +
    • +
    +
    +
    + [% END # /IF action_add_category %]
    - + Cancel
    @@ -289,7 +314,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.20.1