From 568e1cb020f1bd04445737a88578fbf3a984dfe3 Mon Sep 17 00:00:00 2001 From: cavis Date: Wed, 26 Jul 2023 12:17:12 -0600 Subject: [PATCH] Don't highlight days not in current month --- app/helpers/podcast_planner_helper.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/helpers/podcast_planner_helper.rb b/app/helpers/podcast_planner_helper.rb index 11a1001e1..a93d7f9bd 100644 --- a/app/helpers/podcast_planner_helper.rb +++ b/app/helpers/podcast_planner_helper.rb @@ -46,23 +46,22 @@ def date_is_in_month?(date, month) def calendar_day_tag(day:, month:, calendar:, &block) data = {} + cls = [] + if date_is_in_month?(day, month) data[:controller] = DATE_CONTROLLER data[:action] = [TOGGLE_ACTION, RECOUNT_ACTION].join(" ") - end - is_new = date_is_in_dates?(day, @planner.dates) - is_existing = date_is_in_dates?(day, @draft_dates) - cls = + is_new = date_is_in_dates?(day, @planner.dates) + is_existing = date_is_in_dates?(day, @draft_dates) if is_new && is_existing - ["bg-danger", "text-light"] + cls = ["bg-danger", "text-light"] elsif is_new - ["bg-primary", "text-light"] + cls = ["bg-primary", "text-light"] elsif is_existing - ["bg-warning"] - else - [] + cls = ["bg-warning"] end + end content_tag(:td, class: calendar.td_classes_for(day) + cls, data: data) do block.call