Remove images inline, too
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<svg enable-background="new 0 0 24 24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m14.5 14.3h6.7c.6 0 1.1-.5 1.1-1.1v-2.3c0-.6-.5-1.1-1.1-1.1h-6.7-5-6.7c-.6 0-1.1.5-1.1 1.1v2.3c0 .6.5 1.1 1.1 1.1h6.7z"/></svg>
|
||||
|
After Width: | Height: | Size: 230 B |
@@ -19,6 +19,7 @@ class BubblesController < ApplicationController
|
||||
|
||||
def update
|
||||
@bubble.update(bubble_params)
|
||||
remove_image if params[:remove_image] == "true"
|
||||
|
||||
redirect_to bubble_path(@bubble)
|
||||
end
|
||||
@@ -38,6 +39,10 @@ class BubblesController < ApplicationController
|
||||
end
|
||||
|
||||
def bubble_params
|
||||
params.require(:bubble).permit(:title, :body, :color, :image, tag_ids: [])
|
||||
params.require(:bubble).permit(:title, :body, :color, :image, :remove_image, tag_ids: [])
|
||||
end
|
||||
|
||||
def remove_image
|
||||
@bubble.image.purge
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,12 +13,21 @@
|
||||
|
||||
<%= form_with model: bubble, data: { controller: "form" } do | form | %>
|
||||
<div class="bubble__bubble bubble__meta bubble__attachment">
|
||||
<label class="btn btn--plain input--file">
|
||||
<%= image_tag "camera.svg", aria: { hidden: "true" }, size: 20 %>
|
||||
<%= form.file_field :image, class: "input", accept: "image/*",
|
||||
data: { action: "upload-preview#previewImage change->form#submit" } %>
|
||||
<span class="for-screen-reader">Upload an image</span>
|
||||
</label>
|
||||
<% if bubble.image.attached? %>
|
||||
<%= tag.label class:"btn btn--negative", data: { action: "click->upload-preview#clear click->form#submit", upload_preview_target: "button" } do %>
|
||||
<%= image_tag "minus.svg", aria: { hidden: "true" }, size: 24 %>
|
||||
<%= form.hidden_field :bubble, value: bubble.id %>
|
||||
<%= check_box_tag "remove_image", "true" %>
|
||||
<span class="for-screen-reader">Remove imagee</span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<label class="btn btn--plain input--file">
|
||||
<%= image_tag "camera.svg", aria: { hidden: "true" }, size: 20 %>
|
||||
<%= form.file_field :image, class: "input", accept: "image/*",
|
||||
data: { action: "upload-preview#previewImage change->form#submit" } %>
|
||||
<span class="for-screen-reader">Upload an image</span>
|
||||
</label>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user