Bugzilla – Attachment 81279 Details for
Bug 17378
Add ability to specify maximum number of items per record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17378: Add ability to specify maximum number of items per record
Bug-17378-Add-ability-to-specify-maximum-number-of.patch (text/plain), 12.45 KB, created by
Kyle M Hall (khall)
on 2018-10-26 10:49:40 UTC
(
hide
)
Description:
Bug 17378: Add ability to specify maximum number of items per record
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-10-26 10:49:40 UTC
Size:
12.45 KB
patch
obsolete
>From 094e940bd3db0bc0fefffd52a0fa54185da6316e Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Thu, 3 May 2018 12:00:28 -0400 >Subject: [PATCH] Bug 17378: Add ability to specify maximum number of items per > record > >Some libraries want to be able to specify a hard limit on the number of items a record can have. It would be nice to have this set per record type, but since most libraries use item level itemtypes, that would make it confusing and non-intuitive. The simplest and most straight forward approach would just be to have a system preference. Koha should then just report that it failed to create an item if the librarian has hit the upper limit specified in the system preference. > >Test Plan: >1) Apply this patch >2) Run updatedatabase.pl >3) Set the new syspref RecordItemLimit to 3 >4) Find a record with 4 or more records >5) Note in the catalog toolbar you cannot choose the add new item option >6) Note in the items editor you can edit items but not add new ones >--- > .../data/mysql/atomicupdate/bug_17378.sql | 2 + > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/includes/cat-toolbar.inc | 11 +++- > .../admin/preferences/cataloguing.pref | 3 + > .../prog/en/modules/cataloguing/additem.tt | 58 +++++++++++++------ > koha-tmpl/intranet-tmpl/prog/js/catalog.js | 2 +- > 6 files changed, 56 insertions(+), 21 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_17378.sql > >diff --git a/installer/data/mysql/atomicupdate/bug_17378.sql b/installer/data/mysql/atomicupdate/bug_17378.sql >new file mode 100644 >index 0000000000..b315ec828f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_17378.sql >@@ -0,0 +1,2 @@ >+INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+('RecordItemLimit',NULL,NULL,'If this number is exceeded, a librarian will be unable to manually add more items to a record','Integer'); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 0f86627024..b9789776fb 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -458,6 +458,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('QueryWeightFields','1',NULL,'If ON, enables field weighting','YesNo'), > ('QuoteOfTheDay','0',NULL,'Enable or disable display of Quote of the Day on the OPAC home page','YesNo'), > ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), >+('RecordItemLimit',NULL,NULL,'If this number is exceeded, a librarian will be unable to manually add more items to a record','Integer'), > ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), > ('RefundLostOnReturnControl','CheckinLibrary','CheckinLibrary|ItemHomeBranch|ItemHoldingBranch','If a lost item is returned, choose which branch to pick rules for refunding.','Choice'), > ('RenewalLog','0','','If ON, log information about renewals','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 d5191e30fd..170f4f7880 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -1,3 +1,4 @@ >+[% USE Koha %] > [% INCLUDE 'blocking_errors.inc' %] > <div id="toolbar" class="btn-toolbar"> > >@@ -55,7 +56,15 @@ CAN_user_serials_create_subscription ) %] > [% END %] > [% END %] > >- [% IF ( CAN_user_editcatalogue_edit_items ) %]<li><a href="/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=[% biblionumber | html %]">Attach item</a></li>[% END %] >+ [% IF ( CAN_user_editcatalogue_edit_items ) %] >+ [% IF Koha.Preference('RecordItemLimit') && count > Koha.Preference('RecordItemLimit') %] >+ <li class="disabled"> >+ <a id="attachitem" data-toggle="tooltip" data-placement="left" title="[% count | html %] item(s) are attached to this record exceeding the threshold of [% Koha.Preference('RecordItemLimit') | html %] items. You cannot add more items." href="#">Attach item</a> >+ </li> >+ [% ELSE %] >+ <li><a href="/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=[% biblionumber | html %]">Attach item</a></li> >+ [% END %] >+ [% END %] > > [% IF ( EasyAnalyticalRecords ) %][% IF ( CAN_user_editcatalogue_edit_items ) %]<li><a href="/cgi-bin/koha/cataloguing/linkitem.pl?biblionumber=[% biblionumber | html %]">Link to host item</a>[% END %][% END %] > [% IF ( LocalCoverImages || OPACLocalCoverImages) %][% IF ( CAN_user_tools_upload_local_cover_images ) %]<li><a href="/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber | html %]&filetype=image">Upload image</a>[% END %][% END %] >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 d730530764..761493ae8f 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 >@@ -47,6 +47,9 @@ Cataloging: > no: "Don't display" > - buttons on the bib details page to print item spine labels. > - >+ - If a record has more than >+ - pref: RecordItemLimit >+ - items, don't allow a librarian to add more manually. > 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/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index 8f14152e89..a7e365e630 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -18,6 +18,9 @@ > browser.show(); > > $(document).ready(function(){ >+ [% IF opisadd && Koha.Preference('RecordItemLimit') && item_loop.size > Koha.Preference('RecordItemLimit') %] >+ $("#f fieldset.rows").hide(); >+ [% END %] > > // Remove the onclick event defined in browser.js, > // otherwise the deletion confirmation will not work correctly >@@ -119,6 +122,13 @@ function CheckMultipleAdd(f) { > if (f>99) { > return confirm(_("You are about to add %s items. Continue?").format(f)); > } >+ [% IF Koha.Preference('RecordItemLimit') %] >+ [% SET max_new_items = Koha.Preference('RecordItemLimit') - item_loop.size %] >+ if (f > [% max_new_items %]) { >+ alert(_("You are exceeding the [% Koha.Preference('RecordItemLimit') %] limit of items per record. You can only add [% max_new_items %] new item(s).")); >+ return false; >+ } >+ [% END %] > } > function Dopop(link,i) { > defaultvalue=document.forms[0].field_value[i].value; >@@ -337,31 +347,41 @@ function confirm_deletion() { > <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" /> > > <fieldset class="action"> [% IF ( opisadd ) %] >- <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" /> >- <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items >- when pressing the enter key, while in fact it is the first submit button that is validated, in our case the "add (single) item" button. >- It is a bit tricky, but necessary in the sake of UI correctness. >- --> >- <span id="addsingle"> >- <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" /> >- <input type="submit" name="add_duplicate_submit" value="Add & duplicate" onclick="return Check(this.form)" /> >- </span> >- <span id="addmultiple"> >- <input type="button" name="add_multiple_copies" id="add_multiple_copies" value="Add multiple copies of this item" /> >- </span> >- <fieldset id="add_multiple_copies_span"> >- <label for="number_of_copies">Number of copies of this item to add: </label> >- <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" /> >- <input type="submit" id="add_multiple_copies_submit" name="add_multiple_copies_submit" value="Add" onclick="javascript:return Check(this.form) && CheckMultipleAdd(this.form.number_of_copies.value);" /> <a href="#" id="cancel_add_multiple" class="cancel">Cancel</a> >- <div class="hint"><p>The barcode you enter will be incremented for each additional item.</p></div> >- </fieldset> >+ [% IF Koha.Preference('RecordItemLimit') && item_loop.size > Koha.Preference('RecordItemLimit') %] >+ <div class="dialog alert"> >+ [% item_loop.size %] items are attached to this record exceeding the threshold of [% Koha.Preference('RecordItemLimit') %] items. You cannot add more items. >+ </div> >+ [% ELSE %] >+ <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" /> >+ <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items >+ when pressing the enter key, while in fact it is the first submit button that is validated, in our case the "add (single) item" button. >+ It is a bit tricky, but necessary in the sake of UI correctness. >+ --> >+ <span id="addsingle"> >+ <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" /> >+ <input type="submit" name="add_duplicate_submit" value="Add & duplicate" onclick="return Check(this.form)" /> >+ </span> >+ <span id="addmultiple"> >+ <input type="button" name="add_multiple_copies" id="add_multiple_copies" value="Add multiple copies of this item" /> >+ </span> >+ <fieldset id="add_multiple_copies_span"> >+ <label for="number_of_copies">Number of copies of this item to add: </label> >+ <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" /> >+ <input type="submit" id="add_multiple_copies_submit" name="add_multiple_copies_submit" value="Add" onclick="javascript:return Check(this.form) && CheckMultipleAdd(this.form.number_of_copies.value);" /> <a href="#" id="cancel_add_multiple" class="cancel">Cancel</a> >+ <div class="hint"><p>The barcode you enter will be incremented for each additional item.</p></div> >+ </fieldset> >+ [% END %] > > [% ELSE %] > <input type="hidden" name="tag" value="[% itemtagfield | html %]" /> > <input type="hidden" name="subfield" value="[% itemtagsubfield | html %]" /> > <input type="hidden" name="field_value" value="[% itemnumber | html %]" /> > <input type="submit" value="Save changes" onclick="return Check(this.form)"> >- <input type="button" id="addnewitem" value="Add a new item"> >+ [% IF Koha.Preference('RecordItemLimit') && item_loop.size > Koha.Preference('RecordItemLimit') %] >+ <input type="button" id="addnewitem" value="Add a new item" disabled="disabled" title="[% item_loop.size %] item(s) are attached to this record exceeding the threshold of [% Koha.Preference('RecordItemLimit') %] items. You cannot add more items."> >+ [% ELSE %] >+ <input type="button" id="addnewitem" value="Add a new item"> >+ [% END %] > <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]">Cancel</a> > [% END %]</fieldset> > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/catalog.js b/koha-tmpl/intranet-tmpl/prog/js/catalog.js >index d99d4dc8ab..ae3e9c0906 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/catalog.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/catalog.js >@@ -102,7 +102,7 @@ $(document).ready(function() { > return false; > }); > $("#export").remove(); // Hide embedded export form if JS menus available >- $("#deletebiblio").tooltip(); >+ $("#deletebiblio,#attachitem").tooltip(); > $("#batchedit-disabled,#batchdelete-disabled,#deleteallitems-disabled") > .on("click",function(e){ > e.preventDefault(); >-- >2.17.1 (Apple Git-112)
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 17378
:
75018
| 81279