Bladeren bron

[add]

家系図に関係があると父、母、配偶者に初期値が出力
poohr 3 weken geleden
bovenliggende
commit
20c440e5e3
2 gewijzigde bestanden met toevoegingen van 48 en 53 verwijderingen
  1. 29
    52
      src/app/pages/family-edit/family-edit.html
  2. 19
    1
      src/app/pages/family-edit/family-edit.ts

+ 29
- 52
src/app/pages/family-edit/family-edit.html Bestand weergeven

@@ -22,11 +22,8 @@
22 22
               <div class="form-row">
23 23
                 <label for="name">氏名</label>
24 24
                 <div class="form-field">
25
-                  <input
26
-                    id="name"
27
-                    type="text"
28
-                    formControlName="name"
29
-                  />
25
+                  <input id="name" type="text"
26
+                         formControlName="name"/>
30 27
                   @if (familyForm.get('name')?.invalid && familyForm.get('name')?.touched) {
31 28
                     <p class="error-message">氏名を入力してください。</p>
32 29
                   }
@@ -36,11 +33,8 @@
36 33
               <div class="form-row">
37 34
                 <label for="furigana">ふりがな</label>
38 35
                 <div class="form-field">
39
-                  <input
40
-                    id="furigana"
41
-                    type="text"
42
-                    formControlName="furigana"
43
-                  />
36
+                  <input id="furigana" type="text"
37
+                         formControlName="furigana"/>
44 38
                   @if (familyForm.get('furigana')?.invalid && familyForm.get('furigana')?.touched) {
45 39
                     <p class="error-message">ふりがなを入力してください。</p>
46 40
                   }
@@ -50,10 +44,8 @@
50 44
               <div class="form-row">
51 45
                 <label for="relationship">世帯主との関係</label>
52 46
                 <div class="form-field">
53
-                  <select
54
-                    id="relationship"
55
-                    formControlName="relationship"
56
-                  >
47
+                  <select id="relationship"
48
+                          formControlName="relationship">
57 49
                     <option value="">選択してください</option>
58 50
                     <option value="世帯主">世帯主</option>
59 51
                     <option value="配偶者">配偶者</option>
@@ -65,21 +57,28 @@
65 57
                     <option value="次女">次女</option>
66 58
                     <option value="その他">その他</option>
67 59
                   </select>
68
-
69 60
                   @if (familyForm.get('relationship')?.invalid && familyForm.get('relationship')?.touched) {
70 61
                     <p class="error-message">世帯主との関係を選択してください。</p>
71 62
                   }
72 63
                 </div>
73 64
               </div>
74 65
 
66
+              <div class="form-row">
67
+                <label for="gender">性別</label>
68
+                <div class="form-field">
69
+                  <select id="gender" formControlName="gender">
70
+                    <option value="unknown">未設定</option>
71
+                    <option value="male">男性</option>
72
+                    <option value="female">女性</option>
73
+                  </select>
74
+                </div>
75
+              </div>
76
+
75 77
               <div class="form-row">
76 78
                 <label for="birthDate">生年月日</label>
77 79
                 <div class="form-field">
78
-                  <input
79
-                    id="birthDate"
80
-                    type="date"
81
-                    formControlName="birthDate"
82
-                  />
80
+                  <input id="birthDate" type="date"
81
+                         formControlName="birthDate"/>
83 82
                 </div>
84 83
               </div>
85 84
 
@@ -103,10 +102,7 @@
103 102
               <div class="form-row">
104 103
                 <label for="fatherId">父</label>
105 104
                 <div class="form-field">
106
-                  <select
107
-                    id="fatherId"
108
-                    formControlName="fatherId"
109
-                  >
105
+                  <select id="fatherId" formControlName="fatherId">
110 106
                     <option value="">選択なし</option>
