working on image feature

This commit is contained in:
2026-10-01 09:56:32 -06:00
parent 7d4e446d4a
commit 23d8154f17
26 changed files with 1259 additions and 57 deletions
+38 -2
View File
@@ -103,7 +103,7 @@
<details class="dashboard-section dashboard-section--primary" open>
<summary>Record Fuel</summary>
<%= form_with model: [@vehicle, @fuel_entry], class: "stacked-form" do |form| %>
<%= form_with model: [@vehicle, @fuel_entry], class: "stacked-form", multipart: true do |form| %>
<% if @fuel_entry.errors.any? %>
<section class="form-errors">
<h3><%= pluralize(@fuel_entry.errors.count, "error") %> prevented this fuel entry from being saved</h3>
@@ -136,6 +136,11 @@
<%= form.label :date %>
<%= form.date_field :date, max: Date.current, required: true %>
</div>
<div class="field">
<%= form.label :images, "Receipt images" %>
<%= form.file_field :images, multiple: true, accept: "image/jpeg,image/png" %>
</div>
</div>
<div>
@@ -148,7 +153,7 @@
<summary>Record Maintenance</summary>
<% if @maintenance_schedules.any? %>
<%= form_with model: [@vehicle, @maintenance_entry], class: "stacked-form", data: {
<%= form_with model: [@vehicle, @maintenance_entry], class: "stacked-form", multipart: true, data: {
controller: "maintenance-odometer-warning",
maintenance_odometer_warning_current_odometer_value: @vehicle.current_odometer,
maintenance_odometer_warning_threshold_value: 500
@@ -188,6 +193,11 @@
<%= form.label :date %>
<%= form.date_field :date, max: Date.current, required: true %>
</div>
<div class="field">
<%= form.label :images, "Service images" %>
<%= form.file_field :images, multiple: true, accept: "image/jpeg,image/png" %>
</div>
</div>
<p class="field-warning" hidden data-maintenance-odometer-warning-target="warning">
@@ -305,6 +315,7 @@
<th>Odometer</th>
<th>Cost</th>
<th>Notes</th>
<th>Images</th>
<th>Updated by</th>
</tr>
</thead>
@@ -316,6 +327,18 @@
<td><%= number_with_delimiter(entry.odometer) %></td>
<td><%= number_to_currency(entry.cost) %></td>
<td><%= entry.notes %></td>
<td>
<%= turbo_frame_tag dom_id(entry, :images) do %>
<% if entry.images.attached? %>
<div class="action-row">
<%= link_to "Show images (#{entry.images.size})", images_vehicle_maintenance_entry_path(@vehicle, entry), class: "button button--secondary button--small" %>
<%= link_to "Add images", new_images_vehicle_maintenance_entry_path(@vehicle, entry), class: "button button--secondary button--small" %>
</div>
<% else %>
<%= link_to "Add images", new_images_vehicle_maintenance_entry_path(@vehicle, entry), class: "button button--secondary button--small" %>
<% end %>
<% end %>
</td>
<td><%= entry.updated_by_user.name %></td>
</tr>
<% end %>
@@ -339,6 +362,7 @@
<th>Odometer</th>
<th>Gallons</th>
<th>Price paid</th>
<th>Images</th>
<th>Updated by</th>
</tr>
</thead>
@@ -349,6 +373,18 @@
<td><%= number_with_delimiter(entry.odometer) %></td>
<td><%= entry.gallons_pumped %></td>
<td><%= number_to_currency(entry.price_paid) %></td>
<td>
<%= turbo_frame_tag dom_id(entry, :images) do %>
<% if entry.images.attached? %>
<div class="action-row">
<%= link_to "Show images (#{entry.images.size})", images_vehicle_fuel_entry_path(@vehicle, entry), class: "button button--secondary button--small" %>
<%= link_to "Add images", new_images_vehicle_fuel_entry_path(@vehicle, entry), class: "button button--secondary button--small" %>
</div>
<% else %>
<%= link_to "Add images", new_images_vehicle_fuel_entry_path(@vehicle, entry), class: "button button--secondary button--small" %>
<% end %>
<% end %>
</td>
<td><%= entry.updated_by_user.name %></td>
</tr>
<% end %>