Skip to content

Commit

Permalink
- Fixed issue in Obsidian and webforms RegistrationEntry where single…
Browse files Browse the repository at this point in the history
… required fees were not being required. (Fixes #5464)
  • Loading branch information
ethan-sparkdevnetwork committed Jun 7, 2023
1 parent 83fa2e0 commit fa892cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Expand Up @@ -49,7 +49,8 @@ export default defineComponent({
data() {
return {
dropDownValue: "",
checkboxValue: false
checkboxValue: false,
disabled: false
};
},
methods: {
Expand Down Expand Up @@ -110,6 +111,9 @@ export default defineComponent({
},
rules(): string {
return this.fee.isRequired ? "required" : "";
},
isDisabled(): string | undefined {
return this.disabled ? "disabled" : undefined;
}
},
watch: {
Expand Down Expand Up @@ -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;
}
}
}
},
Expand Down Expand Up @@ -165,7 +184,7 @@ export default defineComponent({
},
template: `
<template v-if="!isHidden">
<CheckBox v-if="isCheckbox" :label="label" v-model="checkboxValue" :rules="rules" />
<CheckBox v-if="isCheckbox" :label="label" v-model="checkboxValue" :rules="rules" :disabled="isDisabled" />
<NumberUpDown v-else-if="isNumberUpDown" :label="label" :min="0" :max="singleItem.countRemaining || 100" v-model="modelValue[singleItem.guid]" :rules="rules" />
<DropDownList v-else-if="isDropDown" :label="label" :items="dropDownListOptions" v-model="dropDownValue" :rules="rules" formControlClasses="input-width-md" />
<NumberUpDownGroup v-else-if="isNumberUpDownGroup" :label="label" :options="numberUpDownGroupOptions" v-model="modelValue" :rules="rules" />
Expand Down
Expand Up @@ -47,7 +47,7 @@ private Control GetFeeSingleOptionSingleQuantityControl( bool setValues, string

var currentValue = feeValues?.FirstOrDefault()?.Quantity ?? 0;

if ( fee.IsRequired && usageCountRemaining > 0 )
if ( fee.IsRequired && ( !usageCountRemaining.HasValue || usageCountRemaining > 0 ) )
{
cb.Checked = true;
cb.Enabled = false;
Expand Down

0 comments on commit fa892cf

Please sign in to comment.