|
|
@@ -25,11 +25,13 @@ interface RecentDanka {
|
|
25
|
25
|
|
|
26
|
26
|
@Component({
|
|
27
|
27
|
selector: 'app-dashboard',
|
|
28
|
|
- imports: [AppHeader, AppSideMenu, RouterLink],
|
|
|
28
|
+ imports: [AppHeader, AppSideMenu, RouterLink, FormsModule],
|
|
29
|
29
|
templateUrl: './dashboard.html',
|
|
30
|
30
|
styleUrl: './dashboard.scss',
|
|
31
|
31
|
})
|
|
32
|
32
|
export class Dashboard {
|
|
|
33
|
+ searchKeyword = '';
|
|
|
34
|
+ todayLabel = this.formatTodayLabel(new Date());
|
|
33
|
35
|
weeklyMemorialCount = 0;
|
|
34
|
36
|
todayMemorialCount = 0;
|
|
35
|
37
|
upcomingWeeklyMemorialCount = 0;
|
|
|
@@ -42,6 +44,7 @@ export class Dashboard {
|
|
42
|
44
|
constructor(
|
|
43
|
45
|
private kakochoService: KakochoService,
|
|
44
|
46
|
private dankaService: DankaService,
|
|
|
47
|
+ private router: Router,
|
|
45
|
48
|
) {
|
|
46
|
49
|
this.setWeeklyMemorialSummary();
|
|
47
|
50
|
this.setMonthlyMemorialSummary();
|
|
|
@@ -49,6 +52,14 @@ export class Dashboard {
|
|
49
|
52
|
this.setUpcomingMemorials();
|
|
50
|
53
|
}
|
|
51
|
54
|
|
|
|
55
|
+ searchAll(): void {
|
|
|
56
|
+ const keyword = this.searchKeyword.trim();
|
|
|
57
|
+
|
|
|
58
|
+ this.router.navigate(['/search'], {
|
|
|
59
|
+ queryParams: keyword ? { keyword } : undefined,
|
|
|
60
|
+ });
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
52
|
63
|
private async setRecentDankaList(): Promise<void> {
|
|
53
|
64
|
const dankaList = await this.dankaService.getRecentDankaList(5);
|
|
54
|
65
|
|
|
|
@@ -136,10 +147,7 @@ export class Dashboard {
|
|
136
|
147
|
|
|
137
|
148
|
this.upcomingMemorials = results
|
|
138
|
149
|
.filter((memorial): memorial is UpcomingMemorial => memorial !== null)
|
|
139
|
|
- .sort((a, b) =>
|
|
140
|
|
- a.date.getTime() - b.date.getTime() ||
|
|
141
|
|
- a.title.localeCompare(b.title, 'ja')
|
|
142
|
|
- )
|
|
|
150
|
+ .sort((a, b) => a.date.getTime() - b.date.getTime() || a.title.localeCompare(b.title, 'ja'))
|
|
143
|
151
|
.slice(0, 3);
|
|
144
|
152
|
}
|
|
145
|
153
|
|
|
|
@@ -224,6 +232,11 @@ export class Dashboard {
|
|
224
|
232
|
return `${updatedDate.getMonth() + 1}月${updatedDate.getDate()}日`;
|
|
225
|
233
|
}
|
|
226
|
234
|
|
|
|
235
|
+ private formatTodayLabel(date: Date): string {
|
|
|
236
|
+ const weekdays = ['日曜日', '月曜日', '火曜日', '水曜日', '木曜日', '金曜日', '土曜日'];
|
|
|
237
|
+ return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日 ${weekdays[date.getDay()]}`;
|
|
|
238
|
+ }
|
|
|
239
|
+
|
|
227
|
240
|
private getWeekStart(date: Date): Date {
|
|
228
|
241
|
const day = date.getDay();
|
|
229
|
242
|
const diff = day === 0 ? -6 : 1 - day;
|