localize mood dates
This commit is contained in:
parent
ad1b1e1c6b
commit
13e2e49279
2 changed files with 4 additions and 5 deletions
|
|
@ -16,14 +16,14 @@ class Mood < ApplicationRecord
|
||||||
mood_range = Mood.order(:recorded_at).where(recorded_at: (first_monday..to))
|
mood_range = Mood.order(:recorded_at).where(recorded_at: (first_monday..to))
|
||||||
mood_range.each do |mood|
|
mood_range.each do |mood|
|
||||||
while current_date < mood.recorded_at.to_date do
|
while current_date < mood.recorded_at.to_date do
|
||||||
log_mood << [ current_date.to_s, current_mode ]
|
log_mood << [ current_date, current_mode ]
|
||||||
current_date += 1
|
current_date += 1
|
||||||
end
|
end
|
||||||
current_mode = mood.mode
|
current_mode = mood.mode
|
||||||
end
|
end
|
||||||
|
|
||||||
while current_date <= to.to_date do
|
while current_date <= to.to_date do
|
||||||
log_mood << [ current_date.to_s, current_mode ]
|
log_mood << [ current_date, current_mode ]
|
||||||
current_date += 1
|
current_date += 1
|
||||||
end
|
end
|
||||||
log_mood.each_slice(7).to_a
|
log_mood.each_slice(7).to_a
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,14 @@
|
||||||
<% @mood_log.each do |week| %>
|
<% @mood_log.each do |week| %>
|
||||||
<div class="is-flex is-flex-direction-column is-flex-wrap-wrap mb-3">
|
<div class="is-flex is-flex-direction-column is-flex-wrap-wrap mb-3">
|
||||||
<div class="is-size-7 day">
|
<div class="is-size-7 day">
|
||||||
<% day = Date.parse(week.first[0]) %>
|
<% day = week.first[0] %>
|
||||||
<% if day.day < 8 && day.monday? %>
|
<% if day.day < 8 && day.monday? %>
|
||||||
<%= l(day, format: "%b") %>
|
<%= l(day, format: "%b") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% week.each do |d| %>
|
<% week.each do |d| %>
|
||||||
<% day = Date.parse(d[0]) %>
|
|
||||||
<% if d[1] %>
|
<% if d[1] %>
|
||||||
<div data-image="<%= asset_path(d[1] + ".jpg") %>" data-mode="<%= d[1] %>" data-day="<%= d[0] %>" data-action="click->mood#updateDayInfo mouseover->mood#updateDayInfo mouseleave->mood#updateDayInfo" title="<%= d[0] %> : <%= d[1] %>" class="day <%= d[1] %>"></div>
|
<div data-image="<%= asset_path(d[1] + ".jpg") %>" data-mode="<%= d[1] %>" data-day="<%= l d[0] %>" data-action="click->mood#updateDayInfo mouseover->mood#updateDayInfo mouseleave->mood#updateDayInfo" title="<%= d[0] %> : <%= d[1] %>" class="day <%= d[1] %>"></div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="day"></div>
|
<div class="day"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue