From 85118eb89e47630392f6143d4d55422382a50608 Mon Sep 17 00:00:00 2001 From: alx Date: Tue, 18 May 2021 20:23:47 +0800 Subject: [PATCH] Add Calendar Right Side Menu: Change Day by Year --- src/BootstrapBlazor/Components/Calendar/Calendar.razor | 6 ++++++ .../Components/Calendar/Calendar.razor.cs | 8 ++++++++ .../Components/Calendar/CalendarBase.cs | 10 ++++++++++ src/BootstrapBlazor/Locales/en.json | 2 ++ src/BootstrapBlazor/Locales/zh.json | 2 ++ 5 files changed, 28 insertions(+) diff --git a/src/BootstrapBlazor/Components/Calendar/Calendar.razor b/src/BootstrapBlazor/Components/Calendar/Calendar.razor index d499eeb35..608e266aa 100644 --- a/src/BootstrapBlazor/Components/Calendar/Calendar.razor +++ b/src/BootstrapBlazor/Components/Calendar/Calendar.razor @@ -8,6 +8,9 @@
@GetTitle()
+ @@ -17,6 +20,9 @@ +
diff --git a/src/BootstrapBlazor/Components/Calendar/Calendar.razor.cs b/src/BootstrapBlazor/Components/Calendar/Calendar.razor.cs index 8b1cd63f6..e8e0affd0 100644 --- a/src/BootstrapBlazor/Components/Calendar/Calendar.razor.cs +++ b/src/BootstrapBlazor/Components/Calendar/Calendar.razor.cs @@ -16,6 +16,12 @@ namespace BootstrapBlazor.Components /// public sealed partial class Calendar { + [NotNull] + private string? PreviousYear { get; set; } + + [NotNull] + private string? NextYear { get; set; } + [NotNull] private string? PreviousMonth { get; set; } @@ -65,6 +71,8 @@ namespace BootstrapBlazor.Components protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); + PreviousYear = Localizer[nameof(PreviousYear)]; + NextYear = Localizer[nameof(NextYear)]; PreviousMonth = Localizer[nameof(PreviousMonth)]; NextMonth = Localizer[nameof(NextMonth)]; Today = Localizer[nameof(Today)]; diff --git a/src/BootstrapBlazor/Components/Calendar/CalendarBase.cs b/src/BootstrapBlazor/Components/Calendar/CalendarBase.cs index 949c596b7..747e158c7 100644 --- a/src/BootstrapBlazor/Components/Calendar/CalendarBase.cs +++ b/src/BootstrapBlazor/Components/Calendar/CalendarBase.cs @@ -93,6 +93,16 @@ namespace BootstrapBlazor.Components StateHasChanged(); }); + /// + /// 右侧快捷切换年按钮回调此方法 + /// + /// + protected void OnChangeYear(int offset) + { + if (offset == 0) Value = DateTime.Today; + else Value = Value.AddYears(offset); + } + /// /// 右侧快捷切换月按钮回调此方法 /// diff --git a/src/BootstrapBlazor/Locales/en.json b/src/BootstrapBlazor/Locales/en.json index 4f9a74c6f..c22a999d4 100644 --- a/src/BootstrapBlazor/Locales/en.json +++ b/src/BootstrapBlazor/Locales/en.json @@ -29,9 +29,11 @@ "NotFoundDevicesString": "Not found video device" }, "BootstrapBlazor.Components.Calendar": { + "PreviousYear": "Previous Year", "PreviousMonth": "Previous Month", "Today": "Today", "NextMonth": "Next Month", + "NextYear": "Next Year", "PreviousWeek": "Previous Week", "WeekText": "Week", "NextWeek": "Next Week", diff --git a/src/BootstrapBlazor/Locales/zh.json b/src/BootstrapBlazor/Locales/zh.json index af28a8a35..cb25ed36b 100644 --- a/src/BootstrapBlazor/Locales/zh.json +++ b/src/BootstrapBlazor/Locales/zh.json @@ -29,9 +29,11 @@ "NotFoundDevicesString": "未找到视频相关设备" }, "BootstrapBlazor.Components.Calendar": { + "PreviousYear": "上一年", "PreviousMonth": "上一月", "Today": "今天", "NextMonth": "下一月", + "NextYear": "下一年", "PreviousWeek": "上一周", "WeekText": "本周", "NextWeek": "下一周", -- Gitee