2025-08-05 16:11:24 +02:00
|
|
|
module MoodsHelper
|
2026-03-21 17:35:06 +01:00
|
|
|
def day_status(mood, user)
|
|
|
|
|
return :filled if mood[:mode].present?
|
|
|
|
|
return :guessed if mood[:guess].present? && user.guess?
|
|
|
|
|
return :unknown if mood[:guess].present? && !user.guess?
|
|
|
|
|
:empty
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-26 17:17:39 +01:00
|
|
|
def mode_for(mood, user)
|
|
|
|
|
if user.guess?
|
2026-03-19 19:04:16 +01:00
|
|
|
mood[:mode] || mood[:guess] || { label: "unknown", color: "white", image_url: "unknown.jpg" }
|
2026-02-07 13:05:24 +01:00
|
|
|
else
|
2026-03-19 19:04:16 +01:00
|
|
|
mood[:mode] || { label: "unknown", color: "white", image_url: "unknown.jpg" }
|
2026-02-07 13:05:24 +01:00
|
|
|
end
|
|
|
|
|
end
|
2026-03-14 16:35:48 +01:00
|
|
|
|
2026-03-21 17:35:06 +01:00
|
|
|
def style_for_mode(mode, status)
|
|
|
|
|
case status
|
|
|
|
|
when :empty then ""
|
|
|
|
|
when :unknown then "background-color: #{mode[:color]}; border: 2px double grey;"
|
|
|
|
|
else "background-color: #{mode[:color]};"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def css_class_for_day(status)
|
|
|
|
|
status == :empty ? "day empty-day" : "day"
|
2026-03-14 16:35:48 +01:00
|
|
|
end
|
2025-08-05 16:11:24 +02:00
|
|
|
end
|