Remove images single uploads

This commit is contained in:
Senén Rodero Rodríguez
2017-09-27 10:41:48 +02:00
parent 45f34540ae
commit eef8ad1b73
18 changed files with 16 additions and 510 deletions

View File

@@ -10,12 +10,6 @@
class: 'button hollow float-right' %>
<% end %>
<% if can_create_image?(investment) %>
<%= link_to t("images.upload_image"),
new_image_path(imageable_id:investment, imageable_type: investment.class.name, from: request.url),
class: 'button hollow float-right' %>
<% end %>
<% if can_destroy_image?(investment) %>
<%= link_to t("images.remove_image"),
image_path(investment.image, from: request.url),

View File

@@ -1,65 +0,0 @@
<%= form_for @image,
url: images_path(
imageable_type: @image.imageable_type,
imageable_id: @image.imageable_id,
from: params[:from]
),
html: { multipart: true, class: "imageable" } do |f| %>
<%= render 'shared/errors', resource: @image %>
<div class="row image direct-upload">
<%= f.hidden_field :cached_attachment %>
<div class="small-12 column title">
<%= f.text_field :title, placeholder: t("images.new.form.title_placeholder") %>
</div>
<%= render_image(@image, :thumb, false) if @image.attachment.exists? %>
<div class="attachment-actions">
<div class="small-6 column action-add attachment-errors">
<%= f.label :attachment, t("images.form.attachment_label"), class: 'button hollow' %>
<%= f.file_field :attachment,
accept: imageable_accepted_content_types_extensions,
label: false,
class: 'js-image-attachment',
data: {
url: direct_uploads_url("direct_upload[resource_type]": @image.imageable_type,
"direct_upload[resource_id]": @image.imageable_id,
"direct_upload[resource_relation]": "image"),
cached_attachment_input_field: "image_cached_attachment",
title_input_field: "image_title"
} %>
</div>
<div class="small-6 column action-remove text-right">
<% if @image.cached_attachment.present? %>
<%= link_to t('images.form.delete_button'),
direct_upload_destroy_url("direct_upload[resource_type]": @image.imageable_type,
"direct_upload[resource_id]": @image.imageable_id,
"direct_upload[resource_relation]": "image",
"direct_upload[cached_attachment]": @image.cached_attachment),
method: :delete,
remote: true,
class: "delete remove-cached-attachment" %>
<% end %>
</div>
</div>
<div class="small-12 column image-attachment">
<p class="file-name column">
<%= image_attachment_file_name(@image) %>
</p>
</div>
<div class="small-12 column">
<div class="progress-bar-placeholder"><div class="loading-bar"></div></div>
</div>
<div class="actions small-12 medium-6 large-4 end column">
<%= f.submit(t("images.form.submit_button"), class: "button expanded") %>
</div>
</div>
<% end %>

View File

@@ -2,7 +2,8 @@
<figure>
<%= image_tag image.attachment.url(version),
class: image_class(image),
alt: image.title %>
alt: image.title,
title: image.title %>
<% if show_caption %>
<figcaption class="text-right">
<em><%= image.title %></em>

View File

@@ -4,7 +4,7 @@
<%= f.hidden_field :cached_attachment %>
<div class="small-12 column title">
<%= f.text_field :title, placeholder: t("images.new.form.title_placeholder") %>
<%= f.text_field :title, placeholder: t("images.form.title_placeholder") %>
</div>
<%= render_image(f.object, :thumb, false) if f.object.attachment.exists? %>

View File

@@ -1,30 +0,0 @@
<div class="<%= imageable_class(@image.imageable) %>">
<div class="image-form row">
<div class="small-12 medium-9 column">
<%= back_link_to params[:from] %>
<h1><%= t("images.new.title") %></h1>
<p><%= image_note(@image) %></p>
<%= render "form", form_url: images_url %>
</div>
<div class="small-12 medium-3 column">
<span class="icon-image icon-proposals float-right"></span>
<h2><%= t("images.recommendations_title") %></h2>
<ul class="recommendations">
<li>
<%= image_first_recommendation(@image) %>
</li>
<li>
<%= t "images.recommendation_two_html",
accepted_content_types: imageable_humanized_accepted_content_types %>
</li>
<li>
<%= t "images.recommendation_three_html",
max_file_size: imageable_max_file_size %>
</li>
</ul>
</div>
</div>
</div>

View File

@@ -109,7 +109,7 @@
<aside class="small-12 medium-3 column">
<% if can_create_document?(@proposal) || author_of_proposal?(@proposal) || current_editable?(@proposal) ||
can_create_image?(@proposal) || can_destroy_image?(@proposal) %>
can_destroy_image?(@proposal) %>
<div class="sidebar-divider"></div>
<h2><%= t("proposals.show.author") %></h2>
<div class="show-actions-menu">
@@ -129,14 +129,6 @@
<% end %>
<% end %>
<% if can_create_image?(@proposal) %>
<%= link_to new_image_path(imageable_id: @proposal, imageable_type: @proposal.class.name, from: request.url),
class: 'button hollow expanded' do %>
<span class="icon-document"></span>
<%= t("images.upload_image") %>
<% end %>
<% end %>
<% if can_destroy_image?(@proposal) %>
<%= link_to image_path(@proposal.image, from: request.url),
method: :delete,