ソースを参照

[add]

檀家詳細画面の家系図タブに配偶者関係を表示
poohr 3週間前
コミット
f285bccffb

+ 48
- 1
src/app/pages/danka-detail/danka-detail.html ファイルの表示

480
                           <button
480
                           <button
481
                             type="button"
481
                             type="button"
482
                             class="member-chip"
482
                             class="member-chip"
483
-                            [class.active]="selectedFamily?.id === family.id"
483
+                            [class.active]="selectedFamily.id === family.id"
484
                             (click)="selectFamily(family)"
484
                             (click)="selectFamily(family)"
485
                           >
485
                           >
486
                             {{ family.name }}
486
                             {{ family.name }}
551
                       </div>
551
                       </div>
552
                     </div>
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
                     <div class="selected-person-actions">
601
                     <div class="selected-person-actions">
555
                       <a
602
                       <a
556
                         class="selected-person-button"
603
                         class="selected-person-button"

+ 71
- 0
src/app/pages/danka-detail/danka-detail.scss ファイルの表示

775
   font-weight: 800;
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
 .selected-person-actions {
849
 .selected-person-actions {
779
   display: grid;
850
   display: grid;
780
   gap: 10px;
851
   gap: 10px;

+ 6
- 13
src/app/pages/danka-detail/danka-detail.ts ファイルの表示

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

読み込み中…
キャンセル
保存