Procházet zdrojové kódy

[add]

家系図タブの家系図表示と処理を追加
poohr před 3 týdny
rodič
revize
14e0c18901

+ 251
- 44
src/app/pages/danka-detail/danka-detail.html Zobrazit soubor

@@ -67,60 +67,60 @@
67 67
             </nav>
68 68
           </div>
69 69
           @if (selectedTab === 'basic') {
70
-          <button
71
-            type="button"
72
-            class="edit-button"
73
-            [routerLink]="['/danka-edit', danka.id]"
74
-          >
75
-            編集
76
-          </button>
70
+            <button
71
+              type="button"
72
+              class="edit-button"
73
+              [routerLink]="['/danka-edit', danka.id]"
74
+            >
75
+              編集
76
+            </button>
77 77
           }
78 78
 
79 79
           @if (selectedTab === 'kakocho') {
80
-          <button
81
-            type="button"
82
-            class="add-button"
83
-            [routerLink]="['/kakocho-edit', danka.id]"
84
-          >
85
-            故人を登録
86
-          </button>
87
-
88
-          <button
89
-            type="button"
90
-            class="edit-button"
91
-            [routerLink]="['/kakocho-edit', danka.id, kakocholist[0].id]"
92
-          >
93
-            編集
94
-          </button>
80
+            <button
81
+              type="button"
82
+              class="add-button"
83
+              [routerLink]="['/kakocho-edit', danka.id]"
84
+            >
85
+              故人を登録
86
+            </button>
87
+
88
+            <button
89
+              type="button"
90
+              class="edit-button"
91
+              [routerLink]="['/kakocho-edit', danka.id, kakocholist[0].id]"
92
+            >
93
+              編集
94
+            </button>
95 95
           }
96 96
 
97 97
         </div>
98 98
 
99 99
         <section class="family-summary">
100 100
           @if (selectedTab === 'basic') {
101
-          <div class="family-name-area">
102
-            <p class="family-name">{{ danka.householdName }}</p>
103
-            <p class="family-head">世帯主: {{ danka.householder }}</p>
104
-          </div>
101
+            <div class="family-name-area">
102
+              <p class="family-name">{{ danka.householdName }}</p>
103
+              <p class="family-head">世帯主: {{ danka.householder }}</p>
104
+            </div>
105 105
 
106
-          <div class="family-address">
107
-            <p>郵便番号 〒{{ danka.postalCode }}</p>
108
-            <p>住所 {{ danka.address }}</p>
109
-          </div>
106
+            <div class="family-address">
107
+              <p>郵便番号 〒{{ danka.postalCode }}</p>
108
+              <p>住所 {{ danka.address }}</p>
109
+            </div>
110 110
 
111
-          <button type="button" class="memo-button">
112
-            回忌を見る
113
-          </button>
111
+            <button type="button" class="memo-button">
112
+              回忌を見る
113
+            </button>
114 114
           }
115 115
 
116 116
           @if (selectedTab === 'kakocho') {
117
-          <div class="family-name-area">
118
-            <p class="family-name">{{ danka.householdName }}の過去帳{{ kakocholist.length }} 名</p>
119
-          </div>
117
+            <div class="family-name-area">
118
+              <p class="family-name">{{ danka.householdName }}の過去帳{{ kakocholist.length }} 名</p>
119
+            </div>
120 120
 
121
-          <button type="button" class="memo-button">
122
-            年次法要を見る
123
-          </button>
121
+            <button type="button" class="memo-button">
122
+              年次法要を見る
123
+            </button>
124 124
           }
125 125
         </section>
126 126
 
@@ -355,20 +355,227 @@
355 355
                 <div class="empty-family-message">
356 356
                   登録されている家族情報はありません。
357 357
                 </div>
358
-              }              
358
+              }
359 359
             </p>
360 360
           </section>
361 361
         }
362 362
 
