|
|
@@ -6,8 +6,10 @@ import { KakochoService } from '../../services/kakocho-service';
|
|
6
|
6
|
import { Danka } from '../../models/danka';
|
|
7
|
7
|
import { Family } from '../../models/family';
|
|
8
|
8
|
import { Kakocho } from '../../models/kakocho';
|
|
|
9
|
+import { MarriageRelation } from '../../models/marriage-relation';
|
|
9
|
10
|
import { AppHeader } from '../../share/header/app-header';
|
|
10
|
11
|
import { AppSideMenu } from '../../share/side-menu/app-side-menu';
|
|
|
12
|
+import { MarriageRelationService } from '../../services/marriage-relation-service';
|
|
11
|
13
|
|
|
12
|
14
|
@Component({
|
|
13
|
15
|
selector: 'app-danka-detail',
|
|
|
@@ -19,6 +21,7 @@ export class DankaDetail {
|
|
19
|
21
|
danka: Danka | undefined;
|
|
20
|
22
|
families: Family[] = [];
|
|
21
|
23
|
kakocholist: Kakocho[] = [];
|
|
|
24
|
+ marriageRelations: MarriageRelation[] = [];
|
|
22
|
25
|
currentYear = new Date().getFullYear();
|
|
23
|
26
|
|
|
24
|
27
|
selectedTab: 'basic' | 'family' | 'kakocho' | 'familyTree' = 'basic';
|
|
|
@@ -28,6 +31,7 @@ export class DankaDetail {
|
|
28
|
31
|
private dankaService: DankaService,
|
|
29
|
32
|
private familyService: FamilyService,
|
|
30
|
33
|
private kakochoService: KakochoService,
|
|
|
34
|
+ private marriageRelationService: MarriageRelationService,
|
|
31
|
35
|
private route: ActivatedRoute,
|
|
32
|
36
|
) {
|
|
33
|
37
|
//遷移先からタブ情報を取得
|
|
|
@@ -43,6 +47,7 @@ export class DankaDetail {
|
|
43
|
47
|
const id = this.route.snapshot.params['id'];
|
|
44
|
48
|
if (id) {
|
|
45
|
49
|
this.danka = this.dankaService.getDankaById(id);
|
|
|
50
|
+ this.marriageRelations = this.marriageRelationService.getMarriageRelationsByDankaId(id);
|
|
46
|
51
|
this.families = this.familyService.getFamiliesByDankaId(id);
|
|
47
|
52
|
this.selectedFamily = this.families[0];
|
|
48
|
53
|
this.kakocholist = this.kakochoService.getKakochoByDankaId(id);
|
|
|
@@ -105,4 +110,39 @@ export class DankaDetail {
|
|
105
|
110
|
(child) => child.fatherId === family.id || child.motherId === family.id,
|
|
106
|
111
|
);
|
|
107
|
112
|
}
|
|
|
113
|
+
|
|
|
114
|
+ getCurrentMarriage(family: Family): MarriageRelation | undefined {
|
|
|
115
|
+ return this.marriageRelations.find(
|
|
|
116
|
+ (relation) =>
|
|
|
117
|
+ relation.status === 'current' &&
|
|
|
118
|
+ (relation.person1Id === family.id || relation.person2Id === family.id),
|
|
|
119
|
+ );
|
|
|
120
|
+ }
|
|
|
121
|
+
|
|
|
122
|
+ getPastMarriages(family: Family): MarriageRelation[] {
|
|
|
123
|
+ return this.marriageRelations.filter(
|
|
|
124
|
+ (relation) =>
|
|
|
125
|
+ relation.status !== 'current' &&
|
|
|
126
|
+ (relation.person1Id === family.id || relation.person2Id === family.id),
|
|
|
127
|
+ );
|
|
|
128
|
+
|
|
|
129
|
+ }
|
|
|
130
|
+
|
|
|
131
|
+ getMarriagePartner(relation: MarriageRelation, family: Family): Family | undefined {
|
|
|
132
|
+ const partnerId = relation.person1Id === family.id ? relation.person2Id : relation.person1Id;
|
|
|
133
|
+ return this.getFamilyById(partnerId);
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
|
136
|
+ getMarriageStatusLabel(status: string): string {
|
|
|
137
|
+ if (status === 'current') {
|
|
|
138
|
+ return '現在の配偶者';
|
|
|
139
|
+ }
|
|
|
140
|
+ if (status === 'divorced') {
|
|
|
141
|
+ return '離婚';
|
|
|
142
|
+ }
|
|
|
143
|
+ if (status === 'widowed') {
|
|
|
144
|
+ return '死別';
|
|
|
145
|
+ }
|
|
|
146
|
+ return '不明';
|
|
|
147
|
+ }
|
|
108
|
148
|
}
|