Extract documents action from Answer controller
This way we have a controller just to manage Poll::Question::Answer related documents in the same way we have for videos and images.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<%= back_link_to %>
|
||||
|
||||
<h2><%= t("admin.questions.show.answers.documents_list") %></h2>
|
||||
|
||||
<ul class="breadcrumbs">
|
||||
<li><%= answer.question.title %></li>
|
||||
<li><%= answer.title %></li>
|
||||
</ul>
|
||||
|
||||
<div class="poll-question-form">
|
||||
<%= form_for(Poll::Question::Answer.new, url: admin_answer_documents_path(answer)) do |f| %>
|
||||
<%= render "shared/errors", resource: answer %>
|
||||
|
||||
<div class="documents">
|
||||
<%= render "documents/nested_documents", f: f %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-6 large-2">
|
||||
<%= f.submit(class: "button expanded", value: t("shared.save")) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.documents.present? %>
|
||||
<table>
|
||||
<tr>
|
||||
<th scope="col"><%= t("admin.questions.show.answers.document_title") %></th>
|
||||
<th scope="col"><%= t("admin.questions.show.answers.document_actions") %></th>
|
||||
</tr>
|
||||
|
||||
<% answer.documents.each do |document| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= link_to document.title, document.attachment %>
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(document,
|
||||
actions: [:destroy],
|
||||
destroy_path: document_path(document)
|
||||
) do |actions| %>
|
||||
<%= actions.action(:download,
|
||||
text: t("documents.buttons.download_document"),
|
||||
path: document.attachment,
|
||||
target: "_blank",
|
||||
rel: "nofollow") %>
|
||||
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -0,0 +1,7 @@
|
||||
class Admin::Poll::Questions::Answers::Documents::IndexComponent < ApplicationComponent
|
||||
attr_reader :answer
|
||||
|
||||
def initialize(answer)
|
||||
@answer = answer
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user