Split and reuse question actions in partial

This commit is contained in:
Andreas Nedbal 2022-08-21 15:04:54 +02:00
parent 2a2f1a9988
commit 24be74a5a2
5 changed files with 28 additions and 66 deletions

View File

@ -0,0 +1,24 @@
.dropdown-menu.dropdown-menu-right{ role: :menu }
- if current_user.mod? || question.user == current_user
%a.dropdown-item.text-danger{ href: "#", tabindex: -1, data: { action: "ab-question-destroy", q_id: question.id } }
%i.fa.fa-fw.fa-trash-o
= t("voc.delete")
- unless question.user == current_user
%a.dropdown-item{ href: "#", tabindex: -1, data: { action: "ab-question-report", q_id: question.id } }
%i.fa.fa-fw.fa-exclamation-triangle
= t("voc.report")
- if question.anonymous? && !question.generated?
%a.dropdown-item{ name: "ib-block-anon", data: { q_id: question.id } }
%i.fa.fa-fw.fa-minus-circle
= t("voc.block")
- if current_user.mod?
%a.dropdown-item{ href: "#", name: "mod-block-anon", data: { q_id: question.id } }
%i.fa.fa-fw.fa-volume-off
= t("voc.block_site_wide")
%a.dropdown-item{ href: moderation_questions_path(author_identifier: question.author_identifier) }
%i.fa.fa-fw.fa-user-secret
= t("voc.show_anonymous_questions")
- if current_user.admin?
%a.dropdown-item{ href: rails_admin_path_for_resource(question), target: "_blank" }
%i.fa.fa-fw.fa-gears
= t("voc.view_in_rails_admin")

View File

@ -9,26 +9,7 @@
.btn-group .btn-group
%button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
%span.caret %span.caret
.dropdown-menu.dropdown-menu-right{ role: :menu } = render "actions/question", question: a.question
- if current_user.mod? || a.question.user == current_user
%a.dropdown-item.text-danger{ href: "#", tabindex: -1, data: { action: "ab-question-destroy", q_id: a.question.id } }
%i.fa.fa-trash-o
= t("voc.delete")
- unless a.question.user == current_user
%a.dropdown-item{ href: "#", tabindex: -1, data: { action: "ab-question-report", q_id: a.question.id } }
%i.fa.fa-exclamation-triangle
= t("voc.report")
- if current_user.mod? && a.question.anonymous? && !a.question.generated?
%a.dropdown-item{ href: moderation_questions_path(author_identifier: a.question.author_identifier) }
%i.fa.fa-user-secret
= t("voc.show_anonymous_questions")
%a.dropdown-item{ href: "#", name: "mod-block-anon", data: { q_id: a.question.id } }
%i.fa.fa-volume-off
= t("voc.block_site_wide")
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(a.question), target: "_blank" }
%i.fa.fa-gears
= t("voc.view_in_rails_admin")
%h6.text-muted.media-heading.answerbox__question-user %h6.text-muted.media-heading.answerbox__question-user
- if a.question.author_is_anonymous - if a.question.author_is_anonymous
%i.fa.fa-user-secret{ title: t(".anon_hint") } %i.fa.fa-user-secret{ title: t(".anon_hint") }

View File

@ -19,22 +19,7 @@
.btn-group .btn-group
%button.btn.btn-default.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %button.btn.btn-default.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
%span.caret %span.caret
.dropdown-menu.dropdown-menu-right{ role: :menu } = render "actions/question", question: i.question
- if i.question.user_id != current_user.id
%a.dropdown-item{ name: "ib-report", data: { q_id: i.question.id } }
%i.fa.fa-fw.fa-warning
= t("voc.report")
- if current_user.mod? && i.question.anonymous? && !i.question.generated?
%a.dropdown-item{ name: "mod-block-anon", data: { q_id: i.question.id } }
%i.fa.fa-fw.fa-volume-off
= t("voc.block_site_wide")
%a.dropdown-item{ name: "ib-block-anon", data: { q_id: i.question.id } }
%i.fa.fa-fw.fa-minus-circle
= t("voc.block")
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(i) }
%i.fa.fa-fw.fa-gears
= t("voc.view_in_rails_admin")
- if current_user == i.user - if current_user == i.user
.card-body .card-body
%textarea.form-control{ name: "ib-answer", placeholder: t(".placeholder"), data: { id: i.id } } %textarea.form-control{ name: "ib-answer", placeholder: t(".placeholder"), data: { id: i.id } }

View File

@ -12,23 +12,7 @@
%button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
%span.caret %span.caret
- unless hidden - unless hidden
.dropdown-menu.dropdown-menu-right{ role: :menu } = render "actions/question", question: question
- if current_user.mod? || question.user == current_user
%a.dropdown-item.text-danger{ href: '#',
tabindex: -1,
data: { action: 'ab-question-destroy',
q_id: question.id,
redirect: question.author_is_anonymous? ? '/' : show_user_questions_path(question.user.screen_name) } }
%i.fa.fa-trash-o
= t("voc.delete")
- unless question.user == current_user
%a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id } }
%i.fa.fa-exclamation-triangle
= t("voc.report")
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(question) }
%i.fa.fa-gears
= t("voc.view_in_rails_admin")
%h6.text-muted.media-heading.answerbox__question-user %h6.text-muted.media-heading.answerbox__question-user
- identifier = question.author_is_anonymous ? question.author_identifier : nil - identifier = question.author_is_anonymous ? question.author_identifier : nil
- if hidden - if hidden

View File

@ -12,19 +12,7 @@
.btn-group .btn-group
%button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
%span.caret %span.caret
.dropdown-menu.dropdown-menu-right{ role: :menu } = render "actions/question", question: q
- if current_user.mod? || q.user == current_user
%a.dropdown-item.text-danger{ href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: q.id } }
%i.fa.fa-trash-o
= t("voc.delete")
- unless q.user == current_user
%a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: q.id } }
%i.fa.fa-exclamation-triangle
= t("voc.report")
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(q) }
%i.fa.fa-gears
= t("voc.view_in_rails_admin")
%h6.media-heading.text-muted.answerbox__question-user %h6.media-heading.text-muted.answerbox__question-user
= t("answerbox.header.asked_html", user: user_screen_name(q.user), time: time_tooltip(q)) = t("answerbox.header.asked_html", user: user_screen_name(q.user), time: time_tooltip(q))
- if q.answer_count > 1 - if q.answer_count > 1