Create documentable concern and add it to budget investment model. Create documents controller, documents helper, routes, translations and specs
This commit is contained in:
14
app/views/documents/_document.html.erb
Normal file
14
app/views/documents/_document.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<tr id="<%= dom_id(document)%>">
|
||||
<td><%#= icon %></td>
|
||||
<td><%= document.title %></td>
|
||||
<td>
|
||||
<%= link_to "Download", document.attachment.url %>
|
||||
|
||||
<% if can? :destroy, Document %>
|
||||
<%= link_to "Destroy",
|
||||
document_path(document, from: request.url), method: :delete,
|
||||
data: { confirm: "¿Está segurto de que desea eliminar el documento?. Esta acción no se puede deshacer." } %>
|
||||
<% end %>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
17
app/views/documents/_documents.html.erb
Normal file
17
app/views/documents/_documents.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<% if documents.any? %>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<% documents.each do |document| %>
|
||||
<%= render "documents/document", document: document %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% else %>
|
||||
|
||||
<div class="callout primary text-center">
|
||||
<%= t('documents.no_documents') %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
38
app/views/documents/_form.html.erb
Normal file
38
app/views/documents/_form.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
<%= form_for @document,
|
||||
url: documents_path(
|
||||
documentable_type: @document.documentable_type,
|
||||
documentable_id: @document.documentable_id,
|
||||
from: params[:from]
|
||||
),
|
||||
html: { multipart: true } do |f| %>
|
||||
|
||||
<%= render 'shared/errors', resource: @document %>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :title %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<div class="file-name">
|
||||
<%= f.file_field :attachment, label: false, class:'show-for-sr' %>
|
||||
<br>
|
||||
<%= f.label :attachment, t("documents.form.attachment_label"), class:'button' %>
|
||||
<p><%= document_attachment_file_name(@document) %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @document.errors.has_key?(:attachment) %>
|
||||
<div class="small-12 column">
|
||||
<div class="attachment-errors">
|
||||
<small class="error"><%= errors_on_attachment(@document)%></small>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="actions small-12 medium-6 large-4 end column">
|
||||
<%= f.submit(t("documents.form.submit_button"), class: "button expanded") %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
20
app/views/documents/new.html.erb
Normal file
20
app/views/documents/new.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<div class="document-form <%= @document.documentable.class.name.parameterize('_') %> row">
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= render "shared/back_link" %>
|
||||
|
||||
<h1><%= t("documents.new.title") %></h1>
|
||||
|
||||
<%= render "documents/form", form_url: documents_url %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<span class="icon-documents float-right"></span>
|
||||
<h2><%= t("documents.recommendations_title") %></h2>
|
||||
<ul class="recommendations">
|
||||
<li><%= t("documents.recommendation_one_html") %></li>
|
||||
<li><%= t("documents.recommendation_two_html") %></li>
|
||||
<li><%= t("documents.recommendation_three_html") %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user