|
|
@@ -4,6 +4,7 @@ import {
|
|
4
|
4
|
ViewChild,
|
|
5
|
5
|
AfterViewInit
|
|
6
|
6
|
} from '@angular/core';
|
|
|
7
|
+import { OnInit } from '@angular/core';
|
|
7
|
8
|
import { ActivatedRoute, RouterLink } from '@angular/router';
|
|
8
|
9
|
import { DankaService } from '../../services/dankaService';
|
|
9
|
10
|
import { FamilyService } from '../../services/family-service';
|
|
|
@@ -34,6 +35,7 @@ import { FamilyUnitLayout } from '../../models/family-unit-layout';
|
|
34
|
35
|
import { FamilyUnitLayoutService } from '../../services/family-unit-layout';
|
|
35
|
36
|
|
|
36
|
37
|
|
|
|
38
|
+
|
|
37
|
39
|
interface NextMemorial {
|
|
38
|
40
|
name: string;
|
|
39
|
41
|
memorialType: string;
|
|
|
@@ -47,7 +49,7 @@ interface NextMemorial {
|
|
47
|
49
|
templateUrl: './danka-detail.html',
|
|
48
|
50
|
styleUrl: './danka-detail.scss',
|
|
49
|
51
|
})
|
|
50
|
|
-export class DankaDetail implements AfterViewInit {
|
|
|
52
|
+export class DankaDetail implements OnInit, AfterViewInit {
|
|
51
|
53
|
danka: Danka | undefined;
|
|
52
|
54
|
families: Family[] = [];
|
|
53
|
55
|
kakocholist: Kakocho[] = [];
|
|
|
@@ -92,6 +94,7 @@ export class DankaDetail implements AfterViewInit {
|
|
92
|
94
|
private familyUnitLayout: FamilyUnitLayoutService,
|
|
93
|
95
|
private eventService: EventService,
|
|
94
|
96
|
) {
|
|
|
97
|
+
|
|
95
|
98
|
const tab = this.route.snapshot.queryParams['tab'];
|
|
96
|
99
|
if (tab === 'family') {
|
|
97
|
100
|
this.selectedTab = 'family';
|
|
|
@@ -103,77 +106,88 @@ export class DankaDetail implements AfterViewInit {
|
|
103
|
106
|
this.selectedTab = 'familyTree';
|
|
104
|
107
|
}
|
|
105
|
108
|
|
|
|
109
|
+ }
|
|
|
110
|
+ ngOnInit(): void {
|
|
|
111
|
+ this.init();
|
|
|
112
|
+ }
|
|
|
113
|
+ async init(): Promise<void> {
|
|
106
|
114
|
const id = this.route.snapshot.params['id'];
|
|
107
|
|
- if (id) {
|
|
108
|
|
- this.danka = this.dankaService.getDankaById(id);
|
|
109
|
|
- this.marriageRelations = this.marriageRelationService.getMarriageRelationsByDankaId(id);
|
|
110
|
|
- this.families = this.sortFamiliesByHouseholder(this.familyService.getFamiliesByDankaId(id));
|
|
111
|
|
- this.selectedFamily = this.families[0];
|
|
112
|
|
- this.kakocholist = this.kakochoService.getKakochoByDankaId(id);
|
|
113
|
|
- this.nextMemorial = this.getNextMemorial();
|
|
114
|
|
-
|
|
115
|
|
- this.treeNodes =
|
|
116
|
|
- this.familyTreeBuilder.build(
|
|
117
|
|
- this.families,
|
|
118
|
|
- this.marriageRelations
|
|
119
|
|
- );
|
|
|
115
|
+ if (!id) return;
|
|
120
|
116
|
|
|
121
|
|
- const units =
|
|
122
|
|
- this.familyTreeBuilder.buildFamilyUnits(
|
|
123
|
|
- this.treeNodes
|
|
124
|
|
- );
|
|
|
117
|
+ this.danka = (await this.dankaService.getDankaById(id)) ?? undefined;
|
|
|
118
|
+ if (!this.danka) return;
|
|
125
|
119
|
|
|
126
|
|
- const unitTree =
|
|
127
|
|
- this.familyTreeBuilder.buildFamilyUnitTree(
|
|
128
|
|
- units
|
|
129
|
|
- );
|
|
|
120
|
+ this.marriageRelations = await this.marriageRelationService.getMarriageRelationsByDankaId(id);
|
|
|
121
|
+ this.families = this.sortFamiliesByHouseholder(
|
|
|
122
|
+ await this.familyService.getFamiliesByDankaId(id)
|
|
|
123
|
+ );
|
|
130
|
124
|
|
|
131
|
|
- const unitRoots =
|
|
132
|
|
- this.familyTreeBuilder.getUnitRoots(
|
|
133
|
|
- unitTree
|
|
134
|
|
- );
|
|
|
125
|
+ this.selectedFamily = this.families[0];
|
|
|
126
|
+ this.kakocholist = await this.kakochoService.getKakochoByDankaId(id);
|
|
135
|
127
|
|
|
136
|
|
- this.unitLayouts =
|
|
137
|
|
- this.familyUnitLayout.buildLayout(
|
|
138
|
|
- unitRoots
|
|
139
|
|
- );
|
|
|
128
|
+ this.nextMemorial = this.getNextMemorial();
|
|
140
|
129
|
|
|
141
|
|
- const roots =
|
|
142
|
|
- this.familyTreeBuilder.getRoots(
|
|
143
|
|
- this.treeNodes
|
|
144
|
|
- );
|
|
|
130
|
+ this.treeNodes =
|
|
|
131
|
+ this.familyTreeBuilder.build(
|
|
|
132
|
+ this.families,
|
|
|
133
|
+ this.marriageRelations
|
|
|
134
|
+ );
|
|
145
|
135
|
|
|
146
|
|
- this.layoutNodes =
|
|
147
|
|
- this.familyTreeLayout.buildLayout(
|
|
148
|
|
- roots
|
|
149
|
|
- );
|
|
|
136
|
+ const units =
|
|
|
137
|
+ this.familyTreeBuilder.buildFamilyUnits(
|
|
|
138
|
+ this.treeNodes
|
|
|
139
|
+ );
|
|
150
|
140
|
|
|
151
|
|
- this.rebuildLayoutNodeMap();
|
|
|
141
|
+ const unitTree =
|
|
|
142
|
+ this.familyTreeBuilder.buildFamilyUnitTree(
|
|
|
143
|
+ units
|
|
|
144
|
+ );
|
|
152
|
145
|
|
|
153
|
|
- this.unitLayouts =
|
|
154
|
|
- this.familyUnitLayout.buildLayout(
|
|
155
|
|
- unitRoots
|
|
156
|
|
- );
|
|
|
146
|
+ const unitRoots =
|
|
|
147
|
+ this.familyTreeBuilder.getUnitRoots(
|
|
|
148
|
+ unitTree
|
|
|
149
|
+ );
|
|
157
|
150
|
|
|
158
|
|
- this.rebuildUnitLayoutMap();
|
|
|
151
|
+ this.unitLayouts =
|
|
|
152
|
+ this.familyUnitLayout.buildLayout(
|
|
|
153
|
+ unitRoots
|
|
|
154
|
+ );
|
|
159
|
155
|
|
|
160
|
|
- this.calculateViewBox();
|
|
|
156
|
+ const roots =
|
|
|
157
|
+ this.familyTreeBuilder.getRoots(
|
|
|
158
|
+ this.treeNodes
|
|
|
159
|
+ );
|
|
161
|
160
|
|
|
162
|
|
- this.kakocholist.forEach(kakocho => {
|
|
163
|
|
- if (kakocho.familyId) {
|
|
164
|
|
- this.deathDateMap.set(
|
|
165
|
|
- kakocho.familyId,
|
|
166
|
|
- kakocho
|
|
167
|
|
- );
|
|
168
|
|
- }
|
|
169
|
|
- });
|
|
|
161
|
+ this.layoutNodes =
|
|
|
162
|
+ this.familyTreeLayout.buildLayout(
|
|
|
163
|
+ roots
|
|
|
164
|
+ );
|
|
170
|
165
|
|
|
171
|
|
- this.kakocholist.forEach(k => {
|
|
172
|
|
- const key = this.normalizeName(k.name) + '_' + k.dankaId;
|
|
173
|
|
- this.kakochoByNameMap.set(key, k);
|
|
174
|
|
- });
|
|
|
166
|
+ this.rebuildLayoutNodeMap();
|
|
|
167
|
+
|
|
|
168
|
+ this.unitLayouts =
|
|
|
169
|
+ this.familyUnitLayout.buildLayout(
|
|
|
170
|
+ unitRoots
|
|
|
171
|
+ );
|
|
|
172
|
+
|
|
|
173
|
+ this.rebuildUnitLayoutMap();
|
|
|
174
|
+
|
|
|
175
|
+ this.calculateViewBox();
|
|
|
176
|
+
|
|
|
177
|
+ this.kakocholist.forEach(kakocho => {
|
|
|
178
|
+ if (kakocho.familyId) {
|
|
|
179
|
+ this.deathDateMap.set(
|
|
|
180
|
+ kakocho.familyId,
|
|
|
181
|
+ kakocho
|
|
|
182
|
+ );
|
|
|
183
|
+ }
|
|
|
184
|
+ });
|
|
|
185
|
+
|
|
|
186
|
+ this.kakocholist.forEach(k => {
|
|
|
187
|
+ const key = this.normalizeName(k.name) + '_' + k.dankaId;
|
|
|
188
|
+ this.kakochoByNameMap.set(key, k);
|
|
|
189
|
+ });
|
|
175
|
190
|
|
|
176
|
|
- }
|
|
177
|
191
|
}
|
|
178
|
192
|
|
|
179
|
193
|
ngAfterViewInit(): void {
|