Refactor documents and document view partials

This commit is contained in:
Bertocq
2018-01-02 13:24:38 +01:00
parent 46dc559301
commit d7d1a85fbb
3 changed files with 32 additions and 69 deletions

View File

@@ -1,20 +1,24 @@
<tr id="<%= dom_id(document)%>">
<td class="document-link">
<%= document.title %>
</td>
<td class="text-center">
<%= link_to t('documents.buttons.download_document'),
document.attachment.url,
target: "_blank",
rel: "nofollow",
class: 'button hollow' %>
</td>
<td class="text-center">
<% if can? :destroy, Document %>
<%= link_to t('documents.buttons.destroy_document'),
document_path(document, from: request.url), method: :delete,
data: { confirm: t('documents.actions.destroy.confirm') },
class: 'button hollow alert' %>
<% end %>
</td>
</tr>
<table>
<tbody>
<tr id="<%= dom_id(document)%>">
<td class="document-link">
<%= document.title %>
</td>
<td class="text-center">
<%= link_to t('documents.buttons.download_document'),
document.attachment.url,
target: "_blank",
rel: "nofollow",
class: 'button hollow' %>
</td>
<td class="text-center">
<% if can? :destroy, Document %>
<%= link_to t('documents.buttons.destroy_document'),
document_path(document, from: request.url), method: :delete,
data: { confirm: t('documents.actions.destroy.confirm') },
class: 'button hollow alert' %>
<% end %>
</td>
</tr>
</tbody>
</table>

View File

@@ -1,33 +1,11 @@
<% if documents.any? %>
<% 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">
<%= t "documents.max_documents_allowed_reached_html" %>
</div>
</div>
</div>
<% end %>
<div class="row documents-list">
<div class="small-12 column">
<table>
<tbody>
<%= render partial: "documents/document", collection: documents %>
</tbody>
</table>
</div>
</div>
<% else %>
<div class="row">
<div class="small-12 column">
<div class="row <% 'documents-list' if documents.any? %>">
<div class="small-12 column">
<% if documents.any? %>
<%= render partial: "documents/document", collection: documents %>
<% else %>
<div class="callout primary text-center">
<%= t('documents.no_documents') %>
</div>
</div>
<% end %>
</div>
<% end %>
</div>