Skip to content

Commit

Permalink
+ (Event) Fixed issue causing common registrant values to be cleared …
Browse files Browse the repository at this point in the history
…when selecting a family member. (Fixes #5610)
  • Loading branch information
cabal95 committed Oct 4, 2023
1 parent b8d8e03 commit 6b6b024
Show file tree
Hide file tree
Showing 4 changed files with 719 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Rock.Blocks/Event/RegistrationEntry.cs
Expand Up @@ -2143,6 +2143,9 @@ private bool UpdatePersonAttributes( Person person, History.HistoryChangeList pe
var attribute = AttributeCache.Get( field.AttributeId.Value );
if ( attribute != null )
{
// Note: As per discussion with architecture team, it is correct
// behavior that the new value will always overwrite the old
// value, even if the new value is blank.
string originalValue = person.GetAttributeValue( attribute.Key );
string newValue = PublicAttributeHelper.GetPrivateValue( attribute, fieldValue.ToString() );
person.SetAttributeValue( attribute.Key, newValue );
Expand Down
Expand Up @@ -183,9 +183,9 @@ export default defineComponent({

/** The filtered fields to show on the current form augmented to remove pre/post HTML from non-visible fields */
currentFormFieldsAugmented(): RegistrationEntryBlockFormFieldViewModel[] {
const fields = JSON.parse(JSON.stringify(this.currentFormFields));
const fields = JSON.parse(JSON.stringify(this.currentFormFields)) as RegistrationEntryBlockFormFieldViewModel[];

fields.forEach((value, index) => {
fields.forEach(value => {
if (value.fieldSource != this.fieldSources.personField) {
let isVisible = true;
switch (value.visibilityRuleType) {
Expand Down Expand Up @@ -460,6 +460,13 @@ export default defineComponent({
// If the family member selection is made then set all form fields where use existing value is enabled
for (const form of this.viewModel.registrantForms) {
for (const field of form.fields) {
// Do not set common fields if they are of type
// Registrant Attribute since there is no value to set.
// Fixes issue #5610.
if (field.fieldSource === RegistrationFieldSource.RegistrantAttribute) {
continue;
}

if (field.guid in this.familyMember.fieldValues) {
const familyMemberValue = this.familyMember.fieldValues[field.guid];

Expand Down Expand Up @@ -520,6 +527,14 @@ export default defineComponent({
// If the family member selection is cleared then clear all form fields
for (const form of this.viewModel.registrantForms) {
for (const field of form.fields) {
// Do not touch common fields if they are of type
// Registrant Attribute since we don't set them when
// selecting a family member either.
// Fixes issue #5610.
if (field.fieldSource === RegistrationFieldSource.RegistrantAttribute) {
continue;
}

delete this.currentRegistrant.fieldValues[field.guid];
}
}
Expand Down

0 comments on commit 6b6b024

Please sign in to comment.