From 2a2f1a998894daf4af3ad474823fd11f6bd33b89 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 21 Aug 2022 15:04:12 +0200 Subject: [PATCH] Split actions from comments into separate partial --- app/views/actions/_comment.haml | 12 ++++++++++++ app/views/answerbox/_comments.haml | 13 +------------ 2 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 app/views/actions/_comment.haml diff --git a/app/views/actions/_comment.haml b/app/views/actions/_comment.haml new file mode 100644 index 00000000..c1cec4ce --- /dev/null +++ b/app/views/actions/_comment.haml @@ -0,0 +1,12 @@ +.dropdown-menu.dropdown-menu-right{ role: :menu } + %a.dropdown-item{ href: "#", data: { target: "#modal-view-comment#{comment.id}-smiles", toggle: :modal } } + %i.fa.fa-fw.fa-smile-o + = t(".view_smiles") + - if privileged?(comment.user) || privileged?(answer.user) + %a.dropdown-item.text-danger{ href: "#", data: { action: "ab-comment-destroy", c_id: comment.id } } + %i.fa.fa-fw.fa-trash-o + = t("voc.delete") + - unless comment.user == current_user + %a.dropdown-item{ href: "#", data: { action: "ab-comment-report", c_id: comment.id } } + %i.fa.fa-fw.fa-exclamation-triangle + = t("voc.report") diff --git a/app/views/answerbox/_comments.haml b/app/views/answerbox/_comments.haml index f88085d5..0c87c165 100644 --- a/app/views/answerbox/_comments.haml +++ b/app/views/answerbox/_comments.haml @@ -34,18 +34,7 @@ .btn-group %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %span.caret - .dropdown-menu.dropdown-menu-right{ role: :menu } - %a.dropdown-item{ href: "#", data: { target: "#modal-view-comment#{comment.id}-smiles", toggle: :modal } } - %i.fa.fa-fw.fa-smile-o - = t(".actions.view_smiles") - - if privileged?(comment.user) || privileged?(a.user) - %a.dropdown-item.text-danger{ href: "#", data: { action: "ab-comment-destroy", c_id: comment.id } } - %i.fa.fa-fw.fa-trash-o - = t("voc.delete") - - unless comment.user == current_user - %a.dropdown-item{ href: "#", data: { action: "ab-comment-report", c_id: comment.id } } - %i.fa.fa-fw.fa-exclamation-triangle - = t("voc.report") + = render "actions/comment", comment: comment, answer: a - if user_signed_in? .form-group.has-feedback.comment__input-group{ name: "ab-comment-new-group", data: { a_id: a.id } } %input.form-control.comment__input{ type: :text, placeholder: t(".placeholder"), name: "ab-comment-new", data: { a_id: a.id } }