feat(falukant): enhance child details with other parent information and birth context
All checks were successful
Deploy to production / deploy (push) Successful in 3m2s
All checks were successful
Deploy to production / deploy (push) Successful in 3m2s
- Updated FalukantService to include father and mother character IDs in child relationships. - Added logic to retrieve and display other parent details in ChildDetailsDialog and FamilyView components. - Introduced new translations for 'other parent' and 'birth context' in English, German, and Spanish localization files. - Enhanced UI to show other parent information and birth context in child detail views.
This commit is contained in:
@@ -3439,7 +3439,7 @@ class FalukantService extends BaseService {
|
||||
{ motherCharacterId: { [Op.in]: userCharacterIds } }
|
||||
]
|
||||
},
|
||||
attributes: ['childCharacterId', 'nameSet', 'isHeir', 'legitimacy', 'birthContext', 'publicKnown', 'createdAt']
|
||||
attributes: ['childCharacterId', 'nameSet', 'isHeir', 'legitimacy', 'birthContext', 'publicKnown', 'createdAt', 'fatherCharacterId', 'motherCharacterId']
|
||||
})
|
||||
: [];
|
||||
const childCharIds = [...new Set(childRels.map(r => r.childCharacterId))];
|
||||
@@ -3451,7 +3451,57 @@ class FalukantService extends BaseService {
|
||||
})
|
||||
: [];
|
||||
const childCharMap = Object.fromEntries(childChars.map(c => [c.id, c]));
|
||||
const children = childRels.map(rel => {
|
||||
|
||||
const otherParentIds = new Set();
|
||||
const relMeta = childRels.map((rel) => {
|
||||
const fatherId = rel.fatherCharacterId;
|
||||
const motherId = rel.motherCharacterId;
|
||||
const userIsFather = userCharacterIds.includes(fatherId);
|
||||
const userIsMother = userCharacterIds.includes(motherId);
|
||||
let otherParentId = null;
|
||||
let playerRole = null;
|
||||
if (userIsFather && userIsMother) {
|
||||
otherParentId = null;
|
||||
playerRole = null;
|
||||
} else if (userIsFather) {
|
||||
otherParentId = motherId;
|
||||
playerRole = 'father';
|
||||
} else if (userIsMother) {
|
||||
otherParentId = fatherId;
|
||||
playerRole = 'mother';
|
||||
}
|
||||
if (otherParentId != null) {
|
||||
otherParentIds.add(otherParentId);
|
||||
}
|
||||
return { rel, otherParentId, playerRole };
|
||||
});
|
||||
|
||||
const otherParentChars = otherParentIds.size
|
||||
? await FalukantCharacter.findAll({
|
||||
where: { id: { [Op.in]: [...otherParentIds] } },
|
||||
attributes: ['id', 'gender', 'titleOfNobility'],
|
||||
include: [
|
||||
{ model: FalukantPredefineFirstname, as: 'definedFirstName', attributes: ['name'] },
|
||||
{ model: TitleOfNobility, as: 'nobleTitle', attributes: ['labelTr'] }
|
||||
]
|
||||
})
|
||||
: [];
|
||||
const otherParentMap = Object.fromEntries(
|
||||
otherParentChars.map((c) => {
|
||||
const plain = c.get({ plain: true });
|
||||
return [
|
||||
plain.id,
|
||||
{
|
||||
characterId: plain.id,
|
||||
firstName: plain.definedFirstName?.name || 'Unknown',
|
||||
gender: plain.gender || 'male',
|
||||
nobleTitle: plain.nobleTitle?.labelTr || 'noncivil',
|
||||
}
|
||||
];
|
||||
})
|
||||
);
|
||||
|
||||
const children = relMeta.map(({ rel, otherParentId, playerRole }) => {
|
||||
const kid = childCharMap[rel.childCharacterId];
|
||||
return {
|
||||
childCharacterId: rel.childCharacterId,
|
||||
@@ -3464,6 +3514,8 @@ class FalukantService extends BaseService {
|
||||
birthContext: rel.birthContext || 'marriage',
|
||||
publicKnown: !!rel.publicKnown,
|
||||
_createdAt: rel.createdAt,
|
||||
playerRole,
|
||||
otherParent: otherParentId != null ? (otherParentMap[otherParentId] || null) : null,
|
||||
};
|
||||
});
|
||||
// Sort children globally by relation createdAt ascending (older first)
|
||||
|
||||
Reference in New Issue
Block a user