363 363
         @if (selectedTab === 'familyTree') {
364
-          <section class="coming-soon-section">
364
+          <section class="family-tree-tab-content">
365 365
             <div class="section-heading">
366 366
               <h2>家系図</h2>
367
+              <p>
368
+                家族情報に登録された親子・配偶者の関係をもとに表示します。
369
+              </p>
367 370
             </div>
368 371
 
369
-            <p class="empty-family-message">
370
-              家系図はこれから実装します。
371
-            </p>
372
+            @if (families.length > 0) {
373
+              <div class="family-tree-layout">
374
+                <section class="family-tree-area">
375
+                  <div class="family-tree-toolbar">
376
+                    <div>
377
+                      <p class="family-tree-title">
378
+                        {{ danka.householdName }}の家系図
379
+                      </p>
380
+                      <p class="family-tree-caption">
381
+                        人物カードを選択すると、右側に関係情報が表示されます。
382
+                      </p>
383
+                    </div>
384
+
385
+                    <div class="family-tree-action-list">
386
+                      <button type="button" class="tree-action-button"
387
+                              [routerLink]="['/danka', danka.id, 'family-new']">
388
+                        親子を追加
389
+                      </button>
390
+
391
+                      <button type="button" class="tree-action-button"
392
+                              [routerLink]="['/danka', danka.id, 'family-new']">
393
+                        配偶者を追加
394
+                      </button>
395
+                    </div>
396
+                  </div>
397
+
398
+                  @if (selectedFamily) {
399
+                    <div class="family-tree-diagram">
400
+
401
+                      <div class="tree-generation parent-generation">
402
+                        @if (getFather(selectedFamily)) {
403
+                          <button
404
+                            type="button"
405
+                            class="family-tree-card small"
406
+                            (click)="selectFamily(getFather(selectedFamily)!)">
407
+                            <span class="tree-card-name">{{ getFather(selectedFamily)?.name }}</span>
408
+                            <span class="tree-card-relationship">父</span>
409
+                          </button>
410
+                        }
411
+                        @if (getMother(selectedFamily)) {
412
+                          <button type="button" class="family-tree-card small"
413
+                                  (click)="selectFamily(getMother(selectedFamily)!)">
414
+                            <span class="tree-card-name">{{ getMother(selectedFamily)?.name }}</span>
415
+                            <span class="tree-card-relationship">母</span>
416
+                          </button>
417
+                        }
418
+                      </div>
419
+
420
+                      <div class="tree-generation main-generation">
421
+                        <button type="button"
422
+                                class="family-tree-card active main-person">
423
+                          <span class="tree-card-name">
424
+                            {{ selectedFamily.name }}
425
+                          </span>
426
+                          <span class="tree-card-relationship">
427
+                            {{ selectedFamily.relationship || '関係未登録' }}
428
+                          </span>
429
+                          <span class="tree-card-birth">
430
+                            {{ selectedFamily.birthDate || '生年月日未登録' }}
431
+                          </span>
432
+                        </button>
433
+
434
+                        @if (getSpouse(selectedFamily)) {
435
+                          <button
436
+                            type="button"
437
+                            class="family-tree-card spouse-person"
438
+                            (click)="selectFamily(getSpouse(selectedFamily)!)">
439
+                            <span class="tree-card-name">
440
+                              {{ getSpouse(selectedFamily)?.name }}
441
+                            </span>
442
+                            <span class="tree-card-relationship">配偶者</span>
443
+                            <span class="tree-card-birth">
444
+                              {{ getSpouse(selectedFamily)?.birthDate || '生年月日未登録' }}
445
+                            </span>
446
+                          </button>
447
+                        }
448
+                      </div>
449
+
450
+                      <div class="tree-generation child-generation">
451
+                        @if (getChildren(selectedFamily).length > 0) {
452
+                          @for (child of getChildren(selectedFamily); track child.id) {
453
+                            <button
454
+                              type="button"
455
+                              class="family-tree-card small"
456
+                              (click)="selectFamily(child)">
457
+                              <span class="tree-card-name">
458
+                                {{ child.name }}
459
+                              </span>
460
+                              <span class="tree-card-relationship">
461
+                                {{ child.relationship || '子' }}
462
+                              </span>
463
+                            </button>
464
+                          }
465
+                        } @else {
466
+                          <p class="tree-empty-text">
467
+                            子どもの登録はありません。
468
+                          </p>
469
+                        }
470
+                      </div>
471
+                    </div>
472
+                    <div class="family-tree-member-list">
473
+                      <p class="member-list-title">人物一覧</p>
474
+
475
+                      <div class="member-chip-list">
476
+                        @for (family of families; track family.id) {
477
+                          <button
478
+                            type="button"
479
+                            class="member-chip"
480
+                            [class.active]="selectedFamily?.id === family.id"
481
+                            (click)="selectFamily(family)"
482
+                          >
483
+                            {{ family.name }}
484
+                          </button>
485
+                        }
486
+                      </div>
487
+                    </div>
488
+                  } @else {
489
+                    <p class="empty-family-message">
490
+                      人物カードを選択してください。
491
+                    </p>
492
+                  }
493
+                </section>
494
+
495
+                <aside class="family-tree-side-panel">
496
+                  <h3>選択中の人物情報</h3>
497
+
498
+                  @if (selectedFamily) {
499
+                    <div class="selected-person-card">
500
+                      <p class="selected-person-name">
501
+                        {{ selectedFamily.name }}
502
+                      </p>
503
+
504
+                      <p class="selected-person-sub">
505
+                        {{ selectedFamily.furigana || 'ふりがな未登録' }}
506
+                      </p>
507
+                    </div>
508
+
509
+                    <div class="selected-info-list">
510
+                      <div class="selected-info-row">
511
+                        <span>関係</span>
512
+                        <strong>{{ selectedFamily.relationship || '未登録' }}</strong>
513
+                      </div>
514
+
515
+                      <div class="selected-info-row">
516
+                        <span>生年月日</span>
517
+                        <strong>{{ selectedFamily.birthDate || '未登録' }}</strong>
518
+                      </div>
519
+
520
+                      <div class="selected-info-row">
521
+                        <span>父</span>
522
+                        <strong>{{ getFather(selectedFamily)?.name || '未登録' }}</strong>
523
+                      </div>
524
+
525
+                      <div class="selected-info-row">
526
+                        <span>母</span>
527
+                        <strong>{{ getMother(selectedFamily)?.name || '未登録' }}</strong>
528
+                      </div>
529
+
530
+                      <div class="selected-info-row">
531
+                        <span>配偶者</span>
532
+                        <strong>{{ getSpouse(selectedFamily)?.name || '未登録' }}</strong>
533
+                      </div>
534
+
535
+                      <div class="selected-info-row children-row">
536
+                        <span>子</span>
537
+                        <strong>
538
+                          @if (getChildren(selectedFamily).length > 0) {
539
+                            @for (child of getChildren(selectedFamily); track child.id) {
540
+                              <span class="child-name">
541
+                        {{ child.name }}
542
+                      </span>
543
+                            }
544
+                          } @else {
545
+                            未登録
546
+                          }
547
+                        </strong>
548
+                      </div>
549
+                    </div>
550
+
551
+                    <div class="selected-person-actions">
552
+                      <a
553
+                        class="selected-person-button"
554
+                        [routerLink]="['/danka', danka.id, 'family', selectedFamily.id, 'edit']"
555
+                      >
556
+                        個人情報を編集
557
+                      </a>
558
+
559
+                      <button
560
+                        type="button"
561
+                        class="selected-person-button secondary"
562
+                        (click)="selectedTab = 'kakocho'"
563
+                      >
564
+                        過去帳を確認
565
+                      </button>
566
+                    </div>
567
+                  } @else {
568
+                    <p class="empty-family-message">
569
+                      人物カードを選択してください。
570
+                    </p>
571
+                  }
572
+                </aside>
573
+              </div>
574
+            } @else {
575
+              <div class="empty-family-message">
576
+                登録されている家族情報はありません。
577
+              </div>
578
+            }
372 579
           </section>
373 580
         }
