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)
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
<td>{{ $t('falukant.family.children.gender') }}</td>
|
||||
<td>{{ $t(`falukant.titles.${child.gender}.noncivil`) }}</td>
|
||||
</tr>
|
||||
<tr v-if="child.birthContext">
|
||||
<td>{{ $t('falukant.family.children.birthContextLabel') }}</td>
|
||||
<td>{{ $t('falukant.family.children.birthContextLong.' + child.birthContext) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.family.children.otherParent') }}</td>
|
||||
<td>{{ otherParentDisplay }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ $t('falukant.family.children.heir') }}</td>
|
||||
<td>
|
||||
@@ -58,6 +66,16 @@ export default {
|
||||
child: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
otherParentDisplay() {
|
||||
if (!this.child?.otherParent) {
|
||||
return this.$t('falukant.family.children.otherParentUnknown');
|
||||
}
|
||||
const o = this.child.otherParent;
|
||||
const title = this.$t(`falukant.titles.${o.gender}.${o.nobleTitle}`);
|
||||
return `${title} ${o.firstName}`.trim();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open(child) {
|
||||
this.child = child;
|
||||
|
||||
@@ -659,6 +659,17 @@
|
||||
"acknowledged_bastard": "Anerkannt unehelich",
|
||||
"hidden_bastard": "Unehelich"
|
||||
},
|
||||
"otherParent": "Anderes Elternteil",
|
||||
"otherParentUnknown": "Unbekannt",
|
||||
"birthContextLabel": "Herkunft",
|
||||
"birthContextShort": {
|
||||
"marriage": "Ehe",
|
||||
"lover": "Liebschaft"
|
||||
},
|
||||
"birthContextLong": {
|
||||
"marriage": "Aus der Ehe",
|
||||
"lover": "Aus einer Liebschaft"
|
||||
},
|
||||
"details": {
|
||||
"title": "Kind-Details"
|
||||
}
|
||||
|
||||
@@ -653,10 +653,21 @@
|
||||
"acknowledged_bastard": "Acknowledged illegitimate",
|
||||
"hidden_bastard": "Illegitimate"
|
||||
},
|
||||
"otherParent": "Other parent",
|
||||
"otherParentUnknown": "Unknown",
|
||||
"birthContextLabel": "Origin",
|
||||
"birthContextShort": {
|
||||
"marriage": "Marriage",
|
||||
"lover": "Affair"
|
||||
},
|
||||
"birthContextLong": {
|
||||
"marriage": "From marriage",
|
||||
"lover": "From an affair"
|
||||
},
|
||||
"details": {
|
||||
"title": "Child Details"
|
||||
}
|
||||
,
|
||||
},
|
||||
"taxes": {
|
||||
"title": "Taxes",
|
||||
"loading": "Loading tax data...",
|
||||
@@ -665,7 +676,6 @@
|
||||
"region": "Region",
|
||||
"taxPercent": "Tax %"
|
||||
}
|
||||
}
|
||||
},
|
||||
"spouse": {
|
||||
"traitsToggle": "Character traits",
|
||||
|
||||
@@ -640,6 +640,17 @@
|
||||
"acknowledged_bastard": "Ilegítimo reconocido",
|
||||
"hidden_bastard": "Ilegítimo"
|
||||
},
|
||||
"otherParent": "Otro progenitor",
|
||||
"otherParentUnknown": "Desconocido",
|
||||
"birthContextLabel": "Origen",
|
||||
"birthContextShort": {
|
||||
"marriage": "Matrimonio",
|
||||
"lover": "Amorío"
|
||||
},
|
||||
"birthContextLong": {
|
||||
"marriage": "Del matrimonio",
|
||||
"lover": "De una relación amorosa"
|
||||
},
|
||||
"details": {
|
||||
"title": "Detalles del hijo"
|
||||
}
|
||||
|
||||
@@ -278,6 +278,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('falukant.family.children.name') }}</th>
|
||||
<th>{{ $t('falukant.family.children.otherParent') }}</th>
|
||||
<th>{{ $t('falukant.family.children.age') }}</th>
|
||||
<th>{{ $t('falukant.family.children.heir') }}</th>
|
||||
<th>{{ $t('falukant.family.children.actions') }}</th>
|
||||
@@ -295,6 +296,15 @@
|
||||
<button @click="jumpToChurchForm">{{ $t('falukant.family.children.baptism')
|
||||
}}</button>
|
||||
</td>
|
||||
<td class="child-other-parent-cell">
|
||||
<span class="child-other-parent-name">{{ formatOtherParentLine(child) }}</span>
|
||||
<span
|
||||
v-if="child.birthContext"
|
||||
class="child-origin-badge child-origin-badge--context"
|
||||
>
|
||||
{{ birthContextShortLabel(child.birthContext) }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ child.age }}</td>
|
||||
<td>
|
||||
<span v-if="child.isHeir" class="heir-badge">{{ $t('falukant.family.children.isHeir') }}</span>
|
||||
@@ -720,6 +730,21 @@ export default {
|
||||
this.$refs.childDetailsDialog?.open(child);
|
||||
},
|
||||
|
||||
formatOtherParentLine(child) {
|
||||
if (!child?.otherParent) {
|
||||
return this.$t('falukant.family.children.otherParentUnknown');
|
||||
}
|
||||
const o = child.otherParent;
|
||||
const title = this.$t(`falukant.titles.${o.gender}.${o.nobleTitle}`);
|
||||
return `${title} ${o.firstName}`.trim();
|
||||
},
|
||||
|
||||
birthContextShortLabel(context) {
|
||||
const key = `falukant.family.children.birthContextShort.${context}`;
|
||||
const t = this.$t(key);
|
||||
return t === key ? context : t;
|
||||
},
|
||||
|
||||
async setAsHeir(child) {
|
||||
if (!child.childCharacterId) {
|
||||
showError(this, 'tr:falukant.family.children.heirSetError');
|
||||
@@ -1218,6 +1243,20 @@ export default {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.child-origin-badge--context {
|
||||
margin-left: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.child-other-parent-cell {
|
||||
max-width: 14rem;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.child-other-parent-name {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.lovers-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
|
||||
|
||||
Reference in New Issue
Block a user