Merge pull request #5281 from consuldemocracy/pdf_links
Open PDF files in the same tab/window
This commit is contained in:
@@ -56,8 +56,8 @@
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:allow_images) %>
|
||||
<div class="images small-12 column">
|
||||
<%= render "images/nested_image", f: f %>
|
||||
<div class="small-12 column">
|
||||
<%= render Images::NestedComponent.new(f) %>
|
||||
<p class="help-text"><%= t("admin.budget_phases.edit.image_description") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:allow_images) %>
|
||||
<div class="images small-12 column">
|
||||
<%= render "/images/nested_image", f: f %>
|
||||
<div class="small-12 column">
|
||||
<%= render Images::NestedComponent.new(f) %>
|
||||
<p class="help-text"><%= t("admin.budgets.edit.image_description") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
<%= 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>
|
||||
<%= render Documents::NestedComponent.new(f) %>
|
||||
|
||||
<div class="small-12 medium-6 large-2">
|
||||
<%= f.submit(class: "button expanded", value: t("shared.save")) %>
|
||||
@@ -36,7 +34,7 @@
|
||||
<% documents.each do |document| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= link_to document.title, document.attachment %>
|
||||
<%= document.title %>
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::Poll::Questions::Answers::Documents::TableActionsComponent.new(document) %>
|
||||
|
||||
@@ -3,6 +3,5 @@
|
||||
<%= actions.action(:download,
|
||||
text: t("documents.buttons.download_document"),
|
||||
path: document.attachment,
|
||||
target: "_blank",
|
||||
rel: "nofollow") %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="<%= singular_name %> direct-upload nested-fields">
|
||||
<div class="<%= singular_name %>-fields direct-upload nested-fields">
|
||||
<%= f.hidden_field :id %>
|
||||
<%= f.hidden_field :user_id, value: current_user.id %>
|
||||
<%= f.hidden_field :cached_attachment %>
|
||||
|
||||
@@ -37,15 +37,11 @@
|
||||
<legend><%= t("shared.optional") %></legend>
|
||||
|
||||
<% if feature?(:allow_images) %>
|
||||
<div class="images">
|
||||
<%= render "images/nested_image", f: f %>
|
||||
</div>
|
||||
<%= render Images::NestedComponent.new(f) %>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:allow_attached_documents) %>
|
||||
<div class="documents">
|
||||
<%= render "documents/nested_documents", f: f %>
|
||||
</div>
|
||||
<%= render Documents::NestedComponent.new(f) %>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:map) %>
|
||||
|
||||
17
app/components/documents/document_component.html.erb
Normal file
17
app/components/documents/document_component.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<div id="<%= dom_id(document) %>" class="document">
|
||||
<%= link_to document.attachment, rel: "nofollow" do %>
|
||||
<strong class="document-title"><%= document.title %></strong>
|
||||
<small class="document-metadata">
|
||||
<span class="document-content-type"><%= document.humanized_content_type %></span>
|
||||
<span class="document-size"><%= number_to_human_size(document.attachment_file_size, precision: 2) %></span>
|
||||
</small>
|
||||
<% end %>
|
||||
|
||||
<% if show_destroy_link? && can?(:destroy, document) %>
|
||||
<%= link_to t("documents.buttons.destroy_document"),
|
||||
document,
|
||||
method: :delete,
|
||||
data: { confirm: t("documents.actions.destroy.confirm") },
|
||||
class: "delete" %>
|
||||
<% end %>
|
||||
</div>
|
||||
10
app/components/documents/document_component.rb
Normal file
10
app/components/documents/document_component.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Documents::DocumentComponent < ApplicationComponent
|
||||
attr_reader :document, :show_destroy_link
|
||||
alias_method :show_destroy_link?, :show_destroy_link
|
||||
delegate :can?, to: :helpers
|
||||
|
||||
def initialize(document, show_destroy_link: false)
|
||||
@document = document
|
||||
@show_destroy_link = show_destroy_link
|
||||
end
|
||||
end
|
||||
11
app/components/documents/documents_component.html.erb
Normal file
11
app/components/documents/documents_component.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<div id="documents" class="documents">
|
||||
<h2><%= t("documents.title") %> <span>(<%= documents.count %>)</span></h2>
|
||||
|
||||
<ul class="no-bullet document-link">
|
||||
<% documents.each do |document| %>
|
||||
<li>
|
||||
<%= render Documents::DocumentComponent.new(document, show_destroy_link: true) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
11
app/components/documents/documents_component.rb
Normal file
11
app/components/documents/documents_component.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Documents::DocumentsComponent < ApplicationComponent
|
||||
attr_reader :documents
|
||||
|
||||
def initialize(documents)
|
||||
@documents = documents
|
||||
end
|
||||
|
||||
def render?
|
||||
documents.any?
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
<fieldset class="documents-list">
|
||||
<fieldset class="documents-list documents-nested">
|
||||
<legend><%= t("documents.form.title") %></legend>
|
||||
<p class="help-text"><%= note %></p>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<fieldset>
|
||||
<fieldset class="images-nested">
|
||||
<legend><%= t("images.form.title") %></legend>
|
||||
<p class="help-text"><%= note %></p>
|
||||
|
||||
|
||||
@@ -30,15 +30,11 @@
|
||||
<% if answer.documents.present? %>
|
||||
<div class="document-link">
|
||||
<p>
|
||||
<span class="icon-document"></span>
|
||||
<strong><%= t("polls.show.documents") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.documents.each do |document| %>
|
||||
<%= link_to document.title,
|
||||
document.attachment,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<%= render Documents::DocumentComponent.new(document) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -38,15 +38,11 @@
|
||||
</div>
|
||||
|
||||
<% if feature?(:allow_images) %>
|
||||
<div class="images">
|
||||
<%= render "images/nested_image", f: f %>
|
||||
</div>
|
||||
<%= render Images::NestedComponent.new(f) %>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:allow_attached_documents) %>
|
||||
<div class="documents">
|
||||
<%= render "documents/nested_documents", f: f %>
|
||||
</div>
|
||||
<%= render Documents::NestedComponent.new(f) %>
|
||||
<% end %>
|
||||
|
||||
<% if Geozone.any? %>
|
||||
|
||||
Reference in New Issue
Block a user