374 581
       } @else {

+ 445
- 1
src/app/pages/danka-detail/danka-detail.scss Zobrazit soubor

@@ -566,6 +566,395 @@
566 566
   margin-top: 24px;
567 567
 }
568 568
 
569
+/* =========================
570
+   家系図タブ
571
+========================= */
572
+
573
+.family-tree-tab-content {
574
+  margin-top: 24px;
575
+}
576
+
577
+.family-tree-tab-content .section-heading {
578
+  margin-bottom: 16px;
579
+}
580
+
581
+.family-tree-layout {
582
+  display: grid;
583
+  grid-template-columns: minmax(0, 1fr) 360px;
584
+  gap: 24px;
585
+  align-items: start;
586
+}
587
+
588
+.family-tree-area {
589
+  min-height: 460px;
590
+  padding: 22px;
591
+  background: #fffaf3;
592
+  border: 2px solid #d8c2aa;
593
+  border-radius: 18px;
594
+  box-sizing: border-box;
595
+}
596
+
597
+.family-tree-toolbar {
598
+  display: flex;
599
+  justify-content: space-between;
600
+  align-items: flex-start;
601
+  gap: 18px;
602
+  margin-bottom: 22px;
603
+}
604
+
605
+.family-tree-title {
606
+  margin: 0;
607
+  color: #2f2720;
608
+  font-size: 20px;
609
+  font-weight: 800;
610
+}
611
+
612
+.family-tree-caption {
613
+  margin: 4px 0 0;
614
+  color: #7b6b5c;
615
+  font-size: 14px;
616
+  line-height: 1.6;
617
+}
618
+
619
+.family-tree-action-list {
620
+  display: flex;
621
+  gap: 10px;
622
+  flex-shrink: 0;
623
+}
624
+
625
+.tree-action-button {
626
+  min-width: 112px;
627
+  height: 38px;
628
+  padding: 0 14px;
629
+  border: 2px solid #d8caba;
630
+  border-radius: 6px;
631
+  background: #ffffff;
632
+  color: #2f2720;
633
+  font-size: 14px;
634
+  font-weight: 800;
635
+  cursor: pointer;
636
+  box-sizing: border-box;
637
+}
638
+
639
+.tree-action-button:hover {
640
+  background: #f6efe6;
641
+}
642
+
643
+.family-tree-card-list {
644
+  display: grid;
645
+  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
646
+  gap: 14px;
647
+}
648
+
649
+.family-tree-card {
650
+  min-height: 112px;
651
+  padding: 16px 18px;
652
+  border: 2px solid #d8c2aa;
653
+  border-radius: 14px;
654
+  background: #ffffff;
655
+  color: #2f2720;
656
+  text-align: left;
657
+  cursor: pointer;
658
+  box-sizing: border-box;
659
+  display: flex;
660
+  flex-direction: column;
661
+  gap: 6px;
662
+}
663
+
664
+.family-tree-card:hover {
665
+  background: #f6efe6;
666
+}
667
+
668
+.family-tree-card.active {
669
+  border-color: #8a6543;
670
+  background: #eadfce;
671
+  box-shadow: 0 0 0 3px rgba(138, 101, 67, 0.16);
672
+}
673
+
674
+.tree-card-name {
675
+  color: #5d3b24;
676
+  font-size: 18px;
677
+  font-weight: 800;
678
+}
679
+
680
+.tree-card-relationship {
681
+  color: #2f2720;
682
+  font-size: 14px;
683
+  font-weight: 700;
684
+}
685
+
686
+.tree-card-birth {
687
+  color: #7b6b5c;
688
+  font-size: 13px;
689
+}
690
+
691
+.family-tree-side-panel {
692
+  min-height: 460px;
693
+  padding: 24px 22px;
694
+  background: #fffdf9;
695
+  border: 2px solid #d8caba;
696
+  border-radius: 36px;
697
+  box-sizing: border-box;
698
+}
699
+
700
+.family-tree-side-panel h3 {
701
+  margin: 0 0 16px;
702
+  color: #2f2720;
703
+  font-size: 20px;
704
+  font-weight: 800;
705
+}
706
+
707
+.selected-person-card {
708
+  margin-bottom: 18px;
709
+  padding: 16px 18px;
710
+  background: #eadfce;
711
+  border: 2px solid #d8caba;
712
+  border-radius: 14px;
713
+  box-sizing: border-box;
714
+}
715
+
716
+.selected-person-name {
717
+  margin: 0;
718
+  color: #2f2720;
719
+  font-size: 22px;
720
+  font-weight: 800;
721
+  line-height: 1.2;
722
+}
723
+
724
+.selected-person-sub {
725
+  margin: 4px 0 0;
726
+  color: #7b6b5c;
727
+  font-size: 14px;
728
+}
729
+
730
+.selected-info-list {
731
+  display: grid;
732
+  gap: 10px;
733
+}
734
+
735
+.selected-info-row {
736
+  display: grid;
737
+  grid-template-columns: 82px 1fr;
738
+  gap: 10px;
739
+  align-items: start;
740
+  padding: 10px 12px;
741
+  background: #ffffff;
742
+  border: 2px solid #d8caba;
743
+  border-radius: 8px;
744
+  box-sizing: border-box;
745
+}
746
+
747
+.selected-info-row span {
748
+  color: #7b6b5c;
749
+  font-size: 14px;
750
+  font-weight: 700;
751
+}
752
+
753
+.selected-info-row strong {
754
+  color: #2f2720;
755
+  font-size: 15px;
756
+  font-weight: 800;
757
+  line-height: 1.6;
758
+}
759
+
760
+.children-row strong {
761
+  display: flex;
762
+  flex-wrap: wrap;
763
+  gap: 6px;
764
+}
765
+
766
+.child-name {
767
+  display: inline-flex;
768
+  align-items: center;
769
+  min-height: 26px;
770
+  padding: 2px 8px;
771
+  border-radius: 999px;
772
+  background: #f1e7d8;
773
+  color: #5d3b24;
774
+  font-size: 13px;
775
+  font-weight: 800;
776
+}
777
+
778
+.selected-person-actions {
779
+  display: grid;
780
+  gap: 10px;
781
+  margin-top: 18px;
782
+}
783
+
784
+.selected-person-button {
785
+  min-height: 42px;
786
+  border: 2px solid #8a6543;
787
+  border-radius: 6px;
788
+  background: #8a6543;
789
+  color: #ffffff;
790
+  font-size: 15px;
791
+  font-weight: 800;
792
+  text-decoration: none;
793
+  cursor: pointer;
794
+  display: flex;
795
+  align-items: center;
796
+  justify-content: center;
797
+  box-sizing: border-box;
798
+}
799
+
800
+.selected-person-button:hover {
801
+  background: #765639;
802
+}
803
+
804
+.selected-person-button.secondary {
805
+  background: #ffffff;
806
+  color: #8a6543;
807
+}
808
+
809
+.selected-person-button.secondary:hover {
810
+  background: #f6efe6;
811
+}
812
+
813
+/* =========================
814
+   家系図 図式レイアウト
815
+========================= */
816
+
817
+.family-tree-diagram {
818
+  min-height: 330px;
819
+  padding: 28px 18px;
820
+  background: #fffdf9;
821
+  border: 2px dashed #d8c2aa;
822
+  border-radius: 18px;
823
+  box-sizing: border-box;
824
+  display: grid;
825
+  gap: 34px;
826
+}
827
+
828
+.tree-generation {
829
+  display: flex;
830
+  justify-content: center;
831
+  align-items: center;
832
+  gap: 18px;
833
+  position: relative;
834
+}
835
+
836
+.parent-generation {
837
+  padding-bottom: 8px;
838
+}
839
+
840
+.main-generation {
841
+  padding: 8px 0;
842
+}
843
+
844
+.child-generation {
845
+  padding-top: 8px;
846
+  flex-wrap: wrap;
847
+}
848
+
849
+.family-tree-card.small {
850
+  min-height: 86px;
851
+  max-width: 180px;
852
+}
853
+
854
+.family-tree-card.main-person {
855
+  min-width: 210px;
856
+}
857
+
858
+.family-tree-card.spouse-person {
859
+  min-width: 190px;
860
+}
861
+
862
+/* 本人と配偶者の間の線 */
863
+.main-generation .main-person::after {
864
+  content: "";
865
+  position: absolute;
866
+  top: 50%;
867
+  right: -20px;
868
+  width: 20px;
869
+  height: 2px;
870
+  background: #8a6543;
871
+}
872
+
873
+/* カードを線の基準にする */
874
+.main-generation .family-tree-card {
875
+  position: relative;
876
+}
877
+
878
+/* 親世代から本人世代への縦線 */
879
+.parent-generation::after {
880
+  content: "";
881
+  position: absolute;
882
+  bottom: -28px;
883
+  left: 50%;
884
+  width: 2px;
885
+  height: 28px;
886
+  background: #d8c2aa;
887
+  transform: translateX(-50%);
888
+}
889
+
890
+/* 本人世代から子世代への縦線 */
891
+.main-generation::after {
892
+  content: "";
893
+  position: absolute;
894
+  bottom: -30px;
895
+  left: 50%;
896
+  width: 2px;
897
+  height: 30px;
898
+  background: #d8c2aa;
899
+  transform: translateX(-50%);
900
+}
901
+
902
+/* 子どもがいない場合の文言 */
903
+.tree-empty-text {
904
+  margin: 0;
905
+  padding: 12px 18px;
906
+  background: #ffffff;
907
+  border: 2px solid #d8c2aa;
908
+  border-radius: 10px;
909
+  color: #7b6b5c;
910
+  font-size: 14px;
911
+  font-weight: 700;
912
+}
913
+
914
+.family-tree-member-list {
915
+  margin-top: 18px;
916
+  padding: 16px 18px;
917
+  background: #ffffff;
918
+  border: 2px solid #d8c2aa;
919
+  border-radius: 14px;
920
+  box-sizing: border-box;
921
+}
922
+
923
+.member-list-title {
924
+  margin: 0 0 10px;
925
+  color: #5d3b24;
926
+  font-size: 15px;
927
+  font-weight: 800;
928
+}
929
+
930
+.member-chip-list {
931
+  display: flex;
932
+  flex-wrap: wrap;
933
+  gap: 8px;
934
+}
935
+
936
+.member-chip {
937
+  min-height: 34px;
938
+  padding: 6px 12px;
939
+  border: 2px solid #d8caba;
940
+  border-radius: 999px;
941
+  background: #fffdf9;
942
+  color: #2f2720;
943
+  font-size: 14px;
944
+  font-weight: 700;
945
+  cursor: pointer;
946
+}
947
+
948
+.member-chip:hover {
949
+  background: #f6efe6;
950
+}
951
+
952
+.member-chip.active {
953
+  border-color: #8a6543;
954
+  background: #8a6543;
955
+  color: #ffffff;
956
+}
957
+
569 958
 /* 家族表が狭い画面では横スクロール */
