Kaynağa Gözat

[update]

ダッシュボードを修正
poohr 3 hafta önce
ebeveyn
işleme
8c5b2e22e5

+ 5
- 3
src/app/pages/dashboard/dashboard.html Dosyayı Görüntüle

9
         <div>
9
         <div>
10
           <h1>ホーム</h1>
10
           <h1>ホーム</h1>
11
         </div>
11
         </div>
12
-        <div class="date-pill">2026年5月28日 木曜日</div>
12
+        <div class="date-pill">{{ todayLabel }}</div>
13
       </div>
13
       </div>
14
 
14
 
15
       <section class="overview" aria-label="概要">
15
       <section class="overview" aria-label="概要">
16
-        <a class="card primary" href="#">
16
+        <a class="card" href="#">
17
           <div class="card-label">今週の法要</div>
17
           <div class="card-label">今週の法要</div>
18
           <div class="metric"><strong>{{ weeklyMemorialCount }}</strong><span>件</span></div>
18
           <div class="metric"><strong>{{ weeklyMemorialCount }}</strong><span>件</span></div>
19
           <p class="card-text">
19
           <p class="card-text">
34
           <input
34
           <input
35
             class="search-input"
35
             class="search-input"
36
             type="search"
36
             type="search"
37
+            [(ngModel)]="searchKeyword"
37
             placeholder="氏名、ふりがな、住所、戒名で検索"
38
             placeholder="氏名、ふりがな、住所、戒名で検索"
38
             aria-label="まとめて検索"
39
             aria-label="まとめて検索"
40
+            (keydown.enter)="searchAll()"
39
           />
41
           />
40
-          <button class="search-button" type="button">検索</button>
42
+          <button class="search-button" type="button" (click)="searchAll()">検索</button>
41
         </div>
43
         </div>
42
       </section>
44
       </section>
43
 
45
 

+ 28
- 7
src/app/pages/dashboard/dashboard.ts Dosyayı Görüntüle

1
 import { Component } from '@angular/core';
1
 import { Component } from '@angular/core';
2
-import { RouterLink } from '@angular/router';
2
+import { Router, RouterLink } from '@angular/router';
3
+import { FormsModule } from '@angular/forms';
3
 import { KakochoService } from '../../services/kakocho-service';
4
 import { KakochoService } from '../../services/kakocho-service';
4
 import { DankaService } from '../../services/dankaService';
5
 import { DankaService } from '../../services/dankaService';
5
 import { Danka } from '../../models/danka';
6
 import { Danka } from '../../models/danka';
25
 
26
 
26
 @Component({
27
 @Component({
27
   selector: 'app-dashboard',
28
   selector: 'app-dashboard',
28
-  imports: [AppHeader, AppSideMenu, RouterLink],
29
+  imports: [AppHeader, AppSideMenu, RouterLink, FormsModule],
29
   templateUrl: './dashboard.html',
30
   templateUrl: './dashboard.html',
30
   styleUrl: './dashboard.scss',
31
   styleUrl: './dashboard.scss',
31
 })
32
 })
