소스 검색

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/app/pages/dashboard/dashboard.ts
poohr 3 주 전
부모
커밋
72b3f06044
4개의 변경된 파일48개의 추가작업 그리고 39개의 파일을 삭제
  1. 13
    5
      src/app/pages/danka-edit/danka-edit.ts
  2. 11
    14
      src/app/pages/dashboard/dashboard.ts
  3. 23
    19
      src/app/pages/family-edit/family-edit.ts
  4. 1
    1
      src/app/pages/kakocho-edit/kakocho-edit.ts

+ 13
- 5
src/app/pages/danka-edit/danka-edit.ts 파일 보기

@@ -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
   }

+ 11
- 14
src/app/pages/dashboard/dashboard.ts 파일 보기

@@ -1,6 +1,5 @@
1 1
 import { Component } from '@angular/core';
2
-import { Router, RouterLink } from '@angular/router';
3
-import { FormsModule } from '@angular/forms';
2
+import { RouterLink } from '@angular/router';
4 3
 import { KakochoService } from '../../services/kakocho-service';
5 4
 import { DankaService } from '../../services/dankaService';
6 5
 import { Danka } from '../../models/danka';
@@ -116,22 +115,20 @@ export class Dashboard {
116 115
     const today = this.toDateOnly(new Date());
117 116
     const endDate = this.addDays(today, 30);
118 117
 
119
-    const upcomingMemorials = await Promise.all(
120
-      (await this.kakochoService
121
-        .getKakochoList())
122
-        .map(async (kakocho): Promise<UpcomingMemorial | null> => {
118
+    const kakochoList = await this.kakochoService.getKakochoList();
119
+
120
+    const results = await Promise.all(
121
+      kakochoList.map(async (kakocho): Promise<UpcomingMemorial | null> => {
123 122
         const deathDate = this.parseDate(kakocho.deathDate);
124
-        if (!deathDate) {
125
-          return null;
126
-        }
123
+        if (!deathDate) return null;
127 124
 
128 125
         const eventDate = new Date(this.targetYear, deathDate.getMonth(), deathDate.getDate());
129
-        if (eventDate < today || eventDate > endDate) {
130
-          return null;
131
-        }
126
+        if (eventDate < today || eventDate > endDate) return null;
132 127
 
133 128
         const memorialType = this.getMemorialType(deathDate);
129
+
134 130
         const danka = await this.dankaService.getDankaById(kakocho.dankaId);
131
+
135 132
         const type = memorialType ? '年忌法要' : '命日';
136 133
         const status = memorialType ? '準備確認' : '要確認';
137 134
 
@@ -145,10 +142,10 @@ export class Dashboard {
145 142
           type,
146 143
           status,
147 144
         };
148
-      }),
145
+      })
149 146
     );
150 147
 
151
-    this.upcomingMemorials = upcomingMemorials
148
+    this.upcomingMemorials = results
152 149
       .filter((memorial): memorial is UpcomingMemorial => memorial !== null)
153 150
       .sort((a, b) => a.date.getTime() - b.date.getTime() || a.title.localeCompare(b.title, 'ja'))
154 151
       .slice(0, 3);

+ 23
- 19
src/app/pages/family-edit/family-edit.ts 파일 보기

@@ -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,17 +149,21 @@ 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
-  saveFamily() {
166
+  async saveFamily() {
164 167
     if (this.familyForm.invalid) {
165 168
       return;
166 169
     }
@@ -187,9 +190,10 @@ export class FamilyEdit implements OnInit{
187 190
     };
188 191
 
189 192
     if (spouseId) {
190
-      const existingRelation = this.findMarriageRelation(familyId, spouseId);
191
-      const errors = this.marriageRelationService.saveMarriageRelation({
192
-        id: existingRelation?.id ?? Date.now().toString(),
193
+      const existingRelation = await this.findMarriageRelation(familyId, spouseId);
194
+
195
+      const errors = await this.marriageRelationService.saveMarriageRelation({
196
+        id: existingRelation?.id ?? crypto.randomUUID(),
193 197
         dankaId,
194 198
         person1Id: familyId,
195 199
         person2Id: spouseId,
@@ -204,7 +208,7 @@ export class FamilyEdit implements OnInit{
204 208
         return;
205 209
       }
206 210
     } else {
207
-      const currentMarriage = this.marriageRelationService.getCurrentMarriageByFamilyId(familyId);
211
+      const currentMarriage = await this.marriageRelationService.getCurrentMarriageByFamilyId(familyId);
208 212
       if (currentMarriage) {
209 213
         this.marriageRelationService.deleteMarriageRelation(currentMarriage.id);
210 214
       }

+ 1
- 1
src/app/pages/kakocho-edit/kakocho-edit.ts 파일 보기

@@ -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(

Loading…
취소
저장