working on image feature
This commit is contained in:
@@ -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 %>
|
||||
Reference in New Issue
Block a user