Bugzilla – Attachment 174241 Details for
Bug 34784
Add ability to populate empty item call numbers for a record based on the itemcallnumber system preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34784: Implement feature in staff interface
Bug-34784-Implement-feature-in-staff-interface.patch (text/plain), 11.24 KB, created by
Nick Clemens (kidclamp)
on 2024-11-07 14:41:04 UTC
(
hide
)
Description:
Bug 34784: Implement feature in staff interface
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-11-07 14:41:04 UTC
Size:
11.24 KB
patch
obsolete
>From bdc6fc773778df7eebd130a6a12c68cbe6b160fa Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 14 Sep 2023 12:22:55 -0400 >Subject: [PATCH] Bug 34784: Implement feature in staff interface > >Some libraries would like to auto-populate item call numbers for items on a record based on the system preference "itemcallnumber". Only items with empty call numbers would affected. This would add a button "Populate empty item call numbers" on catalogue/detail.pl, as well as a "Populate call number" button for each line in the holdings table to set the call number for that specific item. > >Test Plan: >1) Set the systempreference to something ( "245a" will make the > call number the record title for testing purposes ) >2) Apply this patch set >3) Restart all the things! >4) Browse to a record details page, note no new buttons >5) Enable the new syspref EnablePopulateCallnumbers >5) Reload the record details, note the new "Populate call numbers" button > in the cataloging toolbar >7) Add one or more items with no call number to the record >8) Test the "Populate call numbers" button >9) Add another item with no call number to the record >10) Test the "Populate call number" button for that single item >--- > .../data/mysql/atomicupdate/bug_34784.pl | 19 ++++++++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../prog/en/includes/cat-toolbar.inc | 4 ++ > .../tables/items/catalogue_detail.inc | 11 ++++- > .../admin/preferences/cataloguing.pref | 6 +++ > koha-tmpl/intranet-tmpl/prog/js/catalog.js | 44 +++++++++++++++++++ > 6 files changed, 83 insertions(+), 2 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_34784.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_34784.pl b/installer/data/mysql/atomicupdate/bug_34784.pl >new file mode 100755 >index 00000000000..6320a094652 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_34784.pl >@@ -0,0 +1,19 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "34784", >+ description => "Add ability to populate empty item call numbers for a record based on the itemcallnumber system preference", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) >+ VALUES ('EnablePopulateCallnumbers','0','','Enable populate call number feature','YesNo') >+ } >+ ); >+ >+ say $out "Added new system preference 'EnablePopulateCallnumbers'"; >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 34ada9d8376..4acd793c2e2 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -251,6 +251,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('EnableItemGroups','0','','Enable the item groups feature','YesNo'), > ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), > ('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo'), >+('EnablePopulateCallnumbers','0','','Enable populate call number feature','YesNo'), > ('EnableSearchHistory','0','','Enable or disable search history','YesNo'), > ('EnhancedMessagingPreferences','1','','If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'), > ('EnhancedMessagingPreferencesOPAC', '1', NULL, 'If ON, show patrons messaging setting on the OPAC.', 'YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >index 36d924b9524..6a36f731178 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -59,6 +59,10 @@ > </li> > [% END %] > >+ [% IF Koha.Preference('EnablePopulateCallnumbers') && ( ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) ) %] >+ <li><a class="dropdown-item" id="populate-callnumbers-biblio" href="#" data-biblionumber="[% biblionumber | html %]" data-toggle="tooltip" data-placement="top" title="Populate call numbers for items with no callnumber."> Populate call numbers</a></li> >+ [% END %] >+ > [% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] > <li><a class="dropdown-item" id="manageitems" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber | html %]">Manage items</a></li> > [% END %] >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 7e44c02a5a1..32bc98fc6e7 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 >@@ -775,11 +775,18 @@ > data: function( row, type, val, meta ) { > let nodes = ''; > if ( can_edit_items_from.includes(row.home_library_id) || !can_edit_items_from.length ){ >- [% IF Koha.Preference('LocalCoverImages') OR Koha.Preference('OPACLocalCoverImages') %] >+ [% SET show_itemcallnumber_link = !item.itemcallnumber && Koha.Preference('EnablePopulateCallnumbers') %] >+ [% SET show_local_covers_link = Koha.Preference('LocalCoverImages') OR Koha.Preference('OPACLocalCoverImages') %] >+ [% IF show_itemcallnumber_link || show_local_covers_link %] > 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-bs-toggle="dropdown"><span class="caret"></span></a>'.format(row.biblio_id, row.item_id, _("Edit")); > nodes += ' <ul class="dropdown-menu pull-right">'; >- nodes += ' <li><a class="dropdown-item" href="/cgi-bin/koha/tools/upload-cover-image.pl?itemnumber=%s&filetype=image"><i class="fa fa-upload"></i> %s</a></li>'.format(row.item_id, _("Upload image")); >+ [% IF show_local_covers_link %] >+ nodes += ' <li><a class="dropdown-item" href="/cgi-bin/koha/tools/upload-cover-image.pl?itemnumber=%s&filetype=image"><i class="fa fa-upload"></i> %s</a></li>'.format(row.item_id, _("Upload image")); >+ [% END %] >+ [% IF show_itemcallnumber_link %] >+ nodes += ' <li><a class="dropdown-item populate-callnumber-item" href="#" data-itemnumber="%s" data-biblionumber="%s" data-toggle="tooltip" data-placement="left" title="Populate call number for this item."><i class="fa fa-bars"></i> %s</a></li>'.format(row.item_id, row.biblio_id, _("Populate call number")); >+ [% END %] > nodes += ' </ul>'; > nodes += '</div>'; > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index ffd9b7e5498..a1ac3f64aa0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -77,6 +77,12 @@ Cataloging: > 0: "Don't show" > - buttons on the bibliographic details page to print item spine labels. > - >+ - pref: EnablePopulateCallnumbers >+ choices: >+ 1: Show >+ 0: "Don't show" >+ - buttons on the catalog details page to populate empty item call numbers from the record based on the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=itemcallnumber">itemcallnumber</a> system preference. >+ - > Record structure: > - > - "Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see <a href='http://www.loc.gov/marc/languages/language_code.html'>MARC Code List for Languages</a>):" >diff --git a/koha-tmpl/intranet-tmpl/prog/js/catalog.js b/koha-tmpl/intranet-tmpl/prog/js/catalog.js >index ec37cb08940..eea77ecdf79 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/catalog.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/catalog.js >@@ -118,6 +118,50 @@ $(document).ready(function() { > }); > $("#export").remove(); // Hide embedded export form if JS menus available > >+ $("#populate-callnumbers-biblio") >+ .on('click', function() { >+ if ( confirm(__('Are you sure you want to populate call numbers for all items without a callnumber on this record?')) ) { >+ const biblionumber = $(this).data('biblionumber'); >+ $.post( `/api/v1/rpc/biblios/${biblionumber}/items/populate_empty_callnumbers`, function( data ) { >+ const items_updated = data.modified_item_ids; >+ const callnumber = data.callnumber; >+ let msg = ""; >+ if( items_updated ){ >+ msg += __('Items populated with the call number "%s": %s').format(callnumber, items_updated); >+ } else { >+ msg += __('No ttems were updated'); >+ } >+ >+ if ( items_updated ) { >+ msg += __('\nReload the page?'); >+ if( confirm(msg) ) { >+ location.reload(true); >+ } >+ } else { >+ alert(msg); >+ } >+ }); >+ } >+ }).tooltip(); >+ >+ $("body") >+ .on('click','.populate-callnumber-item', function() { >+ if ( confirm(__('Are you sure you want to populate the call number for this item?')) ) { >+ const biblionumber = $(this).data('biblionumber'); >+ const itemnumber = $(this).data('itemnumber'); >+ const button = $(this); >+ $.post( `/api/v1/rpc/biblios/${biblionumber}/items/${itemnumber}/populate_empty_callnumbers`, function( data ) { >+ const callnumber = data.callnumber; >+ let msg = __('Item populated with the call number "%s"\nReload the page?').format(callnumber); >+ if( confirm(msg) ) { >+ location.reload(true); >+ } else { >+ button.hide(); >+ } >+ }); >+ } >+ }).tooltip(); >+ > $(".addtolist").on("click", function (e) { > e.preventDefault(); > var shelfnumber = $(this).data("shelfnumber"); >-- >2.39.5
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 34784
:
155623
|
155624
|
155626
|
155627
|
156140
|
156141
|
158554
|
158555
|
158556
|
158569
|
158570
|
158571
|
158572
|
158593
|
158627
|
158628
|
158629
|
158630
|
158631
|
160349
|
173076
|
173077
|
173078
| 174241