Commit 1696030d authored by Felix Macho's avatar Felix Macho
Browse files

Finish

parent 548e674e
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="file" class="svg-inline--fa fa-file fa-w-12" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"></path></svg>
\ No newline at end of file
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>
\ No newline at end of file
......@@ -5,3 +5,12 @@
padding: 5px;
color: $background-sexy;
}
#error_explanation{
font-size: $text;
color: white;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
flex-flow: column wrap;
}
......@@ -175,12 +175,12 @@ section.container {
background-color: $background-light;
display: grid;
grid-template-columns: 60% 40%;
grid-template-rows: 10% 35% 45%;
grid-template-rows: 10% 50% 30%;
row-gap: 5%;
grid-template-areas:
"heading tags"
"description image"
"description image";
"description file";
color: $background-sexy;
border-radius: 1rem;
......@@ -245,16 +245,56 @@ section.container {
&::-webkit-scrollbar {
display: none;
}
border-top: 2px solid $background-sexy;
border-left: 2px solid $background-sexy;
border-bottom: 2px solid $background-sexy;
border-radius: 1rem;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
img {
display: flex;
border-radius: 1rem;
margin: 0 1rem 1rem 1rem;
width: auto;
height: auto;
border-radius: 2rem;
padding: 0 1rem 1rem 1rem;
transition: all 0.5s ease-in-out;
cursor: pointer;
}
.small-img{
width: 50%;
margin: 0;
}
}
.documents{
grid-area: file;
border-top: 2px solid $background-sexy;
border-left: 2px solid $background-sexy;
border-radius: 1rem;
border-bottom-left-radius: 0;
padding: 1rem;
display: flex;
flex-flow: row wrap;
align-items: flex-start;
overflow-y: scroll;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
&::-webkit-scrollbar {
display: none;
}
img{
padding: 0 1rem 1rem 1rem;
cursor: pointer;
border-radius: 0;
}
.file-link{
width: 25%;
padding-right: 1rem;
}
.filename{
width: auto;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
.show-comments {
......
......@@ -46,10 +46,11 @@ class PostsController < ApplicationController
# PATCH/PUT /posts/1.json
# TODO: Refactor
def update
if @post.content_image.attached?
if @post.content_image.attached? || @post.content_file.attached?
@post.content_image.attach(post_params[:content_image]) unless post_params[:content_image].nil?
@post.content_file.attach(post_params[:content_file]) unless post_params[:content_file].nil?
respond_to do |format|
if @post.update(post_params.except(:content_image))
if @post.update(post_params.except(:content_image, :content_file))
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
......@@ -108,6 +109,6 @@ class PostsController < ApplicationController
# Only allow a list of trusted parameters through.
def post_params
params.require(:post).permit(:title, :content_text, :tag_list, :user_id, :content_file, content_image: [])
params.require(:post).permit(:title, :content_text, :tag_list, :user_id, content_file: [], content_image: [])
end
end
......@@ -5,9 +5,8 @@ class Post < ApplicationRecord
validates :title, presence: true
validates :user, presence: true
validates :content_text, presence: true
validates :content_image, content_type: ['image/png', 'image/jpg', 'image/jpeg']
validates :content_file, content_type: { in: 'application/pdf', message: 'is not a PDF' }
# validate :correct_tags
validates :content_image, content_type: ['image/png', 'image/jpg', 'image/jpeg', 'image/svg']
validates :content_file, content_type: { in: ['application/pdf', 'application/xls', 'application/doc', 'application/docx'], message: "is not a valid MIME Type: PDF, XLS, DOC/X" }
belongs_to :user
......
......@@ -36,7 +36,7 @@
<div class="field_content_file">
<%= form.label :content_file, "File" %>
<%= form.file_field :content_file %>
<%= form.file_field :content_file, multiple: true %>
</div>
<div class="actions">
<%= form.submit 'EDIT Post', :class => 'submit', method: :patch %>
......
......@@ -21,11 +21,23 @@
<% if @post.content_image.attached? %>
<% @post.content_image.each do |image| %>
<%= link_to url_for(image), class: "image-link" do %>
<%= image_tag(image.variant(resize_to_limit: [500, 500]), :tabindex => -1) %>
<%= image_tag(image) %>
<% end %>
<% end %>
<% else %>
<h2>Nothing to see here</h2>
<%= image_tag("image-solid.svg", class: "small-img") %>
<% end %>
</div>
<div class="documents">
<% if @post.content_file.attached? %>
<% @post.content_file.each do |file| %>
<%= link_to url_for(file), class: "file-link" do %>
<%= image_tag("file-solid") %>
<div class="filename"><%= file.filename %></div>
<% end %>
<% end %>
<% else %>
<h2>No Attachments</h2>
<% end %>
</div>
</div>
......
......@@ -24,7 +24,7 @@
<div class="field">
<%= f.label :user_tag_list, "Preferred Tags" %> <!-- TODO Find a way to .join(",") the values in here-->
<%= f.text_field :user_tag_list %>
<%= f.text_field :user_tag_list, value: @user.user_tag_list.join(",") %>
</div>
<% if own_profile?(@user) %>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment