Bug 33786: ILL requests table id
Make sure requests table is unique when visiting patron ILL history so the table state is not shared unintentionally Reproduce: 1) Have a borrower with >20 ILL requests in their history 2) Visit cgi-bin/koha/members/ill-requests.pl?borrowernumber=<borrowernumber> 3) On the table, click page 2 4) Visit a different borrower with <20 ILL requests 5) Verify that no requests are shown, this is because the table is using page 2 from step 3) 6) Go back to original borrower, click table page 1 7) Now go back to 2nd borrower, verify is now showing page 1 correctly Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
9eb62ef191
commit
eac2787565
2 changed files with 21 additions and 16 deletions
|
@ -1,4 +1,8 @@
|
|||
[% IF patron.borrowernumber %]
|
||||
<table id="ill-requests-patron-[% patron.borrowernumber | html %]">
|
||||
[% ELSE %]
|
||||
<table id="ill-requests">
|
||||
[% END %]
|
||||
<thead>
|
||||
<tr id="ill_requests_header">
|
||||
<th scope="col">Request ID</th>
|
||||
|
|
|
@ -53,19 +53,17 @@ $(document).ready(function() {
|
|||
|
||||
// At the moment, the only prefilter possible is borrowernumber
|
||||
// see ill/ill-requests.pl and members/ill-requests.pl
|
||||
let additional_prefilters = [];
|
||||
let additional_prefilters = {};
|
||||
if(prefilters){
|
||||
let prefilters_array = prefilters.split("&");
|
||||
prefilters_array.forEach((prefilter) => {
|
||||
let prefilter_split = prefilter.split("=");
|
||||
additional_prefilters.push( {
|
||||
"key": prefilter_split[0],
|
||||
"value": prefilter_split[1]
|
||||
} );
|
||||
|
||||
});
|
||||
let prefilters_array = prefilters.split("&");
|
||||
prefilters_array.forEach((prefilter) => {
|
||||
let prefilter_split = prefilter.split("=");
|
||||
additional_prefilters[prefilter_split[0]] = prefilter_split[1]
|
||||
});
|
||||
}
|
||||
|
||||
let borrower_prefilter = additional_prefilters['borrowernumber'] || null;
|
||||
|
||||
let additional_filters = {
|
||||
"me.backend": function(){
|
||||
let backend = $("#illfilter_backend").val();
|
||||
|
@ -78,9 +76,7 @@ $(document).ready(function() {
|
|||
return { "=": branchcode }
|
||||
},
|
||||
"me.borrowernumber": function(){
|
||||
let borrowernumber_pre_filter = additional_prefilters.find(e => e.key === 'borrowernumber');
|
||||
if ( additional_prefilters.length == 0 || typeof borrowernumber_pre_filter === undefined) return "";
|
||||
return { "=": borrowernumber_pre_filter["value"] }
|
||||
return borrower_prefilter ? { "=": borrower_prefilter } : "";
|
||||
},
|
||||
"-or": function(){
|
||||
let patron = $("#illfilter_patron").val();
|
||||
|
@ -123,7 +119,7 @@ $(document).ready(function() {
|
|||
return filters;
|
||||
},
|
||||
"me.placed": function(){
|
||||
if ( additional_prefilters.length != 0 && !additional_prefilters.find(e => e.key === 'placed')) return "";
|
||||
if ( Object.keys(additional_prefilters).length ) return "";
|
||||
let placed_start = $('#illfilter_dateplaced_start').get(0)._flatpickr.selectedDates[0];
|
||||
let placed_end = $('#illfilter_dateplaced_end').get(0)._flatpickr.selectedDates[0];
|
||||
if (!placed_start && !placed_end) return "";
|
||||
|
@ -133,7 +129,7 @@ $(document).ready(function() {
|
|||
}
|
||||
},
|
||||
"me.updated": function(){
|
||||
if ( additional_prefilters.length != 0 && !additional_prefilters.find(e => e.key === 'updated')) return "";
|
||||
if (Object.keys(additional_prefilters).length) return "";
|
||||
let updated_start = $('#illfilter_datemodified_start').get(0)._flatpickr.selectedDates[0];
|
||||
let updated_end = $('#illfilter_datemodified_end').get(0)._flatpickr.selectedDates[0];
|
||||
if (!updated_start && !updated_end) return "";
|
||||
|
@ -178,7 +174,12 @@ $(document).ready(function() {
|
|||
}
|
||||
};
|
||||
|
||||
var ill_requests_table = $("#ill-requests").kohaTable({
|
||||
let table_id = "#ill-requests";
|
||||
if (borrower_prefilter) {
|
||||
table_id += "-patron-" + borrower_prefilter;
|
||||
}
|
||||
|
||||
var ill_requests_table = $(table_id).kohaTable({
|
||||
"ajax": {
|
||||
"url": '/api/v1/ill/requests'
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue