Просмотр исходного кода

[add]

檀家詳細画面の家系図タブに配偶者関係を表示
poohr 3 недель назад
Родитель
Сommit
f285bccffb

+ 48
- 1
src/app/pages/danka-detail/danka-detail.html Просмотреть файл

@@ -480,7 +480,7 @@
480 480
                           <button
481 481
                             type="button"
482 482
                             class="member-chip"
483
-                            [class.active]="selectedFamily?.id === family.id"
483
+                            [class.active]="selectedFamily.id === family.id"
484 484
                             (click)="selectFamily(family)"
485 485
                           >
486 486
                             {{ family.name }}
@@ -551,6 +551,53 @@
551 551
                       </div>
552 552
                     </div>
553 553
 
554
+                    <section class="marriage-summary-panel">
555
+                      <h4>配偶関係</h4>
556
+
557
+                      <div class="marriage-summary-block">
558
+                        <p class="marriage-summary-label">現在の配偶者</p>
559
+
560
+                        @if (getCurrentMarriage(selectedFamily); as currentMarriage) {
561
+                          @if (getMarriagePartner(currentMarriage, selectedFamily); as currentPartner) {
562
+                            <button
563
+                              type="button"
564
+                              class="marriage-person-button"
565
+                              (click)="selectFamily(currentPartner)"
566
+                            >
567
+                              {{ currentPartner.name }}
568
+                            </button>
569
+                          } @else {
570
+                            <p class="marriage-empty-text">未登録</p>
571
+                          }
572
+                        } @else {
573
+                          <p class="marriage-empty-text">未登録</p>
574
+                        }
575
+                      </div>
576
+
577
+                      <div class="marriage-summary-block">
578
+                        <p class="marriage-summary-label">過去の配偶者</p>
579
+
580
+                        @if (getPastMarriages(selectedFamily).length > 0) {
581
+                          <div class="marriage-history-list">
582
+                            @for (relation of getPastMarriages(selectedFamily); track relation.id) {
583
+                              @if (getMarriagePartner(relation, selectedFamily); as pastPartner) {
584
+                                <button
585
+                                  type="button"
586
+                                  class="marriage-person-button secondary"
587
+                                  (click)="selectFamily(pastPartner)"
588
+                                >
589
+                                  <span>{{ pastPartner.name }}</span>
590
+                                  <small>{{ getMarriageStatusLabel(relation.status) }}</small>
591
+                                </button>
592
+                              }
593
+                            }
594
+                          </div>
595
+                        } @else {
596
+                          <p class="marriage-empty-text">未登録</p>
597
+                        }
598
+                      </div>
599
+                    </section>
600
+
554 601
                     <div class="selected-person-actions">
555 602
                       <a
556 603
                         class="selected-person-button"

+ 71
- 0
src/app/pages/danka-detail/danka-detail.scss Просмотреть файл

@@ -775,6 +775,77 @@
775 775
   font-weight: 800;
776 776
 }
777 777
 
778
+.marriage-summary-panel {
779
+  margin-top: 18px;
780
+  padding: 14px 16px;
781
+  background: #fffaf3;
782
+  border: 2px solid #d8caba;
783
+  border-radius: 12px;
784
+  box-sizing: border-box;
785
+}
786
+
787
+.marriage-summary-panel h4 {
788
+  margin: 0 0 12px;
789
+  color: #2f2720;
790
+  font-size: 16px;
791
+  font-weight: 800;
792
+}
793
+
794
+.marriage-summary-block + .marriage-summary-block {
795
+  margin-top: 14px;
796
+}
797
+
798
+.marriage-summary-label {
799
+  margin: 0 0 8px;
800
+  color: #7b6b5c;
801
+  font-size: 13px;
802
+  font-weight: 800;
803
+}
804
+
805
+.marriage-history-list {
806
+  display: grid;
807
+  gap: 8px;
808
+}
809
+
810
+.marriage-person-button {
811
+  width: 100%;
812
+  min-height: 40px;
813
+  padding: 8px 10px;
814
+  border: 2px solid #8a6543;
815
+  border-radius: 8px;
816
+  background: #ffffff;
817
+  color: #2f2720;
818
+  font-size: 14px;
819
+  font-weight: 800;
820
+  cursor: pointer;
821
+  display: flex;
822
+  align-items: center;
823
+  justify-content: space-between;
824
+  gap: 8px;
825
+  box-sizing: border-box;
826
+}
827
+
828
+.marriage-person-button:hover {
829
+  background: #f6efe6;
830
+}
831
+
832
+.marriage-person-button small {
833
+  color: #7b6b5c;
834
+  font-size: 12px;
835
+  font-weight: 800;
836
+}
837
+
838
+.marriage-person-button.secondary {
839
+  border-color: #d8caba;
840
+}
841
+
842
+.marriage-empty-text {
843
+  margin: 0;
844
+  color: #7b6b5c;
845
+  font-size: 14px;
846
+  font-weight: 700;
847
+}
848
+
778 849
 .selected-person-actions {
779 850
   display: grid;
780 851
   gap: 10px;

+ 6
- 13
src/app/pages/danka-detail/danka-detail.ts Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 import { Component } from '@angular/core';
2
-import { ActivatedRoute, Router, RouterLink } from '@angular/router';
2
+import { ActivatedRoute, RouterLink } from '@angular/router';
3 3
 import { DankaService } from '../../services/dankaService';
4 4
 import { FamilyService } from '../../services/family-service';
5 5
 import { KakochoService } from '../../services/kakocho-service';
@@ -34,7 +34,6 @@ export class DankaDetail {
34 34
     private marriageRelationService: MarriageRelationService,
35 35
     private route: ActivatedRoute,
36 36
   ) {
37
-    //遷移先からタブ情報を取得
38 37
     const tab = this.route.snapshot.queryParams['tab'];
39 38
     if (tab === 'family') {
40 39
       this.selectedTab = 'family';
@@ -43,7 +42,7 @@ export class DankaDetail {
43 42
     } else if (tab === 'familyTree') {
44 43
       this.selectedTab = 'familyTree';
45 44
     }
46
-    //遷移先のIDから該当の世帯と家族基本を取得
45
+
47 46
     const id = this.route.snapshot.params['id'];
48 47
     if (id) {
49 48
       this.danka = this.dankaService.getDankaById(id);
@@ -52,19 +51,15 @@ export class DankaDetail {
52 51
       this.selectedFamily = this.families[0];
53 52
       this.kakocholist = this.kakochoService.getKakochoByDankaId(id);
54 53
     }
55
-    console.log(this.danka);
56
-    console.log(this.families);
57
-    console.log(tab);
58 54
   }
59 55
 
60
-  //年齢計算の処理
61
-  getAge(birthDate: string) {
56
+  getAge(birthDate: string): string {
62 57
     if (birthDate === '') {
63 58
       return '-';
64 59
     }
65 60
 
66 61
     const birth = new Date(birthDate);
67
-    const today: Date = new Date();
62
+    const today = new Date();
68 63
     const thisYearBirthday = new Date(today.getFullYear(), birth.getMonth(), birth.getDate());
69 64
 
70 65
     let age = today.getFullYear() - birth.getFullYear();
@@ -72,16 +67,14 @@ export class DankaDetail {
72 67
     if (thisYearBirthday > today) {
73 68
       age--;
74 69
     }
70
+
75 71
     return age.toString();
76
-    console.log(this.kakocholist);
77 72
   }
78 73
 
79
-  //回忌計算の処理
80 74
   getKaiki(deathDate: string): number {
81 75
     return this.currentYear - new Date(deathDate).getFullYear() + 1;
82 76
   }
83 77
 
84
-  //家系図の処理
85 78
   selectFamily(family: Family): void {
86 79
     this.selectedFamily = family;
87 80
   }
@@ -90,6 +83,7 @@ export class DankaDetail {
90 83
     if (!id) {
91 84
       return undefined;
92 85
     }
86
+
93 87
     return this.families.find((family) => family.id === id);
94 88
   }
95 89
 
@@ -125,7 +119,6 @@ export class DankaDetail {
125 119
         relation.status !== 'current' &&
126 120
         (relation.person1Id === family.id || relation.person2Id === family.id),
127 121
     );
128
-
129 122
   }
130 123
 
131 124
   getMarriagePartner(relation: MarriageRelation, family: Family): Family | undefined {

Загрузка…
Отмена
Сохранить