Bugzilla – Attachment 150112 Details for
Bug 33560
Batch edit link broken if subscriptions are selected using "select all" link
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33560: Batch edit link broken if subscriptions are selected using "select all" link
Bug-33560-Batch-edit-link-broken-if-subscriptions-.patch (text/plain), 6.95 KB, created by
David Nind
on 2023-04-23 06:05:05 UTC
(
hide
)
Description:
Bug 33560: Batch edit link broken if subscriptions are selected using "select all" link
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-04-23 06:05:05 UTC
Size:
6.95 KB
patch
obsolete
>From 45f2e2e55673cb7c1b132676c0e3abbc51db9046 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 18 Apr 2023 16:51:04 +0000 >Subject: [PATCH] Bug 33560: Batch edit link broken if subscriptions are > selected using "select all" link > >This patch revises the process by which the serials search results page >redirects to the batch edit page based on which checkboxes are checked. > >To test, apply the patch and go to serials. You should have some >subscriptions which are open and some which are closed. > >- Perform a search which will return at least one result under each tab > (Open and Closed). > - Checking one or more checkboxes should activate the "Edit selected > serials" link, which should work correctly to redirect you to the > batch edit page. > - Unchecking all the checkboxes should make the edit link disappear. > - Check that the "Select all" and "Clear all" links work the same way > manually checking checkboxes does. > - Confirm that controls under each tab work correctly just for the > results under that tab. > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/modules/serials/serials-search.tt | 73 ++++++++++--------- > 1 file changed, 40 insertions(+), 33 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >index 8e008c5328..8b3c76c47b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt >@@ -65,16 +65,16 @@ > <a class="select-all" href="#" data-tab="[% tab | html %]"><i class="fa fa-check"></i> Select all</a> > | > <a class="clear-all" href="#" data-tab="[% tab | html %]"><i class="fa fa-remove"></i> Clear all</a> >- <span class="itemselection_actions"> >+ <span class="itemselection_actions [% tab | html %]"> > | Actions: >- <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Edit selected serials</a> >+ <a href="#" data-tab="[% tab | html %]" class="itemselection_action_modify"><i class="fa fa-pencil"></i> Edit selected serials</a> > </span> > </div> > [% END %] > <table> > <thead> > <tr> >- <th></th> >+ <th class="NoSort noExport"></th> > <th>ISSN</th> > <th class="anti-the">Title</th> > <th>Notes</th> >@@ -96,7 +96,7 @@ > <tr> > <td> > [% UNLESS subscription.cannotedit %] >- <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" /> >+ <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" class="[% tab | html %]" /> > [% ELSE %] > <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" disabled="disabled" title="You cannot edit this subscription" /> > [% END %] >@@ -322,30 +322,30 @@ > [% Asset.js("js/serials-toolbar.js") | $raw %] > <script> > >- function itemSelectionBuildEditLink(div) { >- var subscription_ids = new Array(); >- $("input[name='subscriptionid'][type='checkbox']:checked", div).each(function() { >- subscription_ids.push($(this).val()); >- }); >- if (subscription_ids.length > 0) { >- var url = "[% edit_action_link | html %]"; >- url += '&subscriptionid=' + subscription_ids.join('&subscriptionid='); >- $('a.itemselection_action_modify').attr('href', url); >- } else { >- return false; >- } >- return true; >- } >+ function itemSelectionBuildEditLink( tab ) { >+ var subscription_ids = new Array(); >+ $( "input:checkbox." + tab + ":checked" ).each(function() { >+ subscription_ids.push( $(this).val() ); >+ }); > >- function itemSelectionBuildActionLinks(tab) { >- var div = $("#" + tab); >- var modify_link_ok = itemSelectionBuildEditLink(div); >- if (modify_link_ok) { >- $('.itemselection_actions', div).show(); >- } else { >- $('.itemselection_actions', div).hide(); >- } >+ if (subscription_ids.length > 0) { >+ var url = "[% edit_action_link | html %]"; >+ url += '&subscriptionid=' + subscription_ids.join('&subscriptionid='); >+ location.href = url; >+ } else { >+ return false; > } >+ } >+ >+ function enableCheckboxActions( tab ){ >+ // Enable/disable controls if checkboxes are checked >+ var checked_count = $("input:checkbox." + tab + ":checked").length; >+ if( checked_count > 0 ){ >+ $(".itemselection_actions." + tab ).show(); >+ } else { >+ $(".itemselection_actions." + tab ).hide(); >+ } >+ } > > $(document).ready(function() { > var osrlt = $("#opened_panel table").dataTable($.extend(true, {}, dataTablesDefaults, { >@@ -385,17 +385,24 @@ > > $('.select-all, .clear-all').on('click', function(e) { > e.preventDefault(); >- var checkboxes = $(this).parents('form').find('input[type="checkbox"]'); >- checkboxes.prop('checked', $(this).hasClass('select-all')); > var tab = $(this).data("tab"); >- itemSelectionBuildActionLinks(tab); >+ var checkboxes = $("input:checkbox." + tab ); >+ checkboxes.prop('checked', $(this).hasClass('select-all')).change(); >+ enableCheckboxActions(tab); > }); > >- itemSelectionBuildActionLinks("opened"); >- itemSelectionBuildActionLinks("closed"); >+ enableCheckboxActions("opened"); >+ enableCheckboxActions("closed"); >+ > $("input[name='subscriptionid'][type='checkbox']").change(function() { >- var div = $(this).parents('form').parent().attr("id"); >- itemSelectionBuildActionLinks(div); >+ var tab = $(this).attr("class"); >+ enableCheckboxActions( tab ); >+ }); >+ >+ $(".itemselection_action_modify").on("click", function(e){ >+ e.preventDefault(); >+ var tab = $(this).data("tab"); >+ itemSelectionBuildEditLink( tab ); > }); > > [% IF ( mana ) %] >-- >2.30.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 33560
:
149895
|
150112
|
150117