111 107
                     @for (family of getFamilyOptions(); track family.id) {
112 108
                       <option [value]="family.id">
@@ -120,10 +116,7 @@
120 116
               <div class="form-row">
121 117
                 <label for="motherId">母</label>
122 118
                 <div class="form-field">
123
-                  <select
124
-                    id="motherId"
125
-                    formControlName="motherId"
126
-                  >
119
+                  <select id="motherId" formControlName="motherId">
127 120
                     <option value="">選択なし</option>
128 121
                     @for (family of getFamilyOptions(); track family.id) {
129 122
                       <option [value]="family.id">
@@ -137,10 +130,7 @@
137 130
               <div class="form-row">
138 131
                 <label for="spouseId">配偶者</label>
139 132
                 <div class="form-field">
140
-                  <select
141
-                    id="spouseId"
142
-                    formControlName="spouseId"
143
-                  >
133
+                  <select id="spouseId" formControlName="spouseId">
144 134
                     <option value="">選択なし</option>
145 135
                     @for (family of getFamilyOptions(); track family.id) {
146 136
                       <option [value]="family.id">
@@ -154,11 +144,7 @@
154 144
               <div class="form-row">
155 145
                 <label for="note">備考</label>
156 146
                 <div class="form-field">
157
-                  <textarea
158
-                    id="note"
159
-                    formControlName="note"
160
-                    rows="4"
161
-                  ></textarea>
147
+                  <textarea id="note" formControlName="note" rows="4"></textarea>
162 148
                 </div>
163 149
               </div>
164 150
 
@@ -169,11 +155,9 @@
169 155
             <div class="householder-area">
170 156
               <h3>この方を世帯主にする</h3>
171 157
 
172
-              <button
173
-                type="button"
174
-                class="set-householder-button"
175
-                (click)="setAsHouseholder()"
176
-              >
158
+              <button type="button"
159
+                      class="set-householder-button"
160
+                      (click)="setAsHouseholder()">
177 161
                 世帯主に設定
178 162
               </button>
179 163
             </div>
@@ -181,10 +165,7 @@
181 165
         </div>
182 166
 
183 167
         <div class="bottom-actions">
184
-          <button
185
-            type="button"
186
-            class="delete-button"
187
-            (click)="deleteFamily()">
168
+          <button type="button" class="delete-button" (click)="deleteFamily()">
188 169
             削除
189 170
           </button>
190 171
 
@@ -192,12 +173,8 @@
192 173
             キャンセル
193 174
           </button>
194 175
 
195
-          <button
196
-            type="button"
197
-            class="save-button"
198
-            [disabled]="familyForm.invalid"
199
-            (click)="saveFamily()"
200
-          >
176
+          <button type="button" class="save-button"
177
+                  [disabled]="familyForm.invalid" (click)="saveFamily()">
201 178
             保存
202 179
           </button>
203 180
         </div>

+ 19
- 1
src/app/pages/family-edit/family-edit.ts Bestand weergeven

@@ -25,6 +25,8 @@ export class FamilyEdit {
25 25
   families: Family[] = [];
26 26
   dankaId: string = '';
27 27
   familyId: string | null = null;
28
+  relationMode: string = '';
29
+  baseFamilyId: string = '';
28 30
 
29 31
   constructor(
30 32
     private familyService: FamilyService,
@@ -34,6 +36,8 @@ export class FamilyEdit {
34 36
     this.dankaId = this.route.snapshot.params['dankaId'];
35 37
     this.familyId = this.route.snapshot.params['familyId'];
36 38
     this.families = this.familyService.getFamiliesByDankaId(this.dankaId);
39
+    this.relationMode = this.route.snapshot.queryParamMap.get('relationMode') ?? '';
40
+    this.baseFamilyId = this.route.snapshot.queryParamMap.get('baseFamilyId') ?? '';
37 41
     if (this.familyId) {
38 42
       this.family = this.familyService.getFamilyById(this.familyId);
39 43
       if (this.family) {
@@ -46,6 +50,18 @@ export class FamilyEdit {
46 50
         });
47 51
       }
48 52
     }
53
+
54
+    if (!this.familyId && this.relationMode === 'spouse') {
55
+      this.familyForm.patchValue({
56
+        spouseId: this.baseFamilyId,
57
+      });
58
+    }
59
+
60
+    if (!this.familyId && this.relationMode === 'child') {
61
+      this.familyForm.patchValue({
62
+        fatherId: this.baseFamilyId,
63
+      });
64
+    }
49 65
   }
50 66
 
51 67
   familyForm = new FormGroup({
@@ -57,12 +73,13 @@ export class FamilyEdit {
57 73
     fatherId: new FormControl(''),
58 74
     motherId: new FormControl(''),
59 75
     spouseId: new FormControl(''),
76
+    gender: new FormControl('unknown'),
60 77
   });
61 78
 
62 79
   getAgeText() {
63 80
     const birthDate = this.familyForm.get('birthDate')?.value;
64 81
     if (!birthDate) {
65
-      return "生年月日を入力すると自動計算されます";
82
+      return '生年月日を入力すると自動計算されます';
66 83
     }
67 84
     const birth = new Date(birthDate);
68 85
     const today = new Date();
@@ -98,6 +115,7 @@ export class FamilyEdit {
98 115
       fatherId: this.familyForm.value.fatherId ?? '',
99 116
       motherId: this.familyForm.value.motherId ?? '',
100 117
       spouseId: this.familyForm.value.spouseId ?? '',
118
+      gender: this.familyForm.value.gender ?? 'unknown',
101 119
     };
102 120
     this.familyService.saveFamily(updatedFamily);
103 121
     this.router.navigate(['/danka-detail', dankaId], { queryParams: { tab: 'family' } });

Laden…
Annuleren
Opslaan