570 959
 @media (max-width: 800px) {
571 960
   .family-list-summary {
@@ -585,4 +974,59 @@
585 974
   .family-support-area {
586 975
     grid-template-columns: 1fr;
587 976
   }
588
-}
977
+
978
+  //家系図タブ
979
+  .family-tree-layout {
980
+    grid-template-columns: 1fr;
981
+  }
982
+
983
+  .family-tree-toolbar {
984
+    flex-direction: column;
985
+  }
986
+
987
+  .family-tree-action-list {
988
+    width: 100%;
989
+    flex-direction: column;
990
+  }
991
+
992
+  .tree-action-button {
993
+    width: 100%;
994
+  }
995
+
996
+  .family-tree-side-panel {
997
+    border-radius: 28px;
998
+  }
999
+
1000
+  .selected-info-row {
1001
+    grid-template-columns: 1fr;
1002
+    gap: 4px;
1003
+  }
1004
+
1005
+  .family-tree-diagram {
1006
+    padding: 22px 12px;
1007
+    gap: 26px;
1008
+  }
1009
+
1010
+  .tree-generation {
1011
+    flex-direction: column;
1012
+    gap: 12px;
1013
+  }
1014
+
1015
+  .family-tree-card.small,
1016
+  .family-tree-card.main-person,
1017
+  .family-tree-card.spouse-person {
1018
+    width: 100%;
1019
+    max-width: none;
1020
+    min-width: 0;
1021
+  }
1022
+
1023
+  .main-generation .main-person::after {
1024
+    display: none;
1025
+  }
1026
+
1027
+  .parent-generation::after,
1028
+  .main-generation::after {
1029
+    height: 20px;
1030
+    bottom: -22px;
1031
+  }
1032
+}

