Bug 32581: Add confirmation modal

This patch makes changing the expiration date optional, by providing a modal when switching a patron category. Confirming the modal will change the expiration date to the default and cancelling will keep the same expiration date.

To test:
1) Same plan as before except now there is a modal when changing the patron category.
- Attempt confirming the modal: expiration date should change to default.
- Attempt canceling the modal: expiration date should stay the same

Signed-off-by: Jan Kissig <jkissig@th-wildau.de>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Sam Lau 2024-07-11 16:03:26 +00:00 committed by Lucas Gass
parent 12f8488b13
commit 8e165a80c1
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 31 additions and 7 deletions

View File

@ -1661,6 +1661,25 @@
</div>
<!-- /.main.container-fluid -->
<!-- Expiration date modal-->
<div id="expirationDateModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="expirationDateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="expirationDateModalLabel">Confirm expiration date</h4>
</div>
<div class="modal-body">
<p>Change expiration date to default for this category?</p>
</div>
<div class="modal-footer">
<button id="expirationDateConfirmBtn" class="btn btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Yes</button>
<button id="expirationDateCancelBtn"data-dismiss="modal" class="btn btn-secondary"><i class="fa fa-times" aria-hidden="true"></i> No</button>
</div>
</div>
</div>
</div>
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% INCLUDE 'str/members-menu.inc' %]

View File

@ -91,13 +91,18 @@ function update_category_code(category_code) {
// Change patron's expiration date
$('#categorycode_entry').change(function() {
var fp = $("#to").flatpickr();
var expiryDate = $('select'+category_selector+' option:selected').data('expiryDate');
// Check if expiryDate is available and format it to YYYY-MM-DD
if (expiryDate) {
var formattedDate = expiryDate.split('T')[0];
fp.setDate(formattedDate);
}
$('#expirationDateModal').modal('show');
// Handle confirmation Yes button click
$('#expirationDateConfirmBtn').on('click', function() {
var fp = $("#to").flatpickr();
var expiryDate = $('select'+category_selector+' option:selected').data('expiryDate');
// Check if expiryDate is available and format it to YYYY-MM-DD
if (expiryDate) {
var formattedDate = expiryDate.split('T')[0];
fp.setDate(formattedDate);
}
$('#expirationDateModal').modal('hide');
});
});
}