|
|
@@ -23,7 +23,7 @@ import { MarriageRelation } from '../../models/marriage-relation';
|
|
23
|
23
|
templateUrl: './family-edit.html',
|
|
24
|
24
|
styleUrl: './family-edit.scss',
|
|
25
|
25
|
})
|
|
26
|
|
-export class FamilyEdit implements OnInit{
|
|
|
26
|
+export class FamilyEdit implements OnInit {
|
|
27
|
27
|
danka: Danka | undefined;
|
|
28
|
28
|
family: Family | undefined;
|
|
29
|
29
|
families: Family[] = [];
|
|
|
@@ -135,14 +135,13 @@ export class FamilyEdit implements OnInit{
|
|
135
|
135
|
return this.families.filter((family) => family.id !== this.familyId);
|
|
136
|
136
|
}
|
|
137
|
137
|
|
|
138
|
|
- patchMarriageRelationFields(familyId: string): void {
|
|
139
|
|
- const relations = this.marriageRelationService.getMarriageRelationsByFamilyId(familyId);
|
|
|
138
|
+ async patchMarriageRelationFields(familyId: string): Promise<void> {
|
|
|
139
|
+ const relations = await this.marriageRelationService.getMarriageRelationsByFamilyId(familyId);
|
|
|
140
|
+
|
|
140
|
141
|
const relation =
|
|
141
|
142
|
relations.find((marriageRelation) => marriageRelation.status === 'current') ?? relations[0];
|
|
142
|
143
|
|
|
143
|
|
- if (!relation) {
|
|
144
|
|
- return;
|
|
145
|
|
- }
|
|
|
144
|
+ if (!relation) return;
|
|
146
|
145
|
|
|
147
|
146
|
this.familyForm.patchValue({
|
|
148
|
147
|
spouseId: relation.person1Id === familyId ? relation.person2Id : relation.person1Id,
|
|
|
@@ -150,14 +149,18 @@ export class FamilyEdit implements OnInit{
|
|
150
|
149
|
});
|
|
151
|
150
|
}
|
|
152
|
151
|
|
|
153
|
|
- findMarriageRelation(person1Id: string, person2Id: string): MarriageRelation | undefined {
|
|
154
|
|
- return this.marriageRelationService
|
|
155
|
|
- .getMarriageRelationsByFamilyId(person1Id)
|
|
156
|
|
- .find(
|
|
157
|
|
- (relation) =>
|
|
158
|
|
- (relation.person1Id === person1Id && relation.person2Id === person2Id) ||
|
|
159
|
|
- (relation.person1Id === person2Id && relation.person2Id === person1Id),
|
|
160
|
|
- );
|
|
|
152
|
+ async findMarriageRelation(
|
|
|
153
|
+ person1Id: string,
|
|
|
154
|
+ person2Id: string
|
|
|
155
|
+ ): Promise<MarriageRelation | undefined> {
|
|
|
156
|
+
|
|
|
157
|
+ const relations = await this.marriageRelationService.getMarriageRelationsByFamilyId(person1Id);
|
|
|
158
|
+
|
|
|
159
|
+ return relations.find(
|
|
|
160
|
+ (relation) =>
|
|
|
161
|
+ (relation.person1Id === person1Id && relation.person2Id === person2Id) ||
|
|
|
162
|
+ (relation.person1Id === person2Id && relation.person2Id === person1Id),
|
|
|
163
|
+ );
|
|
161
|
164
|
}
|
|
162
|
165
|
|
|
163
|
166
|
saveFamily() {
|