Added eaten_at to Meal form
This commit is contained in:
parent
cdd7107567
commit
1007385e1f
@ -11,6 +11,10 @@ module BodyTrackersHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_time(t)
|
||||||
|
t.strftime("%R") if t
|
||||||
|
end
|
||||||
|
|
||||||
def unit_options
|
def unit_options
|
||||||
@project.units.map do |u|
|
@project.units.map do |u|
|
||||||
[u.shortname, u.id]
|
[u.shortname, u.id]
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
module MeasurementsHelper
|
module MeasurementsHelper
|
||||||
def format_datetime(m)
|
def format_datetime(m)
|
||||||
m.taken_at.getlocal
|
m.taken_at
|
||||||
.strftime("%F <small>%R (~#{time_ago_in_words(m.taken_at)} ago)</small>")
|
.strftime("%F <small>%R (~#{time_ago_in_words(m.taken_at)} ago)</small>")
|
||||||
.html_safe
|
.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_time(m)
|
|
||||||
m.taken_at.getlocal.strftime("%R")
|
|
||||||
end
|
|
||||||
|
|
||||||
def toggle_column_options
|
def toggle_column_options
|
||||||
disabled = []
|
disabled = []
|
||||||
enabled_quantities = @routine.quantities.to_a
|
enabled_quantities = @routine.quantities.to_a
|
||||||
|
@ -22,6 +22,20 @@ class Meal < ActiveRecord::Base
|
|||||||
self[:eaten_at].getlocal if self[:eaten_at]
|
self[:eaten_at].getlocal if self[:eaten_at]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def eaten_at_date
|
||||||
|
self.eaten_at
|
||||||
|
end
|
||||||
|
def eaten_at_date=(value)
|
||||||
|
self.eaten_at = Time.parse(value, self.eaten_at)
|
||||||
|
end
|
||||||
|
|
||||||
|
def eaten_at_time
|
||||||
|
self.eaten_at
|
||||||
|
end
|
||||||
|
def eaten_at_time=(value)
|
||||||
|
self.eaten_at = Time.parse(value, self.eaten_at)
|
||||||
|
end
|
||||||
|
|
||||||
def toggle_eaten!
|
def toggle_eaten!
|
||||||
update(eaten_at: self.eaten_at ? nil : DateTime.current)
|
update(eaten_at: self.eaten_at ? nil : DateTime.current)
|
||||||
end
|
end
|
||||||
|
@ -32,15 +32,19 @@ class Measurement < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def taken_at
|
||||||
|
self[:taken_at].getlocal if self[:taken_at]
|
||||||
|
end
|
||||||
|
|
||||||
def taken_at_date
|
def taken_at_date
|
||||||
self.taken_at.getlocal
|
self.taken_at
|
||||||
end
|
end
|
||||||
def taken_at_date=(value)
|
def taken_at_date=(value)
|
||||||
self.taken_at = Time.parse(value, self.taken_at)
|
self.taken_at = Time.parse(value, self.taken_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def taken_at_time
|
def taken_at_time
|
||||||
self.taken_at.getlocal
|
self.taken_at
|
||||||
end
|
end
|
||||||
def taken_at_time=(value)
|
def taken_at_time=(value)
|
||||||
self.taken_at = Time.parse(value, self.taken_at)
|
self.taken_at = Time.parse(value, self.taken_at)
|
||||||
|
@ -2,7 +2,18 @@
|
|||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="tabular">
|
<div class="tabular">
|
||||||
<p><%= f.text_field :notes, required: false, style: "width: 95%;" %></p>
|
<div class="splitcontent">
|
||||||
|
<div class="splitcontentleft">
|
||||||
|
<p>
|
||||||
|
<%= f.date_field :eaten_at_date, required: false %>
|
||||||
|
<%= f.time_field :eaten_at_time, value: format_time(@meal.eaten_at),
|
||||||
|
required: false, label: '' %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="splitcontentright">
|
||||||
|
<p><%= f.text_field :notes, required: false, style: "width: 95%;" %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% @meal.ingredients.each_with_index do |i, index| %>
|
<% @meal.ingredients.each_with_index do |i, index| %>
|
||||||
<table style="width:95%;">
|
<table style="width:95%;">
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= f.date_field :taken_at_date, required: true %>
|
<%= f.date_field :taken_at_date, required: true %>
|
||||||
<%= f.time_field :taken_at_time, value: format_time(@measurement), required: true,
|
<%= f.time_field :taken_at_time, value: format_time(@measurement.taken_at),
|
||||||
label: '' %>
|
required: true, label: '' %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# English strings go here for Rails i18n
|
# English strings go here for Rails i18n
|
||||||
en:
|
en:
|
||||||
body_trackers_menu_caption: 'Body trackers'
|
body_trackers_menu_caption: 'Body trackers'
|
||||||
|
field_eaten_at_date: 'Eaten at'
|
||||||
field_ingredients: 'Ingredients'
|
field_ingredients: 'Ingredients'
|
||||||
field_measurement_routine: 'Routine'
|
field_measurement_routine: 'Routine'
|
||||||
field_readouts: 'Readouts'
|
field_readouts: 'Readouts'
|
||||||
|
Reference in New Issue
Block a user