Skip to content

Commit bbf9f8e

Browse files
mmorgannoblecmorgannoble
authored andcommitted
lp2080899 Prevent payment when no charges selected
Adds code to disable the Submit Payment button if no checkboxes are selected. Release-note: Disables the Pay Selected Charges button when none are selected. Co-authored-by: Christine Morgan <[email protected]> Signed-off-by: Michele Morgan <[email protected]> Signed-off-by: Llewellyn Marshall <[email protected]> Signed-off-by: Jane Sandberg <[email protected]>
1 parent 78c87a4 commit bbf9f8e

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Open-ILS/src/templates/opac/myopac/main.tt2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<th nowrap="nowrap" style="white-space:nowrap;">
4848
<input id="pay_fines_box1" checked="checked"
4949
type="checkbox" onclick="select_all_checkboxes('xact', this.checked)"
50+
onchange=canSubmitPayment(event)
5051
title="[% l('Click to (un)select all charges') %]" />
5152
</th>
5253
[% END %]
@@ -73,7 +74,7 @@
7374
<tr id='myopac_circ_trans_row'>
7475
[% IF myopac_cc_allowed %]
7576
<td>
76-
<input type="checkbox" checked="checked"
77+
<input type="checkbox" checked="checked" onchange=canSubmitPayment(event)
7778
title="[% l('Pay this fine') %]" name="xact"
7879
value="[% f.xact.id %]" />
7980
</td>
@@ -159,6 +160,7 @@
159160
<th nowrap="nowrap" style="white-space:nowrap;">
160161
<input id="pay_fines_box2" checked="checked"
161162
type="checkbox" onclick="select_all_checkboxes('xact_misc', this.checked)"
163+
onchange=canSubmitPayment(event)
162164
title="[% l('Click to (un)select all fines') %]" />
163165
</th>
164166
[% END %]
@@ -177,7 +179,7 @@
177179
[% IF myopac_cc_allowed %]
178180
<td >
179181
<input type="checkbox" title='[% l("Pay this fine") %]'
180-
name="xact_misc" value="[% f.xact.id %]"
182+
name="xact_misc" value="[% f.xact.id %]" onchange=canSubmitPayment(event)
181183
checked="checked" />
182184
</td>
183185
[% END %]

Open-ILS/web/js/ui/default/opac/simple.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,22 @@ function displayAlert(elementID) {
361361
el.classList.remove('d-none');
362362
// fade out after 8 seconds
363363
setTimeout(() => {document.getElementById(elementID).classList.add('d-none')}, 8000);
364-
}
364+
}
365+
366+
function canSubmitPayment(evt){
367+
// check that charges are selected in opac for payment
368+
// enable the submit payment button if they are
369+
var form = document.getElementById('selected_fines');
370+
var submit = form.querySelector('input[type="submit"]');
371+
if (!form || !submit) return;
372+
var els = form.elements;
373+
for (i = 0; i < els.length; i++){
374+
var e = els[i];
375+
if (e.type == "checkbox" && !e.hidden && e.checked){
376+
submit.removeAttribute("disabled");
377+
return;
378+
}
379+
}
380+
381+
submit.setAttribute("disabled","");
382+
}

0 commit comments

Comments
 (0)