2 Commits

Author SHA1 Message Date
c6c984c34c Handle particular cases in simple family tree
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-31 20:26:34 +02:00
c84fb50087 Fix type declaration issue 2023-08-31 20:14:36 +02:00
3 changed files with 32 additions and 4 deletions

View File

@@ -212,7 +212,7 @@ export function CouplePage(p: {
shouldAllowLeaving?: boolean;
children?: Member[];
onCancel?: () => void;
onSave?: (m: Couple) => void;
onSave?: (m: Couple) => Promise<void>;
onRequestEdit?: () => void;
onRequestDelete?: () => void;
onForceReload?: () => void;

View File

@@ -234,7 +234,7 @@ export function MemberPage(p: {
siblings?: Member[];
couples?: Couple[];
onCancel?: () => void;
onSave?: (m: Member) => void;
onSave?: (m: Member) => Promise<void>;
onRequestEdit?: () => void;
onRequestDelete?: () => void;
onForceReload?: () => void;

View File

@@ -254,6 +254,7 @@ function NodeArea(p: {
let pers2 = p.node.spouse?.member;
let didSwap = false;
// Show male of the left (all the time)
if (pers2?.sex === "M") {
let s = pers1;
pers1 = pers2;
@@ -293,10 +294,37 @@ function NodeArea(p: {
let childrenLinkX: number;
let childrenLinkY: number;
if (p.node.spouse) {
// If the father is the father of all the children, while the
// mother is not the mother of any of the children
if (
pers2 &&
p.node.down.every(
(n) => n.member.father === pers1.id && n.member.mother !== pers2!.id
)
) {
childrenLinkX = parent_x_offset + Math.floor(memberCardWidth(pers1) / 2);
childrenLinkY = p.y + CARD_HEIGHT + 2;
}
// If the mother is the mother of all the children, while the
// father is not the father of any of the children
if (
pers2 &&
p.node.down.every(
(n) => n.member.father !== pers1.id && n.member.mother === pers2!.id
)
) {
childrenLinkX = beginSecondFaceX! + Math.floor(memberCardWidth(pers2) / 2);
childrenLinkY = p.y + CARD_HEIGHT + 2;
}
// Normal couple
else if (p.node.spouse) {
childrenLinkX = Math.floor((endFirstFaceX + beginSecondFaceX!) / 2);
childrenLinkY = middleParentFaceY;
} else {
}
// Single person
else {
childrenLinkX = parent_x_offset + Math.floor(memberCardWidth(pers1) / 2);
childrenLinkY = p.y + CARD_HEIGHT + 2;
}