kuni před 3 týdny
rodič
revize
5a3ba3f4e4

+ 2
- 2
src/app/pages/event/event.ts Zobrazit soubor

1
-import { Component } from '@angular/core';
1
+import { Component, OnInit } from '@angular/core';
2
 import { FormsModule } from '@angular/forms';
2
 import { FormsModule } from '@angular/forms';
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';
13
   templateUrl: './event.html',
13
   templateUrl: './event.html',
14
   styleUrl: './event.scss',
14
   styleUrl: './event.scss',
15
 })
15
 })
16
-export class EventPage {
16
+export class EventPage implements OnInit{
17
   eventTargets: EventTarget[] = [];
17
   eventTargets: EventTarget[] = [];
18
   targetYear: number = new Date().getFullYear();
18
   targetYear: number = new Date().getFullYear();
19
   selectedEventType: EventType | 'all' = 'all';
19
   selectedEventType: EventType | 'all' = 'all';

+ 19
- 5
src/app/pages/family-edit/family-edit.ts Zobrazit soubor

6
   ReactiveFormsModule,
6
   ReactiveFormsModule,
7
   Validators,
7
   Validators,
8
 } from '@angular/forms';
8
 } from '@angular/forms';
9
+import { OnInit } from '@angular/core';
9
 import { ActivatedRoute, Router, RouterLink } from '@angular/router';
10
 import { ActivatedRoute, Router, RouterLink } from '@angular/router';
10
 import { AppHeader } from '../../share/header/app-header';
11
 import { AppHeader } from '../../share/header/app-header';
11
 import { AppSideMenu } from '../../share/side-menu/app-side-menu';
12
 import { AppSideMenu } from '../../share/side-menu/app-side-menu';
22
   templateUrl: './family-edit.html',
23
   templateUrl: './family-edit.html',
23
   styleUrl: './family-edit.scss',
24
   styleUrl: './family-edit.scss',
24
 })
25
 })
25
-export class FamilyEdit {
26
+export class FamilyEdit implements OnInit{
26
   danka: Danka | undefined;
27
   danka: Danka | undefined;
27
   family: Family | undefined;
28
   family: Family | undefined;
28
   families: Family[] = [];
29
   families: Family[] = [];
40
     private route: ActivatedRoute,
41
     private route: ActivatedRoute,
41
     private router: Router,
42
     private router: Router,
42
   ) {
43
   ) {
44
+  }
45
+
46
+  ngOnInit(): void {
47
+    this.init();
48
+  }
49
+
50
+  async init(): Promise<void> {
43
     this.dankaId = this.route.snapshot.params['dankaId'];
51
     this.dankaId = this.route.snapshot.params['dankaId'];
44
     this.familyId = this.route.snapshot.params['familyId'];
52
     this.familyId = this.route.snapshot.params['familyId'];
45
-    this.danka = this.dankaService.getDankaById(this.dankaId);
46
-    this.families = this.familyService.getFamiliesByDankaId(this.dankaId);
53
+
47
     this.relationMode = this.route.snapshot.queryParamMap.get('relationMode') ?? '';
54
     this.relationMode = this.route.snapshot.queryParamMap.get('relationMode') ?? '';
48
     this.baseFamilyId = this.route.snapshot.queryParamMap.get('baseFamilyId') ?? '';
55
     this.baseFamilyId = this.route.snapshot.queryParamMap.get('baseFamilyId') ?? '';
56
+
57
+    // ★ここが重要
58
+    this.danka = await this.dankaService.getDankaById(this.dankaId);
59
+    this.families = await this.familyService.getFamiliesByDankaId(this.dankaId);
60
+
49
     if (this.familyId) {
61
     if (this.familyId) {
50
-      this.family = this.familyService.getFamilyById(this.familyId);
62
+      this.family = await this.familyService.getFamilyById(this.familyId);
63
+
51
       if (this.family) {
64
       if (this.family) {
52
         this.familyForm.patchValue({
65
         this.familyForm.patchValue({
53
           furigana: this.family.furigana,
66
           furigana: this.family.furigana,
60
           spouseId: this.family.spouseId,
73
           spouseId: this.family.spouseId,
61
           gender: this.family.gender,
74
           gender: this.family.gender,
62
         });
75
         });
76
+
63
         this.patchMarriageRelationFields(this.family.id);
77
         this.patchMarriageRelationFields(this.family.id);
64
       }
78
       }
65
     }
79
     }
72
     }
86
     }
73
 
87
 
