Bugzilla – Attachment 169388 Details for
Bug 37383
No edit item button on catalog detail page for items where holding library is not logged in library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37383: Use libraries_where_can_edit_items to check if items are editable
Bug-37383-Use-librarieswherecanedititems-to-check-.patch (text/plain), 4.98 KB, created by
Lucas Gass (lukeg)
on 2024-07-22 23:46:58 UTC
(
hide
)
Description:
Bug 37383: Use libraries_where_can_edit_items to check if items are editable
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-07-22 23:46:58 UTC
Size:
4.98 KB
patch
obsolete
>From a74368711040348de2cd83dd21c2cf34d0f8d5c1 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 22 Jul 2024 23:41:46 +0000 >Subject: [PATCH] Bug 37383: Use libraries_where_can_edit_items to check if > items are editable > >To test: >1 - have a system with 2+ branches >2 - have a bib with 2+ items, all with holdingbranch=A >3 - set logged in library to A >4 - go to bib details page, confirm each item has an Edit button in the holdings table >5 - edit one item, set holdingbranch=B >6 - reload bib details page >7 - confirm the item now at branch B does not have an edit button >8 - APPLY PATCH and restart_all >9 - Try 1 - 6 again, this time you should see the proper edit buttons >10 - Set up library group: > * Create a library group for library A + B > * Action: Limit item editing by group >11 - Set up test user: > * Create a staff patron with these permissions: > * catalogue > * fast_cataloguing > * edit_items > * view_borrower_infos_from_any_libraries > * edit borrowers >* Home library: library A > >12 - Set up test items: > * Create a record with 3 items with different home libraries: > * A > * B > * C > >13 - We expect the use to be able to edit A and B, but not C. >14 - With the same user turn OFF the view_borrower_infos_from_any_libraries permission >15 - Behavior should not change, we expect the use to be able to edit A and B, but not C. >16 - Make sure StaffLocationOnDetail still works as expected for all users. >--- > catalogue/detail.pl | 8 +++----- > .../html_helpers/tables/items/catalogue_detail.inc | 6 +++--- > 2 files changed, 6 insertions(+), 8 deletions(-) > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 9a1306cf05..20035acec5 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -18,6 +18,7 @@ > > use Modern::Perl; > >+use List::MoreUtils qw( uniq ); > use CGI qw ( -utf8 ); > use HTML::Entities; > use C4::Auth qw( get_template_and_user ); >@@ -495,11 +496,8 @@ if ( C4::Context->preference('UseCourseReserves') ) { > $template->param( course_reserves => $course_reserves ); > } > >-my @libraries = $biblio->items($items_params)->get_column('homebranch'); >-my %can_edit_items_from = map { >- $_ => $patron->can_edit_items_from($_) >-} @libraries; >-$template->param(can_edit_items_from => \%can_edit_items_from); >+my @libraries = $patron->libraries_where_can_edit_items; >+$template->param(can_edit_items_from => \@libraries); > > my @itemtypes = Koha::ItemTypes->search->as_list; > my %item_type_image_locations = map { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >index 18a2c36630..aceb35d927 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >@@ -190,7 +190,7 @@ > }); > const item_types_notforloan = new Map(all_item_types.map( it => [it.itemtype, it.notforloan] )); > >- const can_edit_items_from = [% To.json(can_edit_items_from || {}) | $raw %]; >+ const can_edit_items_from = [% To.json(can_edit_items_from || []) | $raw %]; > const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %]; > const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib])); > const av_lost = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.itemlost' })) | $raw %].map( av => [av.authorised_value, av.lib])); >@@ -300,7 +300,7 @@ > searchable: false, > orderable: false, > render: function (data, type, row, meta) { >- if ( can_edit_items_from[row.holding_library_id] ){ >+ if ( can_edit_items_from.includes(row.home_library_id) || !can_edit_items_from.length ){ > if ( items_selection[tab_id].includes(row.item_id) ) { > return '<input type="checkbox" value="%s" name="itemnumber" checked />'.format(row.item_id); > } else { >@@ -752,7 +752,7 @@ > { > data: function( row, type, val, meta ) { > let nodes = ''; >- if ( can_edit_items_from[row.holding_library_id] ){ >+ if ( can_edit_items_from.includes(row.home_library_id) || !can_edit_items_from.length ){ > [% IF Koha.Preference('LocalCoverImages') OR Koha.Preference('OPACLocalCoverImages') %] > nodes += '<div class="btn-group">'; > nodes += ' <a class="btn btn-default btn-xs" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=%s&itemnumber=%s#edititem"><i class="fa-solid fa-pencil"></i> %s</a><a class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>'.format(row.biblio_id, row.item_id, _("Edit")); >-- >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 37383
:
169388
|
169395
|
169429
|
169435