Skip to content

Commit

Permalink
Merge pull request #1034 from bcgov/AB#27794-grid-edit-currency
Browse files Browse the repository at this point in the history
AB#27794 Update currency handling in datagrid edit modal
  • Loading branch information
jimmyPasta authored Jan 25, 2025
2 parents f33fedc + 8cd0503 commit 176de90
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
// Add a new 'change' event handler
formElements.on('change', function () {
let isValid = form.valid();
let hasInvalidCurrency = rowEditFormHasInvalidCurrencyCustomFields(formId);
let hasInvalidCurrency = rowEditFormHasInvalidCurrencyCustomFields(formId);
saveBtn.prop('disabled', !(isValid && !hasInvalidCurrency));
if (!isValid) {
Expand All @@ -135,7 +135,7 @@
// Get all date/time elements
let datetimeElements = $(`#${formId} input[type="datetime-local"], #${formId} input[type="date"]`);
// Loop through all the input elements
datetimeElements.each(function () {
// Find the <i> element within the same .custom-input-group
Expand All @@ -145,11 +145,14 @@
icon.attr('class', '');
});
function rowEditFormHasInvalidCurrencyCustomFields(formId) {
function rowEditFormHasInvalidCurrencyCustomFields(formId) {
let invalidFieldsFound = false;
$("#" + formId + " input:visible").each(function (i, el) {
let $field = $(this);
if ($field.hasClass('custom-currency-input')) {
if ($field.hasClass('custom-currency-input')) {
if ($field.val() === '' || $field.val() === '0') {
$field.val('0.00');
}
if (!isValidCurrencyCustomField($field)) {
invalidFieldsFound = true;
}
Expand Down
Loading

0 comments on commit 176de90

Please sign in to comment.