From 7116826b854188604e21e2a613ac6672b6fd81f3 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 8 Sep 2025 21:21:56 +0200 Subject: Create Target and nutrient target table on dashboard. --- .../dashboard/_nutrient_target_table.html.erb | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 app/views/dashboard/_nutrient_target_table.html.erb (limited to 'app/views/dashboard/_nutrient_target_table.html.erb') diff --git a/app/views/dashboard/_nutrient_target_table.html.erb b/app/views/dashboard/_nutrient_target_table.html.erb new file mode 100644 index 0000000..7cf294c --- /dev/null +++ b/app/views/dashboard/_nutrient_target_table.html.erb @@ -0,0 +1,74 @@ +
+
+

Complémentation

+
+ <%= link_to "Nouvelle cible", new_target_path, class: "btn btn-sm btn-primary" %> + <%= link_to "Voir la recette", root_path, class: "btn btn-sm btn-secondary" %> +
+
+ +
+
+ + + + + + + + + + + <% wr = @weighted || {} %> + <% lm = @latest_measurements || {} %> + + <% keys = (wr.keys + lm.keys).map(&:to_s).uniq.sort %> + <% keys.each do |nut| %> + <% measured = lm[nut] %> + <% target = wr[nut] %> + <% delta = (measured.to_f - target.to_f) if measured || target %> + + + + + + + + + + <% end %> + +
NutrimentRelevéCibleDelta
<%= nut.upcase %> + <% if measured.nil? %> + + <% else %> + <%= number_with_precision(measured, precision: 2) %> + <% end %> + + <% if target.nil? %> + + <% else %> + <%= number_with_precision(target, precision: 2) %> + <% end %> + + <% if measured.nil? && target.nil? %> + + <% else %> + <% badge = + if delta.nil? + "text-bg-secondary" + elsif delta.abs <= 0.01 + "text-bg-success" + elsif delta > 0 + "text-bg-warning" + else + "text-bg-danger" + end %> + + <%= number_with_precision(delta.to_f, precision: 2) %> + + <% end %> +
+
+
+
-- cgit v1.2.3