74
     if (!this.familyId && this.relationMode === 'child') {
88
     if (!this.familyId && this.relationMode === 'child') {
75
-      const baseFamily = this.familyService.getFamilyById(this.baseFamilyId);
89
+      const baseFamily = await this.familyService.getFamilyById(this.baseFamilyId);
76
 
90
 
77
       if (baseFamily?.gender === 'male') {
91
       if (baseFamily?.gender === 'male') {
78
         this.familyForm.patchValue({
92
         this.familyForm.patchValue({

+ 22
- 23
src/app/pages/kakocho-edit/kakocho-edit.ts Zobrazit soubor

1
-import { Component } from '@angular/core';
1
+import { Component, OnInit } from '@angular/core';
2
 import {
2
 import {
3
   FormBuilder,
3
   FormBuilder,
4
   FormGroup,
4
   FormGroup,
32
   templateUrl: './kakocho-edit.html',
32
   templateUrl: './kakocho-edit.html',
33
   styleUrl: './kakocho-edit.scss',
33
   styleUrl: './kakocho-edit.scss',
34
 })
34
 })
35
-export class KakochoEdit {
35
+export class KakochoEdit implements OnInit {
36
   danka?: Danka;
36
   danka?: Danka;
37
   kakocho?: Kakocho;
37
   kakocho?: Kakocho;
38
   sourceFamily?: Family;
38
   sourceFamily?: Family;
48
     private route: ActivatedRoute,
48
     private route: ActivatedRoute,
49
     private router: Router,
49
     private router: Router,
50
   ) {
50
   ) {
51
-
52
-    // フォーム初期化
53
     this.kakochoForm = this.fb.group({
51
     this.kakochoForm = this.fb.group({
54
       name: ['', Validators.required],
52
       name: ['', Validators.required],
55
       furigana: [''],
53
       furigana: [''],
59
       ageAtDeath: [''],
57
       ageAtDeath: [''],
60
       note: [''],
58
       note: [''],
61
     });
59
     });
60
+  }
61
+
62
+  ngOnInit(): void {
63
+    this.init();
64
+  }
62
 
65
 
63
-    // 檀家ID
66
+  async init(): Promise<void> {
64
     const dankaId = this.route.snapshot.params['dankaId'];
67
     const dankaId = this.route.snapshot.params['dankaId'];
65
-    this.dankaId = this.route.snapshot.params['dankaId'];
68
+    const familyId = this.route.snapshot.queryParams['familyId'];
69
+    const kakochoId = this.route.snapshot.params['kakochoId'];
70
+
71
+    this.dankaId = dankaId;
66
 
72
 
67
     if (dankaId) {
73
     if (dankaId) {
68
-      this.danka =
69
-        this.dankaService.getDankaById(dankaId);
74
+      this.danka = await this.dankaService.getDankaById(dankaId);
70
     }
75
     }
71
 
76
 
72
-    const familyId = this.route.snapshot.queryParams['familyId'];
73
     if (familyId) {
77
     if (familyId) {
74
-      this.sourceFamily = this.familyService.getFamilyById(familyId);
78
+      this.sourceFamily = await this.familyService.getFamilyById(familyId);
75
       this.returnTab = 'family';
79
       this.returnTab = 'family';
76
     }
80
     }
77
 
81
 
78
-    // 編集対象ID
79
-    const kakochoId =
80
-      this.route.snapshot.params['kakochoId'];
81
-
82
     // 編集モード
82
     // 編集モード
83
     if (kakochoId) {
83
     if (kakochoId) {
84
-
85
-      this.kakocho =
86
-        this.kakochoService.getKakochoById(kakochoId);
84
+      this.kakocho = await this.kakochoService.getKakochoById(kakochoId);
87
 
85
 
88
       if (this.kakocho) {
86
       if (this.kakocho) {
89
-
90
         this.kakochoForm.patchValue({
87
         this.kakochoForm.patchValue({
91
           name: this.kakocho.name,
88
           name: this.kakocho.name,
92
           furigana: this.kakocho.furigana,
89
           furigana: this.kakocho.furigana,
96
           ageAtDeath: this.kakocho.ageAtDeath,
93
           ageAtDeath: this.kakocho.ageAtDeath,
97
           note: this.kakocho.note,
94
           note: this.kakocho.note,
98
         });
95
         });
99
-
100
       }
96
       }
101
-    } else if (this.sourceFamily) {
97
+    }
98
+
99
+    // 新規(家族からの引き継ぎ)
100
+    else if (this.sourceFamily) {
102
       this.kakochoForm.patchValue({
101
       this.kakochoForm.patchValue({
103
         name: this.sourceFamily.name,
102
         name: this.sourceFamily.name,
104
         furigana: this.sourceFamily.furigana,
103
         furigana: this.sourceFamily.furigana,
107
     }
106
     }
108
   }
107
   }
109
 
108
 
110
-  saveKakocho(): void {
109
+  async saveKakocho(): Promise<void> {
111
 
110
 
112
     // form値取得
111
     // form値取得
113
     const formValue = this.kakochoForm.value;
112
     const formValue = this.kakochoForm.value;
120
         ...formValue,
119
         ...formValue,
121
       };
120
       };
122
 
121
 
123
-      this.kakochoService.updateKakocho(
122
+      await this.kakochoService.updateKakocho(
124
         updatedKakocho
123
         updatedKakocho
125
       );
124
       );
126
 
125
 
148
       );
147
       );
149
 
148
 
150
       if (this.sourceFamily) {
149
       if (this.sourceFamily) {
151
-        this.familyService.deleteFamily(this.sourceFamily.id);
150
+        await this.familyService.deleteFamily(this.sourceFamily.id);
152
       }
151
       }
153
     }
152
     }
154
 
153
 

Loading…
Zrušit
Uložit