summaryrefslogtreecommitdiff
path: root/app/views/nutrient_measurements
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/nutrient_measurements')
-rw-r--r--app/views/nutrient_measurements/_form.html.erb49
-rw-r--r--app/views/nutrient_measurements/index.html.erb41
-rw-r--r--app/views/nutrient_measurements/new.html.erb11
3 files changed, 101 insertions, 0 deletions
diff --git a/app/views/nutrient_measurements/_form.html.erb b/app/views/nutrient_measurements/_form.html.erb
new file mode 100644
index 0000000..9689c57
--- /dev/null
+++ b/app/views/nutrient_measurements/_form.html.erb
@@ -0,0 +1,49 @@
+<%= form_with(model: nutrient_measurement) do |form| %>
+ <% if nutrient_measurement.errors.any? %>
+ <div class="alert alert-danger">
+ <p class="mb-1"><strong><%= pluralize(nutrient_measurement.errors.count, "erreur") %></strong> empêchent l’enregistrement :</p>
+ <ul class="mb-0">
+ <% nutrient_measurement.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="mb-3">
+ <%= form.label :measured_on, "Date du relevé", class: "form-label" %>
+ <%= form.date_field :measured_on, class: "form-control", required: true %>
+ </div>
+
+ <h2 class="h6 mt-4 mb-2">Concentrations de nutriments — laisser vide si non mesuré</h2>
+
+ <div class="row g-2">
+ <% # You can reorganize into macros/micros if you prefer %>
+ <% labels = {
+ nno3: "Nitrate (N-NO₃)", p: "Phosphore (P)", k: "Potassium (K)",
+ ca: "Calcium (Ca)", mg: "Magnésium (Mg)", s: "Soufre (S)",
+ na: "Sodium (Na)", cl: "Chlore (Cl)", si: "Silicium (Si)",
+ fe: "Fer (Fe)", zn: "Zinc (Zn)", b: "Bore (B)",
+ mn: "Manganèse (Mn)", cu: "Cuivre (Cu)", mo: "Molybdène (Mo)",
+ nnh4: "Ammonium (N-NH₄)"
+ } %>
+
+ <% NutrientMeasurement::NUTRIENT_FIELDS.each do |field| %>
+ <div class="col-6 col-md-3">
+ <div class="input-group">
+ <%= form.number_field field,
+ class: "form-control",
+ placeholder: "—",
+ step: "0.01",
+ min: "0" %>
+ <span class="input-group-text">mg/L</span>
+ </div>
+ <label class="form-label d-block small text-muted mt-1"><%= labels[field] %></label>
+ </div>
+ <% end %>
+ </div>
+
+ <div>
+ <%= form.submit "Ajouter le relevé", class: "btn btn-primary" %>
+ </div>
+<% end %>
diff --git a/app/views/nutrient_measurements/index.html.erb b/app/views/nutrient_measurements/index.html.erb
new file mode 100644
index 0000000..c01d0cc
--- /dev/null
+++ b/app/views/nutrient_measurements/index.html.erb
@@ -0,0 +1,41 @@
+<% content_for :title, "Liste des Relevé" %>
+
+<h1 class="display-1">Liste des Relevés</h1>
+
+<div class="d-flex justify-content-between align-items-center mb-3">
+ <div class="btn-group">
+ <%= link_to "Nouvelle mesure", new_nutrient_measurement_path, class: "btn btn-primary" %>
+ <%= link_to "Retour", root_path, class: "btn btn-outline-secondary" %>
+ </div>
+</div>
+
+<div class="table-responsive">
+ <table class="table table-sm table-striped table-hover align-middle table-nutrient mb-0">
+ <thead class="table-light">
+ <tr>
+ <th>Date</th>
+ <th class="text-end" title="Total N = NO₃-N + NH₄-N">N (total)</th>
+ <th class="text-end">P</th>
+ <th class="text-end">K</th>
+ <th class="text-end" title="Ammonia nitrogen">NH₄-N</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @nutrient_measurements.each do |m| %>
+ <tr>
+ <td><%= l(m.measured_on) %></td>
+ <td class="text-end">
+ <%= number_with_precision(m.nno3.to_f + m.nnh4.to_f, precision: 2) if m.nno3 || m.nnh4 %>
+ </td>
+ <td class="text-end"><%= number_with_precision(m.p, precision: 2) if m.p %></td>
+ <td class="text-end"><%= number_with_precision(m.k, precision: 2) if m.k %></td>
+ <td class="text-end"><%= number_with_precision(m.nnh4, precision: 2) if m.nnh4 %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+</div>
+
+<%= line_chart @npk_measurement_data,
+ title: "NPK",
+ ytitle: "Concentration (mg/L)" %>
diff --git a/app/views/nutrient_measurements/new.html.erb b/app/views/nutrient_measurements/new.html.erb
new file mode 100644
index 0000000..82a913e
--- /dev/null
+++ b/app/views/nutrient_measurements/new.html.erb
@@ -0,0 +1,11 @@
+<% content_for :title, "Ajouter un Relevé" %>
+
+<h1 class="display-1">Ajouter un Relevé</h1>
+
+<%= render "form", nutrient_measurement: @nutrient_measurement %>
+
+<br>
+
+<div>
+ <%= link_to "Retour", root_path, class: "btn btn-secondary" %>
+</div>
Copyright 2019--2025 Marius PETER