From fa892cf99d6bd9c5e32af458dec34636b90b4d8d Mon Sep 17 00:00:00 2001 From: ethan-sparkdevnetwork Date: Wed, 7 Jun 2023 14:19:25 -0700 Subject: [PATCH] - Fixed issue in Obsidian and webforms RegistrationEntry where single required fees were not being required. (Fixes #5464) --- .../RegistrationEntry/feeField.partial.ts | 23 +++++++++++++++++-- .../RegistrationTemplateFee.WebForms.cs | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Rock.JavaScript.Obsidian.Blocks/src/Event/RegistrationEntry/feeField.partial.ts b/Rock.JavaScript.Obsidian.Blocks/src/Event/RegistrationEntry/feeField.partial.ts index 72169f2196b..856d43f893c 100644 --- a/Rock.JavaScript.Obsidian.Blocks/src/Event/RegistrationEntry/feeField.partial.ts +++ b/Rock.JavaScript.Obsidian.Blocks/src/Event/RegistrationEntry/feeField.partial.ts @@ -49,7 +49,8 @@ export default defineComponent({ data() { return { dropDownValue: "", - checkboxValue: false + checkboxValue: false, + disabled: false }; }, methods: { @@ -110,6 +111,9 @@ export default defineComponent({ }, rules(): string { return this.fee.isRequired ? "required" : ""; + }, + isDisabled(): string | undefined { + return this.disabled ? "disabled" : undefined; } }, watch: { @@ -138,6 +142,21 @@ export default defineComponent({ if (this.isCheckbox && this.singleItem) { this.checkboxValue = !!this.modelValue[this.singleItem.guid]; this.modelValue[this.singleItem.guid] = this.checkboxValue ? 1 : 0; + + // If the fee is required and available then select and disable the checkbox + if (this.fee.isRequired && (this.fee.items[0].countRemaining === null || this.fee.items[0].countRemaining > 0)) { + this.checkboxValue = true; + this.modelValue[this.singleItem.guid] = this.checkboxValue ? 1 : 0; + this.disabled = true; + } + + // If the fee is not required and used up then disable the checkbox. + if (this.fee.items[0].countRemaining !== null && this.fee.items[0].countRemaining <= 0) { + // If the checkbox is already checked then leave it checked in case this form is being revisited. + this.checkboxValue = this.checkboxValue ? this.checkboxValue : false; + this.modelValue[this.singleItem.guid] = this.checkboxValue ? 1 : 0; + this.disabled = true; + } } } }, @@ -165,7 +184,7 @@ export default defineComponent({ }, template: `