Bugzilla – Attachment 189292 Details for
Bug 38924
Introduce an organization level loan 'Quota' system for Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38924: (follow-up) Minor QOL quota modal fixes
Bug-38924-follow-up-Minor-QOL-quota-modal-fixes.patch (text/plain), 4.67 KB, created by
Jacob O'Mara
on 2025-11-07 12:13:59 UTC
(
hide
)
Description:
Bug 38924: (follow-up) Minor QOL quota modal fixes
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2025-11-07 12:13:59 UTC
Size:
4.67 KB
patch
obsolete
>From 090e518082696f6857e2edb7fec5f24b3b91edda Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <Jacob.omara@openfifth.co.uk> >Date: Fri, 7 Nov 2025 11:50:36 +0000 >Subject: [PATCH] Bug 38924: (follow-up) Minor QOL quota modal fixes > >This patch: > - Makes sure that the quotas modal displays the error message for why >the submit failed, instead of a generic message > - Clears the modal data on modal close to remove persistent data > - Get dates directly from flatpickr selectedDates for API requests to >ensure sync. >--- > .../intranet-tmpl/prog/js/modals/quota.js | 60 +++++++++++++++++-- > 1 file changed, 56 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/quota.js b/koha-tmpl/intranet-tmpl/prog/js/modals/quota.js >index b6a795217d4..a83acc6d3f1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/quota.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/quota.js >@@ -2,6 +2,9 @@ > document > .getElementById("quotaModal") > ?.addEventListener("show.bs.modal", handleShowQuotaModal); >+ document >+ .getElementById("quotaModal") >+ ?.addEventListener("hidden.bs.modal", handleHideQuotaModal); > document > .getElementById("quotaForm") > ?.addEventListener("submit", handleQuotaSubmit); >@@ -27,10 +30,19 @@ > const quotaId = formData.get("quota_id"); > const patronId = formData.get("patron_id"); > const description = formData.get("description"); >- const startDate = formData.get("start_date"); >- const endDate = formData.get("end_date"); > const allocation = formData.get("allocation"); > >+ const quotaStartPicker = >+ document.getElementById("quota_from")._flatpickr; >+ const quotaEndPicker = document.getElementById("quota_to")._flatpickr; >+ >+ const startDate = quotaStartPicker.selectedDates[0] >+ ? flatpickr.formatDate(quotaStartPicker.selectedDates[0], "Y-m-d") >+ : null; >+ const endDate = quotaEndPicker.selectedDates[0] >+ ? flatpickr.formatDate(quotaEndPicker.selectedDates[0], "Y-m-d") >+ : null; >+ > const quotaUrl = quotaId > ? `/api/v1/patrons/${patronId}/quotas/${quotaId}` > : `/api/v1/patrons/${patronId}/quotas`; >@@ -50,10 +62,21 @@ > }) > ); > if (error || !response.ok) { >+ let errorMessage = __("Failure"); >+ >+ try { >+ const errorData = await response.json(); >+ if (errorData.error) { >+ errorMessage = errorData.error; >+ } >+ } catch (e) { >+ // If parsing fails, use default message >+ } >+ > const alertContainer = document.getElementById("quota_result"); > alertContainer.outerHTML = ` > <div id="quota_result" class="alert alert-danger"> >- ${__("Failure")} >+ ${errorMessage} > </div> > `; > >@@ -73,6 +96,12 @@ > return; > } > >+ const alertContainer = document.getElementById("quota_result"); >+ if (alertContainer) { >+ alertContainer.className = ""; >+ alertContainer.innerHTML = ""; >+ } >+ > const quotaModalLabel = document.getElementById("quotaLabel"); > const quotaModalSubmit = document.getElementById("quotaFormSubmit"); > >@@ -115,6 +144,18 @@ > return; > } > >+ function handleHideQuotaModal() { >+ document.getElementById("quota_description").value = ""; >+ document.getElementById("quota_from")._flatpickr.clear(); >+ document.getElementById("quota_to")._flatpickr.clear(); >+ document.getElementById("quota_allocation").value = ""; >+ document.getElementById("quota_id").value = ""; >+ const alertContainer = document.getElementById("quota_result"); >+ if (alertContainer) { >+ alertContainer.innerHTML = ""; >+ } >+ } >+ > async function handleDeleteSubmit(e) { > e.preventDefault(); > >@@ -137,10 +178,21 @@ > }) > ); > if (error || !response.ok) { >+ let errorMessage = __("Failure"); >+ >+ try { >+ const errorData = await response.json(); >+ if (errorData.error) { >+ errorMessage = errorData.error; >+ } >+ } catch (e) { >+ // If parsing fails, use default message >+ } >+ > const alertContainer = document.getElementById("quota_result"); > alertContainer.outerHTML = ` > <div id="quota_result" class="alert alert-danger"> >- ${__("Failure")} >+ ${errorMessage} > </div> > `; > >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38924
:
178582
|
178583
|
178584
|
178585
|
178586
|
178587
|
178588
|
178589
|
178590
|
178591
|
178592
|
178593
|
178594
|
178595
|
178596
|
178597
|
178598
|
178599
|
178600
|
178601
|
178602
|
178603
|
178604
|
178605
|
178606
|
178607
|
178608
|
185631
|
185632
|
185633
|
185634
|
185635
|
185636
|
185637
|
185638
|
185639
|
185640
|
185641
|
185642
|
185643
|
185644
|
185645
|
185646
|
185647
|
185648
|
185649
|
185650
|
185651
|
185652
|
185653
|
185654
|
185655
|
185656
|
185657
|
185675
|
185676
|
185677
|
185678
|
185679
|
185680
|
185681
|
185682
|
185683
|
185684
|
185685
|
185686
|
185687
|
185688
|
185689
|
185690
|
185691
|
185692
|
185693
|
185694
|
185695
|
185696
|
185697
|
185698
|
185699
|
185700
|
185701
|
185702
|
189266
|
189267
|
189268
|
189269
|
189270
|
189271
|
189272
|
189273
|
189274
|
189275
|
189276
|
189277
|
189278
|
189279
|
189280
|
189281
|
189282
|
189283
|
189284
|
189285
|
189286
|
189287
|
189288
|
189289
|
189290
|
189291
| 189292