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>
This commit is contained in:
parent
07890e3163
commit
7a25557bfe
|
|
@ -426,7 +426,7 @@
|
|||
"searchable": false,
|
||||
"orderable": false,
|
||||
"render": function( data, type, row, meta ) {
|
||||
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' class='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />";
|
||||
return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' class='check" + data + " selection' name='borrowernumber' value='" + data + "' />";
|
||||
}
|
||||
}
|
||||
[% CASE 'cardnumber' %]
|
||||
|
|
@ -657,6 +657,10 @@
|
|||
|
||||
patron_search_form.on('submit', filter);
|
||||
patron_search_form.on('submit', update_search_type);
|
||||
patron_search_form.on('submit', function(){
|
||||
parent_block.find(".searchheader").show();
|
||||
});
|
||||
|
||||
|
||||
$(".filterByLetter").on("click",function(e){
|
||||
e.preventDefault();
|
||||
|
|
@ -913,14 +917,12 @@
|
|||
|
||||
<div id="[% search_results_block_id | html %]"> <!-- FIXME removed style from #searchresults, is that bad? -->
|
||||
[% IF columns.grep('checkbox').size %]
|
||||
<div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;">
|
||||
<div class="searchheader fh-fixedHeader" style="display:none;">
|
||||
<div>
|
||||
<a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
|
||||
<a href="#" class="btn btn-link select_all"><i class="fa fa-check"></i> Select all</a>
|
||||
|
|
||||
<a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
|
||||
[% IF selection_type == 'add' %]
|
||||
<button id="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button>
|
||||
[% END %]
|
||||
<a href="#" class="btn btn-link clear_all"><i class="fa fa-remove"></i> Clear all</a>
|
||||
<button class="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button>
|
||||
</div>
|
||||
</div>
|
||||
[% END %]
|
||||
|
|
@ -934,4 +936,33 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="patron_preview_modal" class="basicModal"></div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let parent_block = $("#[% search_results_block_id | html %]");
|
||||
parent_block.find(".select_all").on("click",function(e){
|
||||
e.preventDefault();
|
||||
parent_block.find(".selection").prop("checked", true).change();
|
||||
});
|
||||
parent_block.find(".clear_all").on("click",function(e){
|
||||
e.preventDefault();
|
||||
parent_block.find(".selection").prop("checked", false).change();
|
||||
});
|
||||
parent_block.find(".searchheader").hide();
|
||||
parent_block.find(".clear_search").on("click",function(e){$("#searchheader").hide();});
|
||||
|
||||
parent_block.find('.add-selected').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var counter = 0;
|
||||
parent_block.find('tr:has(.selection:checked) .add_user').each(function(){
|
||||
var borrowernumber = $(this).data('borrowernumber');
|
||||
var firstname = $(this).data('firstname');
|
||||
var surname = $(this).data('surname');
|
||||
add_user( borrowernumber, firstname + ' ' + surname );
|
||||
counter++;
|
||||
});
|
||||
parent_block.find('.info').html(_("%s Patrons added.").format(counter)).show();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
[% USE Asset %]
|
||||
[% PROCESS 'i18n.inc' %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% PROCESS 'patron-search.inc' %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>[% FILTER collapse %]
|
||||
[% IF ( batch_id ) %]
|
||||
|
|
@ -85,7 +86,7 @@
|
|||
</div>
|
||||
</form>
|
||||
<div id="batch-manage" class="action">
|
||||
<a class="btn btn-default" id="additems" href="#"><i class="fa fa-plus"></i> Add patron(s)</a>
|
||||
<a class="btn btn-default" id="additems" href="#patron_search_modal" data-toggle="modal"><i class="fa fa-plus"></i> Add patron(s)</a>
|
||||
[% IF ( table_loop ) %]
|
||||
<a class="btn btn-default" id="savedesc" href="#" data-batch_id="[% batch_id | html %]"><i class="fa fa-save"></i> Save description</a>
|
||||
<a class="btn btn-default" id="removeitems" href="#"><i class="fa fa-trash-can"></i> Remove selected patrons</a>
|
||||
|
|
@ -222,13 +223,11 @@
|
|||
function Add() {
|
||||
var bor_nums = document.getElementById("bor_num_list");
|
||||
if (bor_nums.value == '') {
|
||||
window.open("/cgi-bin/koha/members/search.pl?columns=checkbox,cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
|
||||
'PatronPopup',
|
||||
'width=1024,height=768,location=yes,toolbar=no,'
|
||||
+ 'scrollbars=yes,resize=yes');
|
||||
} else {
|
||||
document.forms["add_by_bor_num"].submit();
|
||||
return true;
|
||||
}
|
||||
|
||||
document.forms["add_by_bor_num"].submit();
|
||||
return false
|
||||
};
|
||||
|
||||
function add_user(borrowernumber) {
|
||||
|
|
@ -316,8 +315,7 @@
|
|||
"autoWidth": false
|
||||
}));
|
||||
$("#additems").click(function(){
|
||||
Add();
|
||||
return false;
|
||||
return Add();
|
||||
});
|
||||
$("#removeitems").click(function(){
|
||||
Remove();
|
||||
|
|
@ -385,6 +383,11 @@
|
|||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
[% INCLUDE 'select2.inc' %]
|
||||
[% SET columns = ['checkbox','cardnumber','name','category','branch','dateexpiry','borrowernotes','action'] %]
|
||||
[% PROCESS patron_search_modal columns => columns, modal_title => t("Add patrons") %]
|
||||
[% PROCESS patron_search_js columns => columns, actions => ["add"], preview_on_name_click => 1 %]
|
||||
[% END %]
|
||||
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue