working on image feature
This commit is contained in:
@@ -20,7 +20,10 @@
|
||||
<h2>Download Backup</h2>
|
||||
<p>Download a gzip-compressed YAML backup of vehicles, users, maintenance schedules, fuel entries, and maintenance entries.</p>
|
||||
<p>Authentication data, access keys, and browser sessions are not included.</p>
|
||||
<p><%= link_to "Download backup", download_backup_path, class: "button button--primary" %></p>
|
||||
<div class="action-row">
|
||||
<%= link_to "Download data backup", download_backup_path, class: "button button--primary" %>
|
||||
<%= link_to "Download backup with images", download_with_images_backup_path, class: "button button--secondary" %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dashboard-section">
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<%= turbo_frame_tag dom_id(entry, :images) do %>
|
||||
<%= form_with url: upload_path, scope: entry.model_name.param_key, multipart: true, class: "entry-image-form" do |form| %>
|
||||
<% if entry.errors[:images].any? || entry.errors[:base].any? %>
|
||||
<div class="form-errors form-errors--compact">
|
||||
<ul>
|
||||
<% entry.errors[:base].each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
|
||||
<% entry.errors[:images].each do |message| %>
|
||||
<li>Images <%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :images, "Images" %>
|
||||
<%= form.file_field :images, multiple: true, accept: "image/jpeg,image/png", required: true %>
|
||||
</div>
|
||||
|
||||
<div class="action-row">
|
||||
<%= form.submit "Upload images", class: "button button--primary button--small" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -0,0 +1,23 @@
|
||||
<%= turbo_frame_tag dom_id(entry, :images) do %>
|
||||
<% if entry.images.attached? %>
|
||||
<div class="entry-images">
|
||||
<% entry.images.each do |image| %>
|
||||
<figure class="entry-image">
|
||||
<%= link_to rails_blob_path(image, disposition: "inline"), target: "_blank", rel: "noopener" do %>
|
||||
<%= image_tag rails_blob_path(image, disposition: "inline"), alt: image.filename.to_s, class: "entry-image__thumbnail" %>
|
||||
<% end %>
|
||||
|
||||
<figcaption><%= image.filename %></figcaption>
|
||||
|
||||
<%= button_to "Delete", delete_path_for.call(image), method: :delete, class: "button button--danger button--small" %>
|
||||
</figure>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<span>No images attached.</span>
|
||||
<% end %>
|
||||
|
||||
<p class="entry-images__actions">
|
||||
<%= link_to "Add images", add_path, class: "button button--secondary button--small" %>
|
||||
</p>
|
||||
<% end %>
|
||||
@@ -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 %>
|
||||
|
||||
Reference in New Issue
Block a user