Skip to content

Commit 7a25557

Browse files
committed
Bug 35329: Move patron search to modal - edit-batch
Test plan: Create new patron card batch Keep the textarea empty and click "Add patron(s)" to open the modal There is a special feature here, the "checkbox" column is displayed and you can select several patrons and click "Add selected patrons". Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
1 parent 07890e3 commit 7a25557

File tree

2 files changed

+50
-16
lines changed

2 files changed

+50
-16
lines changed

koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc

+38-7
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426
"searchable": false,
427427
"orderable": false,
428428
"render": function( data, type, row, meta ) {
429-
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' class='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />";
429+
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' class='check" + data + " selection' name='borrowernumber' value='" + data + "' />";
430430
}
431431
}
432432
[% CASE 'cardnumber' %]
@@ -657,6 +657,10 @@
657657

658658
patron_search_form.on('submit', filter);
659659
patron_search_form.on('submit', update_search_type);
660+
patron_search_form.on('submit', function(){
661+
parent_block.find(".searchheader").show();
662+
});
663+
660664

661665
$(".filterByLetter").on("click",function(e){
662666
e.preventDefault();
@@ -913,14 +917,12 @@
913917

914918
<div id="[% search_results_block_id | html %]"> <!-- FIXME removed style from #searchresults, is that bad? -->
915919
[% IF columns.grep('checkbox').size %]
916-
<div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;">
920+
<div class="searchheader fh-fixedHeader" style="display:none;">
917921
<div>
918-
<a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
922+
<a href="#" class="btn btn-link select_all"><i class="fa fa-check"></i> Select all</a>
919923
|
920-
<a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
921-
[% IF selection_type == 'add' %]
922-
<button id="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button>
923-
[% END %]
924+
<a href="#" class="btn btn-link clear_all"><i class="fa fa-remove"></i> Clear all</a>
925+
<button class="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button>
924926
</div>
925927
</div>
926928
[% END %]
@@ -934,4 +936,33 @@
934936
</div>
935937
</div>
936938
<div id="patron_preview_modal" class="basicModal"></div>
939+
940+
<script>
941+
$(document).ready(function() {
942+
let parent_block = $("#[% search_results_block_id | html %]");
943+
parent_block.find(".select_all").on("click",function(e){
944+
e.preventDefault();
945+
parent_block.find(".selection").prop("checked", true).change();
946+
});
947+
parent_block.find(".clear_all").on("click",function(e){
948+
e.preventDefault();
949+
parent_block.find(".selection").prop("checked", false).change();
950+
});
951+
parent_block.find(".searchheader").hide();
952+
parent_block.find(".clear_search").on("click",function(e){$("#searchheader").hide();});
953+
954+
parent_block.find('.add-selected').on('click', function(e) {
955+
e.preventDefault();
956+
var counter = 0;
957+
parent_block.find('tr:has(.selection:checked) .add_user').each(function(){
958+
var borrowernumber = $(this).data('borrowernumber');
959+
var firstname = $(this).data('firstname');
960+
var surname = $(this).data('surname');
961+
add_user( borrowernumber, firstname + ' ' + surname );
962+
counter++;
963+
});
964+
parent_block.find('.info').html(_("%s Patrons added.").format(counter)).show();
965+
});
966+
});
967+
</script>
937968
[% END %]

koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt

+12-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[% USE Asset %]
33
[% PROCESS 'i18n.inc' %]
44
[% SET footerjs = 1 %]
5+
[% PROCESS 'patron-search.inc' %]
56
[% INCLUDE 'doc-head-open.inc' %]
67
<title>[% FILTER collapse %]
78
[% IF ( batch_id ) %]
@@ -85,7 +86,7 @@
8586
</div>
8687
</form>
8788
<div id="batch-manage" class="action">
88-
<a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>
89+
<a class="btn btn-default" id="additems" href="#patron_search_modal" data-toggle="modal"><i class="fa fa-plus"></i> Add patron(s)</a>
8990
[% IF ( table_loop ) %]
9091
<a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
9192
<a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash-can"></i> Remove selected patrons</a>
@@ -222,13 +223,11 @@
222223
function Add() {
223224
var bor_nums = document.getElementById("bor_num_list");
224225
if (bor_nums.value == '') {
225-
window.open("/cgi-bin/koha/members/search.pl?columns=checkbox,cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
226-
'PatronPopup',
227-
'width=1024,height=768,location=yes,toolbar=no,'
228-
+ 'scrollbars=yes,resize=yes');
229-
} else {
230-
document.forms["add_by_bor_num"].submit();
226+
return true;
231227
}
228+
229+
document.forms["add_by_bor_num"].submit();
230+
return false
232231
};
233232

234233
function add_user(borrowernumber) {
@@ -316,8 +315,7 @@
316315
"autoWidth": false
317316
}));
318317
$("#additems").click(function(){
319-
Add();
320-
return false;
318+
return Add();
321319
});
322320
$("#removeitems").click(function(){
323321
Remove();
@@ -385,6 +383,11 @@
385383
});
386384
});
387385
</script>
386+
387+
[% INCLUDE 'select2.inc' %]
388+
[% SET columns = ['checkbox','cardnumber','name','category','branch','dateexpiry','borrowernotes','action'] %]
389+
[% PROCESS patron_search_modal columns => columns, modal_title => t("Add patrons") %]
390+
[% PROCESS patron_search_js columns => columns, actions => ["add"], preview_on_name_click => 1 %]
388391
[% END %]
389392

390393
[% INCLUDE 'intranet-bottom.inc' %]

0 commit comments

Comments
 (0)