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