+ 34
- 4
src/app/pages/danka-detail/danka-detail.ts Zobrazit soubor

@@ -22,6 +22,7 @@ export class DankaDetail {
22 22
   currentYear = new Date().getFullYear();
23 23
 
24 24
   selectedTab: 'basic' | 'family' | 'kakocho' | 'familyTree' = 'basic';
25
+  selectedFamily: Family | undefined = undefined;
25 26
 
26 27
   constructor(
27 28
     private dankaService: DankaService,
@@ -43,6 +44,7 @@ export class DankaDetail {
43 44
     if (id) {
44 45
       this.danka = this.dankaService.getDankaById(id);
45 46
       this.families = this.familyService.getFamiliesByDankaId(id);
47
+      this.selectedFamily = this.families[0];
46 48
       this.kakocholist = this.kakochoService.getKakochoByDankaId(id);
47 49
     }
48 50
     console.log(this.danka);
@@ -50,6 +52,7 @@ export class DankaDetail {
50 52
     console.log(tab);
51 53
   }
52 54
 
55
+  //年齢計算の処理
53 56
   getAge(birthDate: string) {
54 57
     if (birthDate === '') {
55 58
       return '-';
@@ -68,11 +71,38 @@ export class DankaDetail {
68 71
     console.log(this.kakocholist);
69 72
   }
70 73
 
74
+  //回忌計算の処理
71 75
   getKaiki(deathDate: string): number {
72
-    return (
73
-      this.currentYear -
74
-      new Date(deathDate).getFullYear() +
75
-      1
76
+    return this.currentYear - new Date(deathDate).getFullYear() + 1;
77
+  }
78
+
79
+  //家系図の処理
80
+  selectFamily(family: Family): void {
81
+    this.selectedFamily = family;
82
+  }
83
+
84
+  getFamilyById(id: string): Family | undefined {
85
+    if (!id) {
86
+      return undefined;
87
+    }
88
+    return this.families.find((family) => family.id === id);
89
+  }
90
+
91
+  getFather(family: Family): Family | undefined {
92
+    return this.getFamilyById(family.fatherId);
93
+  }
94
+
95
+  getMother(family: Family): Family | undefined {
96
+    return this.getFamilyById(family.motherId);
97
+  }
98
+
99
+  getSpouse(family: Family): Family | undefined {
100
+    return this.getFamilyById(family.spouseId);
101
+  }
102
+
103
+  getChildren(family: Family): Family[] {
104
+    return this.families.filter(
105
+      (child) => child.fatherId === family.id || child.motherId === family.id,
76 106
     );
77 107
   }
78 108
 }

Loading…
Zrušit
Uložit