Remove documents single uploads

This commit is contained in:
Senén Rodero Rodríguez
2017-09-27 11:04:56 +02:00
parent eef8ad1b73
commit 2993ef8707
11 changed files with 73 additions and 502 deletions

View File

@@ -4,12 +4,6 @@
<div class="small-12 medium-9 column">
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
<% if can_create_document?(investment) %>
<%= link_to t("documents.upload_document"),
new_document_path(documentable_id:investment, documentable_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,6 +1,6 @@
<% if documents.any? %>
<% if documents.size == max_documents_allowed && can?(:create, Document) %>
<% if documents.size == max_documents_allowed && can?(:destroy, Document) %>
<div class="row documents-list">
<div class="small-12 column">
<div class="callout warning text-center">

View File

@@ -1,63 +0,0 @@
<%= form_for @document,
url: documents_path(
documentable_type: @document.documentable_type,
documentable_id: @document.documentable_id,
from: params[:from]
),
html: { multipart: true, class: "documentable document-form" } do |f| %>
<%= render 'shared/errors', resource: @document %>
<div class="row document direct-upload">
<%= f.hidden_field :cached_attachment %>
<div class="small-12 column title">
<%= f.text_field :title, placeholder: t("documents.new.form.title_placeholder") %>
</div>
<div class="small-12 column attachment-actions">
<div class="small-6 column action-add attachment-errors">
<%= f.label :attachment, t("documents.form.attachment_label"), class: 'button hollow' %>
<%= f.file_field :attachment,
accept: accepted_content_types_extensions(@document.documentable.class),
label: false,
class: 'js-document-attachment',
data: {
url: direct_uploads_url("direct_upload[resource_type]": @document.documentable_type,
"direct_upload[resource_id]": @document.documentable_id,
"direct_upload[resource_relation]": "documents"),
cached_attachment_input_field: "document_cached_attachment",
title_input_field: "document_title"
} %>
</div>
<div class="small-6 column action-remove text-right">
<% if @document.cached_attachment.present? %>
<%= link_to t('documents.form.delete_button'),
direct_upload_destroy_url("direct_upload[resource_type]": @document.documentable_type,
"direct_upload[resource_id]": @document.documentable_id,
"direct_upload[resource_relation]": "documents",
"direct_upload[cached_attachment]": @document.cached_attachment),
method: :delete,
remote: true,
class: "delete remove-cached-attachment" %>
<% end %>
</div>
</div>
<div class="small-12 column">
<p class="file-name">
<%= document_attachment_file_name(@document) %>
</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("documents.form.submit_button"), class: "button expanded") %>
</div>
</div>
<% end %>

View File

@@ -108,18 +108,10 @@
</div>
<aside class="small-12 medium-3 column">
<% if can_create_document?(@proposal) || author_of_proposal?(@proposal) || current_editable?(@proposal) ||
can_destroy_image?(@proposal) %>
<% if author_of_proposal?(@proposal) || current_editable?(@proposal) || can_destroy_image?(@proposal) %>
<div class="sidebar-divider"></div>
<h2><%= t("proposals.show.author") %></h2>
<div class="show-actions-menu">
<% if can_create_document?(@proposal) %>
<%= link_to new_document_path(documentable_id: @proposal, documentable_type: @proposal.class.name, from: request.url),
class: 'button hollow expanded' do %>
<span class="icon-document"></span>
<%= t("documents.upload_document") %>
<% end %>
<% end %>
<% if author_of_proposal?(@proposal) %>
<%= link_to new_proposal_notification_path(proposal_id: @proposal.id),