Add `show_reactions` action and move markup into it
This commit is contained in:
parent
795e687bc8
commit
f30b1b820e
|
@ -7,4 +7,11 @@ class CommentController < ApplicationController
|
||||||
|
|
||||||
render "index", locals: { a: answer }
|
render "index", locals: { a: answer }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_reactions
|
||||||
|
comment = Comment.find(params[:id])
|
||||||
|
@reactions = Appendable::Reaction.where(parent_type: "Comment", parent: comment.id).includes([{ user: :profile }])
|
||||||
|
|
||||||
|
redirect_to answer_path(username: comment.answer.user.screen_name, id: comment.answer.id) unless turbo_frame_request?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.dropdown-menu.dropdown-menu-end{ role: :menu }
|
.dropdown-menu.dropdown-menu-end{ role: :menu }
|
||||||
%a.dropdown-item{ href: "#", data: { bs_target: "#modal-view-comment#{comment.id}-smiles", bs_toggle: :modal } }
|
= link_to comment_reactions_path(username: comment.user.screen_name, id: comment.id), class: "dropdown-item", data: { turbo_frame: "modal" } do
|
||||||
%i.fa.fa-fw.fa-smile-o
|
%i.fa.fa-fw.fa-smile-o
|
||||||
= t(".view_smiles")
|
= t(".view_smiles")
|
||||||
- if privileged?(comment.user) || privileged?(answer.user)
|
- if privileged?(comment.user) || privileged?(answer.user)
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
%ul.comment__container
|
%ul.comment__container
|
||||||
- comments.order(:created_at).each do |comment|
|
- comments.order(:created_at).each do |comment|
|
||||||
%li.comment{ data: { comment_id: comment.id } }
|
%li.comment{ data: { comment_id: comment.id } }
|
||||||
%div{ style: "height: 0; width: 0" }= render "modal/comment_smiles", comment: comment
|
|
||||||
.d-flex
|
.d-flex
|
||||||
.flex-shrink-0
|
.flex-shrink-0
|
||||||
%a{ href: user_path(comment.user) }
|
%a{ href: user_path(comment.user) }
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
= turbo_frame_tag "modal" do
|
||||||
|
.modal.fade.show.d-block{ id: "modal-view-comment-smiles", aria: { hidden: false, labelledby: "modal-commentsmile-label" }, role: :dialog, tabindex: -1 }
|
||||||
|
.modal-dialog
|
||||||
|
.modal-content
|
||||||
|
.modal-header
|
||||||
|
%h5.modal-title#modal-commentsmile-label= t(".title")
|
||||||
|
= button_to modal_close_path, method: :get, class: "btn-close" do
|
||||||
|
%span.visually-hidden Close
|
||||||
|
.modal-body
|
||||||
|
- if @reactions.count.zero?
|
||||||
|
= t(".none")
|
||||||
|
- else
|
||||||
|
%ul.smiles__user-list
|
||||||
|
- @reactions.each do |smile|
|
||||||
|
%li.smiles__user-list-entry
|
||||||
|
%a{ href: user_path(smile.user) }
|
||||||
|
%img{ src: smile.user.profile_picture.url(:small), alt: user_screen_name(smile.user, url: false) }
|
||||||
|
%span= user_screen_name(smile.user, url: false)
|
||||||
|
.modal-footer
|
||||||
|
= button_to t("voc.close"), modal_close_path, method: :get, class: "btn btn-default"
|
||||||
|
.modal-backdrop.fade.show
|
|
@ -1,17 +0,0 @@
|
||||||
.modal.fade{ id: "modal-view-comment#{comment.id}-smiles", aria: { hidden: true, labelledby: "modal-commentsmile-label" }, role: :dialog, tabindex: -1 }
|
|
||||||
.modal-dialog
|
|
||||||
.modal-content
|
|
||||||
.modal-header
|
|
||||||
%h5.modal-title#modal-commentsmile-label= t(".title")
|
|
||||||
%button.btn-close{ data: { bs_dismiss: :modal }, type: :button }
|
|
||||||
%span.visually-hidden Close
|
|
||||||
.modal-body
|
|
||||||
- if comment.smiles.all.count.zero?
|
|
||||||
= t(".none")
|
|
||||||
- else
|
|
||||||
%ul.smiles__user-list
|
|
||||||
- comment.smiles.all.each do |smile|
|
|
||||||
%li.smiles__user-list-entry
|
|
||||||
%a{ href: user_path(smile.user) }
|
|
||||||
%img{ src: smile.user.profile_picture.url(:small), alt: user_screen_name(smile.user, url: false) }
|
|
||||||
%span= user_screen_name(smile.user, url: false)
|
|
|
@ -150,6 +150,10 @@ en:
|
||||||
non_anonymous_html: |
|
non_anonymous_html: |
|
||||||
This user does not want to receive anonymous questions. <br/>
|
This user does not want to receive anonymous questions. <br/>
|
||||||
(%{sign_in} or %{sign_up})
|
(%{sign_in} or %{sign_up})
|
||||||
|
comment:
|
||||||
|
show_reactions:
|
||||||
|
title: "People who smiled this comment"
|
||||||
|
none: "No one has smiled this comment yet."
|
||||||
devise:
|
devise:
|
||||||
registrations:
|
registrations:
|
||||||
edit:
|
edit:
|
||||||
|
@ -262,9 +266,6 @@ en:
|
||||||
action: "Ask"
|
action: "Ask"
|
||||||
loading: "Asking…"
|
loading: "Asking…"
|
||||||
long_question_warning: "This question will only be sent to those who allow long questions in their profile settings."
|
long_question_warning: "This question will only be sent to those who allow long questions in their profile settings."
|
||||||
comment_smiles:
|
|
||||||
title: "People who smiled this comment"
|
|
||||||
none: "No one has smiled this comment yet."
|
|
||||||
list:
|
list:
|
||||||
title: "Manage list memberships"
|
title: "Manage list memberships"
|
||||||
tab:
|
tab:
|
||||||
|
|
|
@ -156,6 +156,7 @@ Rails.application.routes.draw do
|
||||||
get "/@:username/a/:id/comments", to: "comment#index", as: :comments
|
get "/@:username/a/:id/comments", to: "comment#index", as: :comments
|
||||||
get "/@:username/a/:id/reactions", to: "reaction#index", as: :reactions
|
get "/@:username/a/:id/reactions", to: "reaction#index", as: :reactions
|
||||||
get "/@:username/q/:id", to: "question#show", as: :question
|
get "/@:username/q/:id", to: "question#show", as: :question
|
||||||
|
get "/@:username/c/:id/reactions", to: "comment#show_reactions", as: :comment_reactions
|
||||||
get "/@:username/followers", to: "user#followers", as: :show_user_followers
|
get "/@:username/followers", to: "user#followers", as: :show_user_followers
|
||||||
get "/@:username/followings", to: "user#followings", as: :show_user_followings
|
get "/@:username/followings", to: "user#followings", as: :show_user_followings
|
||||||
get "/@:username/friends", to: redirect("/@%{username}/followings")
|
get "/@:username/friends", to: redirect("/@%{username}/followings")
|
||||||
|
|
Loading…
Reference in New Issue