aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Étienne Deparis 2022-07-12 19:23:24 +0200
committerGravatar Étienne Deparis 2022-07-12 19:25:46 +0200
commit5be899ccfee5a5a7f46ea2228b0cd606e33bed9e (patch)
tree4ad8daeef3c0f44d5bdadd34f6051ca80caee276
parent58adccde492ee6ebd9ec9ee43e7d1cd48e734d86 (diff)
downloadbiberons-5be899ccfee5a5a7f46ea2228b0cd606e33bed9e.tar.gz
biberons-5be899ccfee5a5a7f46ea2228b0cd606e33bed9e.tar.xz
biberons-5be899ccfee5a5a7f46ea2228b0cd606e33bed9e.zip
feat: Add breastfeeding related columns and checkboxes
-rw-r--r--db/migrations/202207121918_add_breast_feeding.rb10
-rw-r--r--lib/biberon.rb8
-rw-r--r--lib/biberon/models/biberon.rb3
-rw-r--r--locales/en.yml7
-rw-r--r--locales/fr.yml8
-rw-r--r--views/baby.slim23
-rw-r--r--views/settings.slim6
7 files changed, 58 insertions, 7 deletions
diff --git a/db/migrations/202207121918_add_breast_feeding.rb b/db/migrations/202207121918_add_breast_feeding.rb
new file mode 100644
index 0000000..987576e
--- /dev/null
+++ b/db/migrations/202207121918_add_breast_feeding.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+Sequel.migration do
+ change do
+ alter_table :biberons do
+ add_column :left_breast, TrueClass
+ add_column :right_breast, TrueClass
+ end
+ end
+end
diff --git a/lib/biberon.rb b/lib/biberon.rb
index 56956cc..94bc04f 100644
--- a/lib/biberon.rb
+++ b/lib/biberon.rb
@@ -29,7 +29,7 @@ module Biberon
@_cookie = parse_cookie
R18n.set cookie('l', 'fr')
- @settings = cookie('c', 'c,t,u,v,w').split(',')
+ @settings = cookie('c', 'c,t,u,v,w,l,r').split(',')
r.root do
r.redirect "/#{session['baby_id']}" if session['baby_id']
@@ -66,7 +66,8 @@ module Biberon
settings << "l:#{params['lang']}"
end
opts = []
- ['comment', 'temp', 'urines', 'vitamind', 'weight'].each do |opt_name|
+ ['comment', 'temp', 'urines', 'vitamind', 'weight',
+ 'left_breast', 'right_breast'].each do |opt_name|
opts << opt_name[0] if params[opt_name]
end
settings << "c:#{opts.join(',')}"
@@ -106,7 +107,8 @@ module Biberon
bib.set_fields(
params,
['baby_id', 'quantity', 'weight', 'comment',
- 'feces', 'urines', 'vitamind', 'temperature']
+ 'feces', 'urines', 'vitamind', 'temperature',
+ 'left_breast', 'right_breast']
)
bib.datetime = DateTime.strptime(
"#{params['date']} #{params['time']}",
diff --git a/lib/biberon/models/biberon.rb b/lib/biberon/models/biberon.rb
index df38469..b55015c 100644
--- a/lib/biberon/models/biberon.rb
+++ b/lib/biberon/models/biberon.rb
@@ -10,7 +10,8 @@ module Biberon
super
errors.add(:baby, R18n.t.biberon.validations.baby) if baby.nil?
comment = nil if comment&.strip == ''
- one_off = [quantity, temperature, weight, comment].compact
+ one_off = [quantity, temperature, weight, comment,
+ left_breast, right_breast].compact
return unless one_off.empty?
errors.add(:quantity, R18n.t.biberon.validations.quantity)
end
diff --git a/locales/en.yml b/locales/en.yml
index 75e5cd5..ca57729 100644
--- a/locales/en.yml
+++ b/locales/en.yml
@@ -17,6 +17,10 @@ biberon:
vitamind: Vitamin D
weight: Weight
comment: Comment
+ lbreast: L.
+ left_breast: Left breast
+ rbreast: R.
+ right_breast: Right breast
actions: Actions
total_of_day: Total of day
tomorrow: Tomorrow
@@ -25,7 +29,8 @@ biberon:
show_graph: Show graph
validations:
baby: is not set
- quantity: cannot be empty if temperature, weight or comment are empty too
+ quantity: cannot be empty if temperature, weight, left or right
+ breast or comment are empty too
graph:
back_to_bibs: Back to measures
settings:
diff --git a/locales/fr.yml b/locales/fr.yml
index ddc975b..6fe0b44 100644
--- a/locales/fr.yml
+++ b/locales/fr.yml
@@ -17,6 +17,10 @@ biberon:
vitamind: Vitamine D
weight: Poids
comment: Observations
+ lbreast: G.
+ left_breast: Sein gauche
+ rbreast: D.
+ right_breast: Sein droit
actions: Actions
total_of_day: Total du jour
tomorrow: Demain
@@ -25,8 +29,8 @@ biberon:
show_graph: Afficher le graphique
validations:
baby: n’est pas présent
- quantity: ne peut pas être vide si Température, Poids ou Observations
- sont également vides
+ quantity: ne peut pas être vide si Température, Poids, Sein gauche
+ ou droit ou Observations sont également vides
graph:
back_to_bibs: Retour aux mesures
settings:
diff --git a/views/baby.slim b/views/baby.slim
index 52b2b42..9e5e6f9 100644
--- a/views/baby.slim
+++ b/views/baby.slim
@@ -20,6 +20,10 @@ table.biblist
thead
tr
th = R18n.t.biberon.hour
+ - if @settings.include?('l')
+ th = R18n.t.biberon.lbreast
+ - if @settings.include?('r')
+ th = R18n.t.biberon.rbreast
th = R18n.t.biberon.quantity
- if @settings.include?('t')
th = R18n.t.biberon.temp
@@ -37,6 +41,14 @@ table.biblist
- @baby.bibs_of_day(@today).each do |bib|
tr
td = bib.hour
+ - if @settings.include?('l')
+ td
+ - if bib.left_breast
+ | ✅
+ - if @settings.include?('r')
+ td
+ - if bib.right_breast
+ | ✅
td = bib.quantity
- if @settings.include?('t')
td = bib.temperature
@@ -93,6 +105,17 @@ form action="/#{@baby.id}/add" method='post'
= R18n.t.biberon.hour
input#time type='time' name='time' value=DateTime.now.strftime('%H:%M')
+ .row
+ - if @settings.include?('l')
+ .column.column-50
+ input#leftbreast type='checkbox' name='left_breast'
+ label.label-inline for='leftbreast' = R18n.t.biberon.left_breast
+
+ - if @settings.include?('r')
+ .column.column-50
+ input#rightbreast type='checkbox' name='right_breast'
+ label.label-inline for='rightbreast' = R18n.t.biberon.right_breast
+
label for='quantity'
' 🍼
= R18n.t.biberon.quantity
diff --git a/views/settings.slim b/views/settings.slim
index cf74d5a..86ad3d6 100644
--- a/views/settings.slim
+++ b/views/settings.slim
@@ -12,6 +12,12 @@ form action='/settings' method='post'
fieldset
legend = R18n.t.settings.columns
+ input#leftbreast type='checkbox' name='left_breast' checked=@settings.include?('l')
+ label.label-inline for='leftbreast' = R18n.t.biberon.left_breast
+ br
+ input#rightbreast type='checkbox' name='right_breast' checked=@settings.include?('r')
+ label.label-inline for='rightbreast' = R18n.t.biberon.right_breast
+ br
input#comment type='checkbox' name='comment' checked=@settings.include?('c')
label.label-inline for='comment' = R18n.t.biberon.comment
br