From 46784cff449261acf92e4dc2a93570a501f4d2cb Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Tue, 25 Aug 2026 14:30:06 -0400 Subject: [PATCH] Added a today button to bring the calendar to the current day --- app/views/common/_calendar.html.erb | 35 +++++++++++++++++++++++++---- config/locales/en.yml | 1 + 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 704f865..8ba0f71 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -3,6 +3,10 @@ only_appointments = params[:only_appointments] == '1' hide_past_weeks = params[:hide_past_weeks] == '1' + # Current date context + today = User.current.today + is_current_month = (calendar.instance_variable_get(:@month) == today.month && calendar.instance_variable_get(:@year) == today.year) + # Get Redmine's configured non-working week days (e.g., ["6", "7"] for Sat/Sun) non_working_days = Setting.non_working_week_days || [] @@ -66,6 +70,25 @@
+ <% if is_current_month %> + + <% else %> + <%= link_to url_for(request.query_parameters.merge(year: today.year, month: today.month)), + class: 'button-small', + style: 'display: inline-flex; align-items: center; gap: 5px; text-decoration: none; font-weight: 600; font-size: 0.9em; padding: 4px 10px; border-radius: 3px;', + title: l(:label_today) do %> + + <%= l(:label_today,) %> + <% end %> + <% end %> +