Bugzilla – Attachment 177464 Details for
Bug 8137
Checkout limit for all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8137: (follow-up) fix behavior with edit and clear actions
Bug-8137-follow-up-fix-behavior-with-edit-and-clea.patch (text/plain), 10.34 KB, created by
Thibaud Guillot (thibaud_g)
on 2025-02-03 08:55:38 UTC
(
hide
)
Description:
Bug 8137: (follow-up) fix behavior with edit and clear actions
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2025-02-03 08:55:38 UTC
Size:
10.34 KB
patch
obsolete
>From 3d03790ec999c7c981a33f2659ab614e4a6323db Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Mon, 3 Feb 2025 08:55:11 +0000 >Subject: [PATCH] Bug 8137: (follow-up) fix behavior with edit and clear > actions > >--- > .../prog/en/modules/admin/smart-rules.tt | 94 +++++++++++++++---- > 1 file changed, 74 insertions(+), 20 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index 1ecd8fbc1ec..45cac33744f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -918,7 +918,7 @@ > <form id="set-global-checkouts-limit" method="post" action="/cgi-bin/koha/admin/smart-rules.pl"> > [% INCLUDE 'csrf-token.inc' %] > <input type="hidden" name="op" value="cud-set-global-checkout-limits" /> >- <table> >+ <table id="global-checkout-limits-rules"> > <thead> > <tr> > <th class="fixed_sort">Patron category</th> >@@ -953,7 +953,7 @@ > [% END %] > </td> > <td class="actions restricted-access"> >- <a href="#" class="editrule btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> >+ <a href="#" class="editrule-global-checkout-limits btn btn-default btn-xs"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> > <a href="#" class="delete-global-checkout-limits btn btn-default btn-xs" data-itemtype="[% i || '*' | html %]" data-categorycode="[% c || '*' | html %]" data-branch="*"><i class="fa fa-trash-can"></i> Delete</a> > </td> > <td> >@@ -974,9 +974,9 @@ > [% END %] > [% END %] > [% END %] >- <tr class="noExport restricted-access" id="edit_row"> >+ <tr class="noExport restricted-access" id="global_checkout_limits_edit_row"> > <td> >- <select name="categorycode" id="categorycode"> >+ <select name="categorycode" id="global_checkout_limits_categorycode"> > <option value="*">All</option> > [% FOREACH patron_category IN patron_categories%] > <option value="[% patron_category.categorycode | html %]">[% patron_category.description | html %]</option> >@@ -984,7 +984,7 @@ > </select> > </td> > <td> >- <select name="itemtype" id="matrixitemtype" style="width:13em;"> >+ <select name="itemtype" id="global_checkout_limits_itemtype" style="width:13em;"> > <option value="*">All</option> > [% FOREACH itemtypeloo IN itemtypeloop %] > [% NEXT IF itemtypeloo.parent_type %] >@@ -1004,10 +1004,10 @@ > </td> > <td class="actions"> > <button type="submit" class="btn btn-primary btn-xs"><i class="fa fa-save"></i> Save</button> >- <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button> >+ <button name="cancel" class="clear_edit_global_checkouts_limit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button> > </td> >- <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td> >- <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td> >+ <td><input type="text" name="maxissueqty" id="global_checkout_limits_maxissueqty" size="3" /></td> >+ <td><input type="text" name="maxonsiteissueqty" id="global_checkout_limits_maxonsiteissueqty" size="3" /></td> > </tr> > </tbody> > </table> >@@ -1595,25 +1595,25 @@ > }); > }); > >- function clear_edit(){ >+ function clear_edit_form(editRowSelector, tableSelector) { > var cancel = confirm(_("Are you sure you want to cancel your changes?")); >- if ( !cancel ) return; >- $('#default-circulation-rules td').removeClass('highlighted-row'); >- var edit_row = $("#edit_row"); >- $(edit_row).find("input").each(function(){ >+ if (!cancel) return; >+ $(tableSelector + ' td').removeClass('highlighted-row'); >+ var edit_row = $(editRowSelector); >+ $(edit_row).find("input").each(function() { > var type = $(this).attr("type"); >- if (type != "button" && type != "submit" ) { >+ if (type !== "button" && type !== "submit") { > $(this).val(""); > $(this).prop('disabled', false); > } >- if ( type == "checkbox" ) { >+ if (type === "checkbox") { > $(this).prop('checked', false); > } > }); >- $(edit_row).find("select").prop('disabled', false); >- $(edit_row).find("select option:selected").removeAttr('selected'); >- $(edit_row).find("select option:first-child").attr("selected", "selected"); >- $(edit_row).find("td:last input[name='clear']").remove(); >+ edit_row.find("select").prop('disabled', false); >+ edit_row.find("select option:selected").prop('selected', false); >+ edit_row.find("select option:first-child").prop("selected", true); >+ edit_row.find("td:last input[name='clear']").remove(); > } > > var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); >@@ -1732,9 +1732,63 @@ > $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true); > return false; > }); >+ $(".editrule-global-checkout-limits").click(function(){ >+ if ( $("#global_checkout_limits_edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) { >+ var edit = confirm(_("Are you sure you want to edit another rule?")); >+ if (!edit) return false; >+ } >+ $('#global-checkout-limits-rules td').removeClass('highlighted-row'); >+ $(this).parent().parent().find("td").each(function (i) { >+ >+ $(this).addClass('highlighted-row'); >+ itm_code = $(this).data('code'); >+ itm_text = $(this).text(); >+ itm_text = itm_text.replace(/^\s*|\s*$/g,''); >+ var current_column = $("#global_checkout_limits_edit_row td:eq("+i+")"); >+ var current_input_id = $(current_column).children('input').first().attr('id'); >+ $(current_column).find("input[type='text']").val(itm_text); >+ // select the corresponding option >+ $(current_column).find("select option").each(function(){ >+ // Reset selection status for all options >+ $(this).prop('selected', false); >+ // Declare opt here to ensure it is scoped correctly within the loop >+ let opt = $(this).val(); >+ // Select the matching option >+ if (opt == itm_code) { >+ $(this).prop('selected', true); >+ } >+ }); >+ // After setting the correct option, update the select to reflect the change >+ $(current_column).find('select').trigger('change'); >+ if ( i == 0 || i == 1 ) { >+ // Disable the 2 first columns, we cannot update them. >+ var val = $(current_column).find("select option:selected").val(); >+ var name = "categorycode"; >+ if ( i == 1 ) { >+ name="itemtype"; >+ } >+ // Remove potential previous input added >+ $(current_column).find("input").remove(); >+ $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); >+ } else if ( current_input_id === "global_checkout_limits_maxissueqty" || current_input_id === "global_checkout_limits_maxonsiteissueqty" ) { >+ // If the value is not an integer for >+ // - "Global current checkouts allowed" >+ // - "Global current on-site checkouts allowed" >+ // The value will be "Not defined" >+ if( !((parseFloat(itm_text) == parseInt(itm_text)) && !isNaN(itm_text)) ) { >+ $(current_column).find("input[type='text']").val(""); >+ } >+ } >+ }); >+ return false; >+ }); > $(".clear_edit").on("click",function(e){ > e.preventDefault(); >- clear_edit(); >+ clear_edit_form("#edit_row", "#default-circulation-rules"); >+ }); >+ $(".clear_edit_global_checkouts_limit").on("click",function(e){ >+ e.preventDefault(); >+ clear_edit_form("#global_checkout_limits_edit_row", "#global-checkout-limits-rules"); > }); > > $("#set-article-requests-daily-limit").on("submit", function(){ >-- >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 8137
:
9705
|
9706
|
11079
|
64703
|
64704
|
64791
|
64891
|
72831
|
72832
|
107207
|
107208
|
107209
|
107459
|
111368
|
111369
|
111370
|
112640
|
113797
|
113882
|
114531
|
114532
|
114533
|
114534
|
116676
|
116677
|
116678
|
116679
|
116680
|
145476
|
145477
|
145478
|
145479
|
145480
|
152040
|
152041
|
152042
|
152043
|
152044
|
152045
|
156316
|
156317
|
156318
|
156319
|
156320
|
156321
|
156322
|
159712
|
162367
|
167208
|
167923
|
168119
|
169084
|
169696
|
169700
|
169727
|
169927
|
169928
|
170411
|
173605
|
173608
|
175837
|
175838
| 177464