@@ -, +, @@ patrons to lists - In the staff interface, perform a patron search that will return multiple results. - In the toolbar at the top of the search results you should see two disabled Bootstrap-styled buttons: "Add to patron list" and "Merge selected patrons." - The "Select all" and "Clear all" links should work to enable and disable the toolbar buttons. - "Clear all" and then check the checkbox next to one of the results. The "Add to patron list" button should be enabled. - Check a second checkbox. The "Merge selected patrons" button should be enabled. - Test the "Add to patron list" button. It should trigger a dropdown menu listing existing patrons lists and a "New list" link. - Test adding to an exising patron list. It should trigger a message at the top of the page which shows a link to that list. - Test adding to a new list. It should trigger a Bootstrap modal where you can enter the name of the new list. - Submitting the list title form should close the modal and trigger the display of the message showing how many patrons were added to your new list. The link to the new list should be correct. - Test the "Merge selected patrons" button. It should send the selected patrons to the patron merge screen. --- .../prog/css/src/staff-global.scss | 32 +-- .../prog/en/modules/members/member.tt | 223 ++++++++++-------- .../modules/members/tables/members_results.tt | 2 +- 3 files changed, 140 insertions(+), 117 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2071,22 +2071,24 @@ li { } #searchresults { - ul { - li { - clear: left; - font-size: 90%; - list-style: url("../img/item-bullet.svg"); - padding: .2em 0; - - &.result_itype_image { - list-style: none; - list-style-type: none; - } + td { + ul { + li { + clear: left; + font-size: 90%; + list-style: url("../img/item-bullet.svg"); + padding: .2em 0; + + &.result_itype_image { + list-style: none; + list-style-type: none; + } - img { - float: left; - margin: 3px 5px 3px -5px; - max-width: 25px; + img { + float: left; + margin: 3px 5px 3px -5px; + max-width: 25px; + } } } } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt @@ -45,7 +45,7 @@
[% IF CAN_user_tools_manage_patron_lists %] -
+
Added patrons to .
[% END %] @@ -72,38 +72,32 @@ [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
- Select all + Select all | - Clear all + Clear all [% IF CAN_user_tools_manage_patron_lists %] - | - - - - - - - - + [% END %] - [% IF CAN_user_tools_manage_patron_lists && CAN_user_borrowers_edit_borrowers %] - | + [% IF CAN_user_tools_manage_patron_lists %] +
+ + +
[% END %] [% IF CAN_user_borrowers_edit_borrowers %] - + [% END %]
@@ -210,6 +204,32 @@
+ + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -229,101 +249,70 @@ $('#merge-patrons').prop('disabled', true); $('#memberresultst').on('change', 'input.selection', function() { if ( $('.selection:checked').length > 1 ) { - $('#merge-patrons').prop('disabled', false); + /* More than one checkbox has been checked */ + $('#merge-patrons').prop('disabled', false).removeClass("disabled"); + $("#patronlist-menu").removeClass("disabled").prop("disabled", false); + } else if ( $('.selection:checked').length == 1 ) { + /* At least one checkbox has been checked */ + $('#merge-patrons').prop('disabled', true).addClass("disabled"); + $("#patronlist-menu").removeClass("disabled").prop("disabled", false); } else { - $('#merge-patrons').prop('disabled', true); + /* No checkbox has been checked */ + $('#merge-patrons').prop('disabled', true).addClass("disabled"); + $("#patronlist-menu").addClass("disabled").prop("disabled", true); } }); + $('#merge-patrons').on('click', function() { var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked') .map(function() { return "id=" + $(this).val() }).get().join('&'); - window.location.href = merge_patrons_url; }); - $('#add_to_patron_list_submit').prop('disabled', true); - $('#new_patron_list').hide(); - - $('#add_to_patron_list').change(function() { - var value = $('#add_to_patron_list').val(); - if ( value == 'new' ) { - $('#new_patron_list').val('') - $('#new_patron_list').show(); - $('#new_patron_list').focus(); - } else if ( value ) { - $('#new_patron_list').hide(); - $('#add_to_patron_list_submit').prop('disabled', false); - } else { - $('#new_patron_list').hide(); - $('#add_to_patron_list_submit').prop('disabled', true); + $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){ + e.preventDefault(); + + if ( $("#memberresultst input:checkbox:checked").length == 0 ) { + alert( _("You have not selected any patrons to add to a list!") ); + $(".btn-group").removeClass("open"); /* Close button menu */ + return false; } - }); - $('#new_patron_list').on('input', function() { - if ( $('#new_patron_list').val() ) { - $('#add_to_patron_list_submit').prop('disabled', false); + var listid = $(this).data("listid"); + $("#add_to_patron_list").val( listid ); + if( listid == "new" ){ + /* #add_to_patron_list value "new" in the modal form will tell API to create a new list */ + $("#new-patron-list").modal("show"); } else { - $('#add_to_patron_list_submit').prop('disabled', true); - } - }); + /* Ajax submit the patrons to list */ - $("#add_to_patron_list_submit").on('click', function(e){ - if ( $('#add_to_patron_list').val() == 'new' ) { - if ( $('#new_patron_list').val() ) { - $("#add_to_patron_list option").each(function() { - if ( $(this).text() == $('#new_patron_list').val() ) { - alert( _("You already have a list with that name!") ); - return false; - } - }); - } else { - alert( _("You must give your new patron list a name!") ); - return false; - } + patronListAdd(); } + }) - if ( $("#memberresultst input:checkbox:checked").length == 0 ) { - alert( _("You have not selected any patrons to add to a list!") ); + /* Submit selected patrons to a list via AJAX */ + $("#new-patron-list_form").on('submit', function(e){ + e.preventDefault(); + /* Upon submitting modal patron list add form... */ + if ( $('#new_patron_list').val() ) { + $(".patron-list-add").each(function() { + /* Check each list name in the menu of patron lists */ + /* If submitted list name matches... */ + if ( $(this).text() == $('#new_patron_list').val() ) { + alert( _("You already have a list with that name!") ); + return false; + } + }); + } else { + alert( _("You must give your new patron list a name!") ); return false; } - - var borrowernumbers = []; - $("#memberresultst").find("input:checkbox:checked").each(function(){ - borrowernumbers.push($(this).val()); - }); - var data = { - add_to_patron_list: $("#add_to_patron_list").val(), - new_patron_list: $("#new_patron_list").val(), - borrowernumbers: borrowernumbers - }; - $.ajax({ - data: data, - type: 'POST', - url: '/cgi-bin/koha/svc/members/add_to_list', - success: function(data) { - $("#patron_list_dialog").show(); - $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list); - $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id); - $("#patron_list_dialog > a").html(data.patron_list.name); - if ( $('#add_to_patron_list').val() == 'new' ) { - var new_patron_list_added = $("