webtrees
webtrees copied to clipboard
Unwanted ADOP when Linking to Family
When using "Link this individual to an existing family as a child" with "Relationship to parents" set to "Adopted", an ADOP event is created for the individual regardless of if an ADOP event linked to that family already exists.
For example, if the individual already has an ADOP event:
1 ADOP
2 FAMC @X1234@
Then creating a link to family @X1234
will result in:
1 ADOP
2 FAMC @X1234@
1 FAMC @X1234@
2 PEDI ADOPTED
1 ADOP
2 FAMC @X1234@
3 ADOP BOTH
The last three lines are the unwanted record. What I would expect is:
1 ADOP
2 FAMC @X1234@
3 ADOP BOTH
1 FAMC @X1234@
2 PEDI ADOPTED
Proposed pseudo-code:
AdopLinked = null
AdopUnlinked = null
For each ADOP event in the Individual:
If thisAdop linked to NewFamilyLink:
AdopLinked = thisAdop
Else If thisAdop has no link
AdopUnlinked = thisAdop
Else
Do nothing - thisAdop is linked to a different family
Endif
EndFor
If AdopLinked != null then
If AdopLinked does not have a 3 ADOP
Set 3 ADOP BOTH
Else If AdopUnlinked != null then
Reuse AdopUnlinked event - set 2 FAMC and 3 ADOP
Else
Create new 1 ADOP with 2 FAMC and 3 ADOP
Endif