mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-03-19 14:03:44 +00:00
WikiTree: display marriage info for descendants
This commit is contained in:
@@ -34,6 +34,8 @@ interface Person {
|
|||||||
DeathDate: string;
|
DeathDate: string;
|
||||||
BirthLocation: string;
|
BirthLocation: string;
|
||||||
DeathLocation: string;
|
DeathLocation: string;
|
||||||
|
marriage_location: string;
|
||||||
|
marriage_date: string;
|
||||||
DataStatus?: {
|
DataStatus?: {
|
||||||
BirthDate: string;
|
BirthDate: string;
|
||||||
DeathDate: string;
|
DeathDate: string;
|
||||||
@@ -123,7 +125,10 @@ export async function loadWikiTree(
|
|||||||
// Map from family id to the set of children.
|
// Map from family id to the set of children.
|
||||||
const children = new Map<string, Set<number>>();
|
const children = new Map<string, Set<number>>();
|
||||||
// Map from famliy id to the spouses.
|
// Map from famliy id to the spouses.
|
||||||
const spouses = new Map<string, {wife?: number; husband?: number}>();
|
const spouses = new Map<
|
||||||
|
string,
|
||||||
|
{wife?: number; husband?: number; spouse?: Person}
|
||||||
|
>();
|
||||||
// Map from numerical id to human-readable id.
|
// Map from numerical id to human-readable id.
|
||||||
const idToName = new Map<number, string>();
|
const idToName = new Map<number, string>();
|
||||||
|
|
||||||
@@ -149,7 +154,18 @@ export async function loadWikiTree(
|
|||||||
}
|
}
|
||||||
converted.add(person.Id);
|
converted.add(person.Id);
|
||||||
const indi = convertPerson(person);
|
const indi = convertPerson(person);
|
||||||
// TODO: add to spouses map for each spouse.
|
if (person.Spouses) {
|
||||||
|
Object.values(person.Spouses).forEach((spouse) => {
|
||||||
|
const famId = getFamilyId(person.Id, spouse.Id);
|
||||||
|
getSet(families, person.Id).add(famId);
|
||||||
|
getSet(families, spouse.Id).add(famId);
|
||||||
|
const familySpouses =
|
||||||
|
person.Gender === 'Male'
|
||||||
|
? {wife: spouse.Id, husband: person.Id, spouse}
|
||||||
|
: {wife: person.Id, husband: spouse.Id, spouse};
|
||||||
|
spouses.set(famId, familySpouses);
|
||||||
|
});
|
||||||
|
}
|
||||||
indi.fams = Array.from(getSet(families, person.Id));
|
indi.fams = Array.from(getSet(families, person.Id));
|
||||||
indis.push(indi);
|
indis.push(indi);
|
||||||
});
|
});
|
||||||
@@ -169,6 +185,15 @@ export async function loadWikiTree(
|
|||||||
fam.children = Array.from(getSet(children, key)).map(
|
fam.children = Array.from(getSet(children, key)).map(
|
||||||
(child) => idToName.get(child)!,
|
(child) => idToName.get(child)!,
|
||||||
);
|
);
|
||||||
|
if (
|
||||||
|
value.spouse &&
|
||||||
|
(value.spouse.marriage_date || value.spouse.marriage_location)
|
||||||
|
) {
|
||||||
|
const parsedDate = parseDate(value.spouse.marriage_date);
|
||||||
|
fam.marriage = Object.assign({}, parsedDate, {
|
||||||
|
place: value.spouse.marriage_location,
|
||||||
|
});
|
||||||
|
}
|
||||||
return fam;
|
return fam;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user