Skip to content

Commit

Permalink
Hide feedbacks if post is in review
Browse files Browse the repository at this point in the history
  • Loading branch information
angussidney committed Feb 5, 2019
1 parent 20c2856 commit 91ec12a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def show
@post = Post.find params[:id]
end

@is_review_item = false

not_found if @post&.id.nil?
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/post_comments/_comment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="panel panel-primary post-comment" data-cid="<%= comment.id %>">
<div class="panel-heading">
<strong><%= comment.user.username %></strong>
<% if feedback.present? %>
<% if feedback.present? && !@is_review_item %>
<%= render 'feedbacks/feedback', feedback: feedback %>
<% end %>
<span title="<%= comment.created_at %>"><%= time_ago_in_words comment.created_at %> ago</span>
Expand Down
1 change: 1 addition & 0 deletions app/views/posts/_review_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="review-item">
<%= render 'review_queues/responses', queue: queue, item: item, exclude_responses: item.reviewable.question? ? [['NAA', 'naa']] : [] %>
<% @post = item.reviewable %>
<% @is_review_item = true %>
<%= render file: 'posts/show.html.erb' %>
</div>
18 changes: 10 additions & 8 deletions app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
<% end %>
<% end %>
<%= title @post.title %>
<% feedbacks = @post.feedbacks.to_a %>
<strong class="post-feedbacks">
<% feedbacks.each do |feedback| %>
<span style="<%= "font-weight:normal" if feedback.is_naa? %>" data-toggle="tooltip" data-placement="top" title="<%= (feedback.user.present? || feedback.api_key_id.present?) ? "#{feedback.user.try(:username)} (From #{feedback.api_key.try(:app_name) || "Review"})" : feedback.user_name %>: <%= feedback.feedback_type %>" class="<%= element_class_for_feedback feedback %>"><%= element_symbol_for_feedback(feedback).html_safe %></span>
<% end %>
</strong>
<% unless feedbacks.empty? %>
<% unless @is_review_item %>
<% feedbacks = @post.feedbacks.to_a %>
<strong class="post-feedbacks">
<% feedbacks.each do |feedback| %>
<span style="<%= "font-weight:normal" if feedback.is_naa? %>" data-toggle="tooltip" data-placement="top" title="<%= (feedback.user.present? || feedback.api_key_id.present?) ? "#{feedback.user.try(:username)} (From #{feedback.api_key.try(:app_name) || "Review"})" : feedback.user_name %>: <%= feedback.feedback_type %>" class="<%= element_class_for_feedback feedback %>"><%= element_symbol_for_feedback(feedback).html_safe %></span>
<% end %>
</strong>
<% end %>
<% unless feedbacks.empty? || @is_review_item %>
<% if current_user.present? && (current_user.has_role?(:admin) || @post.feedbacks.where(user_id: current_user.id).exists?) %>
<small>
<%= link_to "(clear)", clear_post_feedback_path(@post) %>
Expand All @@ -26,7 +28,7 @@
</a></p>
<% end %>
<% if user_signed_in? && current_user.has_role?(:reviewer) %>
<% if user_signed_in? && current_user.has_role?(:reviewer) && !@is_review_item %>
<p>
<strong>Add feedback:</strong>
<%= link_to raw('&#x2713'), post_feedback_path(post_id: @post.id, feedback_type: 'tp'),
Expand Down

0 comments on commit 91ec12a

Please sign in to comment.