32
 export class Dashboard {
33
 export class Dashboard {
34
+  searchKeyword = '';
35
+  todayLabel = this.formatTodayLabel(new Date());
33
   weeklyMemorialCount = 0;
36
   weeklyMemorialCount = 0;
34
   todayMemorialCount = 0;
37
   todayMemorialCount = 0;
35
   upcomingWeeklyMemorialCount = 0;
38
   upcomingWeeklyMemorialCount = 0;
42
   constructor(
45
   constructor(
43
     private kakochoService: KakochoService,
46
     private kakochoService: KakochoService,
44
     private dankaService: DankaService,
47
     private dankaService: DankaService,
48
+    private router: Router,
45
   ) {
49
   ) {
46
     this.setWeeklyMemorialSummary();
50
     this.setWeeklyMemorialSummary();
47
     this.setMonthlyMemorialSummary();
51
     this.setMonthlyMemorialSummary();
49
     this.setUpcomingMemorials();
53
     this.setUpcomingMemorials();
50
   }
54
   }
51
 
55
 
56
+  searchAll(): void {
57
+    const keyword = this.searchKeyword.trim();
58
+
59
+    this.router.navigate(['/search'], {
60
+      queryParams: keyword ? { keyword } : undefined,
61
+    });
62
+  }
63
+
52
   private async setRecentDankaList(): Promise<void> {
64
   private async setRecentDankaList(): Promise<void> {
53
     const dankaList = await this.dankaService.getRecentDankaList(5);
65
     const dankaList = await this.dankaService.getRecentDankaList(5);
54
 
66
 
104
     const today = this.toDateOnly(new Date());
116
     const today = this.toDateOnly(new Date());
105
     const endDate = this.addDays(today, 30);
117
     const endDate = this.addDays(today, 30);
106
 
118
 
107
-    this.upcomingMemorials = (await this.kakochoService
108
-      .getKakochoList())
109
-      .map((kakocho): UpcomingMemorial | null => {
119
+    const upcomingMemorials = await Promise.all(
120
+      (await this.kakochoService
121
+        .getKakochoList())
122
+        .map(async (kakocho): Promise<UpcomingMemorial | null> => {
110
         const deathDate = this.parseDate(kakocho.deathDate);
123
         const deathDate = this.parseDate(kakocho.deathDate);
111
         if (!deathDate) {
124
         if (!deathDate) {
112
           return null;
125
           return null;
118
         }
131
         }
119
 
132
 
120
         const memorialType = this.getMemorialType(deathDate);
133
         const memorialType = this.getMemorialType(deathDate);
121
-        const danka = this.dankaService.getDankaById(kakocho.dankaId);
134
+        const danka = await this.dankaService.getDankaById(kakocho.dankaId);
122
         const type = memorialType ? '年忌法要' : '命日';
135
         const type = memorialType ? '年忌法要' : '命日';
123
         const status = memorialType ? '準備確認' : '要確認';
136
         const status = memorialType ? '準備確認' : '要確認';
124
 
137
 
132
           type,
145
           type,
133
           status,
146
           status,
134
         };
147
         };
135
-      })
148
+      }),
149
+    );
150
+
151
+    this.upcomingMemorials = upcomingMemorials
136
       .filter((memorial): memorial is UpcomingMemorial => memorial !== null)
152
       .filter((memorial): memorial is UpcomingMemorial => memorial !== null)
137
       .sort((a, b) => a.date.getTime() - b.date.getTime() || a.title.localeCompare(b.title, 'ja'))
153
       .sort((a, b) => a.date.getTime() - b.date.getTime() || a.title.localeCompare(b.title, 'ja'))
138
       .slice(0, 3);
154
       .slice(0, 3);
219
     return `${updatedDate.getMonth() + 1}月${updatedDate.getDate()}日`;
235
     return `${updatedDate.getMonth() + 1}月${updatedDate.getDate()}日`;
220
   }
236
   }
221
 
237
 
238
+  private formatTodayLabel(date: Date): string {
239
+    const weekdays = ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'];
240
+    return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日 ${weekdays[date.getDay()]}`;
241
+  }
242
+
222
   private getWeekStart(date: Date): Date {
243
   private getWeekStart(date: Date): Date {
223
     const day = date.getDay();
244
     const day = date.getDay();
224
     const diff = day === 0 ? -6 : 1 - day;
245
     const diff = day === 0 ? -6 : 1 - day;

+ 8
- 1
src/app/pages/search/search.ts Dosyayı Görüntüle

1
 import { Component, OnInit } from '@angular/core';
1
 import { Component, OnInit } from '@angular/core';
2
 import { FormBuilder, FormsModule } from '@angular/forms';
2
 import { FormBuilder, FormsModule } from '@angular/forms';
3
-import { Router, RouterLink } from '@angular/router';
3
+import { ActivatedRoute, Router, RouterLink } from '@angular/router';
4
 import { Danka } from '../../models/danka';
4
 import { Danka } from '../../models/danka';
5
 import { Family } from '../../models/family';
5
 import { Family } from '../../models/family';
6
 import { Kakocho } from '../../models/kakocho';
6
 import { Kakocho } from '../../models/kakocho';
34
     private dankaService: DankaService,
34
     private dankaService: DankaService,
35
     private familyService: FamilyService,
35
     private familyService: FamilyService,
36
     private kakochoService: KakochoService,
36
     private kakochoService: KakochoService,
37
+    private route: ActivatedRoute,
37
   ) { }
38
   ) { }
38
 
39
 
39
   ngOnInit(): void {
40
   ngOnInit(): void {
41
+    const keyword = this.route.snapshot.queryParamMap.get('keyword');
42
+
43
+    if (keyword) {
44
+      this.searchKeyword = keyword;
45
+      this.searchAll();
46
+    }
40
   }
47
   }
41
 
48
 
42
   // フィルタータブの選択処理
49
   // フィルタータブの選択処理

Loading…
İptal
Kaydet