From 454dee523ec2d4edc73532814460d1e521ba396e Mon Sep 17 00:00:00 2001 From: Christoph Marzell Date: Sun, 8 Feb 2026 08:35:29 +0100 Subject: [PATCH] fix view --- app/controllers/calendar_controller.rb | 17 ++++++++++------- app/views/calendar/month.html.erb | 11 ++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/controllers/calendar_controller.rb b/app/controllers/calendar_controller.rb index 1b9e4fc..a765707 100644 --- a/app/controllers/calendar_controller.rb +++ b/app/controllers/calendar_controller.rb @@ -17,18 +17,19 @@ class CalendarController < ApplicationController first_of_month = Date.new(@year, @month, 1) last_of_month = first_of_month.end_of_month + start_date = first_of_month - (first_of_month.cwday - 1) + end_date = last_of_month + (7 - last_of_month.cwday) + @filter_typ = params[:typ] @filter_art = params[:art] - @entries = current_user.entries - .where(date: first_of_month..last_of_month) - @entries = @entries.where(praktikums_typ: @filter_typ) if @filter_typ.present? - @entries = @entries.where(entry_art: @filter_art) if @filter_art.present? - @entries = @entries.group_by { |e| e.date.to_date } + entries_scope = current_user.entries.where(date: start_date..end_date) + entries_scope = entries_scope.where(praktikums_typ: @filter_typ) if @filter_typ.present? + entries_scope = entries_scope.where(entry_art: @filter_art) if @filter_art.present? + @entries = entries_scope.group_by { |e| e.date.to_date } - puts @entries - @days = (first_of_month..last_of_month).to_a + @days = (start_date..end_date).to_a end def week @@ -47,6 +48,8 @@ class CalendarController < ApplicationController first = Date.commercial(@year, @week, 1) last = Date.commercial(@year, @week, 7) + + @filter_typ = params[:typ] @filter_art = params[:art] diff --git a/app/views/calendar/month.html.erb b/app/views/calendar/month.html.erb index a3340bc..ec4f18f 100644 --- a/app/views/calendar/month.html.erb +++ b/app/views/calendar/month.html.erb @@ -23,11 +23,11 @@ - - <% Date::ABBR_DAYNAMES.each do |day| %> - - <% end %> - + <% day_names = I18n.t("date.abbr_day_names") %> + <% monday_first = day_names.rotate(1) %> + <% monday_first.each do |day| %> + + <% end %> <% weeks = @days.in_groups_of(7, nil) %> @@ -36,6 +36,7 @@ <% week.each do |date| %>
<%= day %>
<%= day %>