3 Incheckningar

Upphovsman SHA1 Meddelande Datum
  kuni b0224195a9 Merge branch 'master' of https://gitea.softopia.gku.ac.jp/nyoraiji/kaimyo-management 3 veckor sedan
  kuni 157806e70f added 3 veckor sedan
  kuni 57f38c65db added 3 veckor sedan

+ 13
- 5
src/app/pages/danka-edit/danka-edit.ts Visa fil

@@ -1,4 +1,4 @@
1
-import { Component, inject } from '@angular/core';
1
+import { Component, inject, OnInit } from '@angular/core';
2 2
 import {
3 3
   FormBuilder,
4 4
   FormGroup,
@@ -19,7 +19,7 @@ import { Danka } from '../../models/danka';
19 19
   templateUrl: './danka-edit.html',
20 20
   styleUrl: './danka-edit.scss',
21 21
 })
22
-export class DankaEdit {
22
+export class DankaEdit implements OnInit {
23 23
   danka: Danka | undefined;
24 24
 
25 25
   dankaForm = new FormGroup({
@@ -38,9 +38,17 @@ export class DankaEdit {
38 38
     private route: ActivatedRoute,
39 39
     private router: Router,
40 40
   ) {
41
+  }
42
+
43
+  ngOnInit(): void {
44
+    this.init();
45
+  }
46
+
47
+  async init(): Promise<void> {
41 48
     const id = this.route.snapshot.params['id'];
49
+
42 50
     if (id) {
43
-      this.danka = this.dankaService.getDankaById(id);
51
+      this.danka = await this.dankaService.getDankaById(id);
44 52
 
45 53
       if (this.danka) {
46 54
         this.dankaForm.patchValue({
@@ -60,7 +68,7 @@ export class DankaEdit {
60 68
         }
61 69
       }
62 70
     }
63
-    console.log(this.danka);
71
+
64 72
   }
65 73
 
66 74
   get phones() {
@@ -79,7 +87,7 @@ export class DankaEdit {
79 87
   }
80 88
 
81 89
   removePhone(index: number) {
82
-    if(this.phones.length > 1) {
90
+    if (this.phones.length > 1) {
83 91
       this.phones.removeAt(index);
84 92
     }
85 93
   }

+ 17
- 14
src/app/pages/family-edit/family-edit.ts Visa fil

@@ -23,7 +23,7 @@ import { MarriageRelation } from '../../models/marriage-relation';
23 23
   templateUrl: './family-edit.html',
24 24
   styleUrl: './family-edit.scss',
25 25
 })
26
-export class FamilyEdit implements OnInit{
26
+export class FamilyEdit implements OnInit {
27 27
   danka: Danka | undefined;
28 28
   family: Family | undefined;
29 29
   families: Family[] = [];
@@ -135,14 +135,13 @@ export class FamilyEdit implements OnInit{
135 135
     return this.families.filter((family) => family.id !== this.familyId);
136 136
   }
137 137
 
138
-  patchMarriageRelationFields(familyId: string): void {
139
-    const relations = this.marriageRelationService.getMarriageRelationsByFamilyId(familyId);
138
+  async patchMarriageRelationFields(familyId: string): Promise<void> {
139
+    const relations = await this.marriageRelationService.getMarriageRelationsByFamilyId(familyId);
140
+
140 141
     const relation =
141 142
       relations.find((marriageRelation) => marriageRelation.status === 'current') ?? relations[0];
142 143
 
143
-    if (!relation) {
144
-      return;
145
-    }
144
+    if (!relation) return;
146 145
 
147 146
     this.familyForm.patchValue({
148 147
       spouseId: relation.person1Id === familyId ? relation.person2Id : relation.person1Id,
@@ -150,14 +149,18 @@ export class FamilyEdit implements OnInit{
150 149
     });
151 150
   }
152 151
 
153
-  findMarriageRelation(person1Id: string, person2Id: string): MarriageRelation | undefined {
154
-    return this.marriageRelationService
155
-      .getMarriageRelationsByFamilyId(person1Id)
156
-      .find(
157
-        (relation) =>
158
-          (relation.person1Id === person1Id && relation.person2Id === person2Id) ||
159
-          (relation.person1Id === person2Id && relation.person2Id === person1Id),
160
-      );
152
+  async findMarriageRelation(
153
+    person1Id: string,
154
+    person2Id: string
155
+  ): Promise<MarriageRelation | undefined> {
156
+
157
+    const relations = await this.marriageRelationService.getMarriageRelationsByFamilyId(person1Id);
158
+
159
+    return relations.find(
160
+      (relation) =>
161
+        (relation.person1Id === person1Id && relation.person2Id === person2Id) ||
162
+        (relation.person1Id === person2Id && relation.person2Id === person1Id),
163
+    );
161 164
   }
162 165
 
163 166
   saveFamily() {

+ 1
- 1
src/app/pages/kakocho-edit/kakocho-edit.ts Visa fil

@@ -37,7 +37,7 @@ export class KakochoEdit implements OnInit {
37 37
   kakocho?: Kakocho;
38 38
   sourceFamily?: Family;
39 39
   kakochoForm: FormGroup;
40
-  dankaId: string;
40
+  dankaId: string | undefined;
41 41
   returnTab: 'family' | 'kakocho' = 'kakocho';
42 42
 
43 43
   constructor(

Laddar…
Avbryt
Spara