Unify the way we display document information
We were displaying documents in five places, and in five different ways. Sometimes with the metadata in parenthesis after the title, sometimes with the metadata below the title, sometimes without metadata, sometimes with an icon in front of the document, and sometimes with a separate link to download the file. So we're now displaying the same thing everywhere. Not sure whether this is the best solution, but at least it's consistent. We aren't unifying the way we display a list of documents, though, since different sections look pretty different and I'm not sure whether the same style would look well everywhere. Note that we're renaming the `document` HTML class in the documents table to `document-row` so the styles for the `document` class don't apply here.
This commit is contained in:
21
app/assets/stylesheets/documents/document.scss
Normal file
21
app/assets/stylesheets/documents/document.scss
Normal file
@@ -0,0 +1,21 @@
|
||||
.document {
|
||||
+ .document {
|
||||
margin-top: $line-height / 3;
|
||||
}
|
||||
|
||||
a:first-of-type {
|
||||
word-wrap: break-word;
|
||||
|
||||
.document-metadata {
|
||||
&::before,
|
||||
&::after {
|
||||
content: "";
|
||||
display: block;
|
||||
}
|
||||
|
||||
* + *::before {
|
||||
@include vertical-separator;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,5 @@
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2028,12 +2028,8 @@ table {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.icon-document {
|
||||
color: #007bb7;
|
||||
display: inline-block;
|
||||
font-size: rem-calc(24);
|
||||
line-height: $line-height;
|
||||
vertical-align: middle;
|
||||
> :first-child {
|
||||
@include has-fa-icon(file, regular);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1442,8 +1442,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
.document-link a {
|
||||
word-wrap: break-word;
|
||||
.document-link {
|
||||
> :first-child {
|
||||
@include has-fa-icon(file, regular);
|
||||
|
||||
&::before {
|
||||
position: relative;
|
||||
top: -0.1rem;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
<li id="<%= dom_id(document) %>">
|
||||
<%= link_to t("documents.buttons.download_document"),
|
||||
document.attachment,
|
||||
target: "_blank",
|
||||
rel: "nofollow",
|
||||
class: "button hollow medium float-right" %>
|
||||
<div id="<%= dom_id(document) %>" class="document">
|
||||
<%= link_to document.attachment, target: "_blank", 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 %>
|
||||
|
||||
<strong><%= document.title %></strong>
|
||||
<br>
|
||||
<small>
|
||||
<%= document.humanized_content_type %> |
|
||||
<%= number_to_human_size(document.attachment_file_size, precision: 2) %>
|
||||
</small>
|
||||
|
||||
<% if can?(:destroy, document) %>
|
||||
<br>
|
||||
<% 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 %>
|
||||
</li>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
class Documents::DocumentComponent < ApplicationComponent
|
||||
attr_reader :document
|
||||
attr_reader :document, :show_destroy_link
|
||||
alias_method :show_destroy_link?, :show_destroy_link
|
||||
delegate :can?, to: :helpers
|
||||
|
||||
def initialize(document)
|
||||
def initialize(document, show_destroy_link: false)
|
||||
@document = document
|
||||
@show_destroy_link = show_destroy_link
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
<ul class="no-bullet document-link">
|
||||
<% documents.each do |document| %>
|
||||
<%= render Documents::DocumentComponent.new(document) %>
|
||||
<li>
|
||||
<%= render Documents::DocumentComponent.new(document, show_destroy_link: true) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
module DocumentsHelper
|
||||
def document_item_link(document)
|
||||
info_text = "#{document.humanized_content_type} | #{number_to_human_size(document.attachment_file_size)}"
|
||||
|
||||
link_to safe_join([document.title, tag.small("(#{info_text})")], " "),
|
||||
document.attachment,
|
||||
target: "_blank",
|
||||
title: t("shared.target_blank")
|
||||
end
|
||||
end
|
||||
@@ -18,7 +18,7 @@
|
||||
</thead>
|
||||
<tbody id="documents">
|
||||
<% @documents.each do |document| %>
|
||||
<tr id="<%= dom_id(document) %>" class="document">
|
||||
<tr id="<%= dom_id(document) %>" class="document-row">
|
||||
<td><%= document.title %></td>
|
||||
<td><%= document.attachment.content_type %></td>
|
||||
<td><%= number_to_human_size(document.attachment.byte_size) %></td>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<p>
|
||||
<%= link_to document.attachment, target: "_blank" do %>
|
||||
<%= document.title %>
|
||||
(<%= document.humanized_content_type %>
|
||||
|
|
||||
<%= number_to_human_size(document.attachment_file_size, precision: 2) %>)
|
||||
<% end %>
|
||||
</p>
|
||||
@@ -49,7 +49,9 @@
|
||||
<p><%= link_to link.label, link.url, target: "_blank" %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: "document", collection: proposed_action.documents %>
|
||||
<% proposed_action.documents.each do |document| %>
|
||||
<%= render Documents::DocumentComponent.new(document) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<p><span class="icon-document"></span>
|
||||
<%= document_item_link(document) %>
|
||||
</p>
|
||||
@@ -6,7 +6,9 @@
|
||||
<p>
|
||||
<strong><%= t("documents.additional") %></strong>
|
||||
</p>
|
||||
<%= render partial: "documents/additional_document", collection: documents, as: :document %>
|
||||
<% documents.each do |document| %>
|
||||
<%= render Documents::DocumentComponent.new(document) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -36,15 +36,7 @@
|
||||
</p>
|
||||
|
||||
<% milestone.documents.each do |document| %>
|
||||
<%= link_to document.title,
|
||||
document.attachment,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<small>
|
||||
<%= document.humanized_content_type %> |
|
||||
<%= number_to_human_size(document.attachment_file_size, precision: 2) %>
|
||||
</small>
|
||||
<br>
|
||||
<%= render Documents::DocumentComponent.new(document) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user