Merge pull request #635 from Retrospring/feature/actions-partials
This commit is contained in:
commit
f06c07bb47
|
@ -29,7 +29,7 @@ export function answerboxSubscribeHandler(event: Event): void {
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
button.dataset.torpedo = ["yes", "no"][torpedo];
|
button.dataset.torpedo = ["yes", "no"][torpedo];
|
||||||
button.children[0].nextSibling.textContent = ' ' + (torpedo ? I18n.translate('views.actions.unsubscribe') : I18n.translate('views.actions.subscribe'));
|
button.children[0].nextSibling.textContent = ' ' + (torpedo ? I18n.translate('voc.unsubscribe') : I18n.translate('voc.subscribe'));
|
||||||
showNotification(I18n.translate(`frontend.subscription.${torpedo ? 'subscribe' : 'unsubscribe'}`));
|
showNotification(I18n.translate(`frontend.subscription.${torpedo ? 'subscribe' : 'unsubscribe'}`));
|
||||||
} else {
|
} else {
|
||||||
showErrorNotification(I18n.translate(`frontend.subscription.fail.${torpedo ? 'subscribe' : 'unsubscribe'}`));
|
showErrorNotification(I18n.translate(`frontend.subscription.fail.${torpedo ? 'subscribe' : 'unsubscribe'}`));
|
||||||
|
|
|
@ -141,6 +141,10 @@ class User < ApplicationRecord
|
||||||
has_role?(:moderator) || has_role?(:administrator)
|
has_role?(:moderator) || has_role?(:administrator)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def admin?
|
||||||
|
has_role?(:administrator)
|
||||||
|
end
|
||||||
|
|
||||||
# region stuff used for reporting/moderation
|
# region stuff used for reporting/moderation
|
||||||
def report(object, reason = nil)
|
def report(object, reason = nil)
|
||||||
existing = Report.find_by(type: "Reports::#{object.class}", target_id: object.id, user_id: self.id, deleted: false)
|
existing = Report.find_by(type: "Reports::#{object.class}", target_id: object.id, user_id: self.id, deleted: false)
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
.dropdown-menu.dropdown-menu-right{ role: :menu }
|
||||||
|
- if Subscription.is_subscribed(current_user, answer)
|
||||||
|
-# fun joke should subscribe?
|
||||||
|
%a.dropdown-item{ href: "#", data: { a_id: answer.id, action: "ab-submarine", torpedo: "no" } }
|
||||||
|
%i.fa.fa-fw.fa-anchor
|
||||||
|
= t("voc.unsubscribe")
|
||||||
|
- else
|
||||||
|
%a.dropdown-item{ href: "#", data: { a_id: answer.id, action: "ab-submarine", torpedo: "yes" } }
|
||||||
|
%i.fa.fa-fw.fa-anchor
|
||||||
|
= t("voc.subscribe")
|
||||||
|
- if privileged? answer.user
|
||||||
|
%a.dropdown-item.text-danger{ href: "#", data: { a_id: answer.id, action: "ab-destroy" } }
|
||||||
|
%i.fa.fa-fw.fa-trash-o
|
||||||
|
= t(".return")
|
||||||
|
- unless answer.user == current_user
|
||||||
|
%a.dropdown-item{ href: "#", data: { a_id: answer.id, action: "ab-report" } }
|
||||||
|
%i.fa.fa-fw.fa-exclamation-triangle
|
||||||
|
= t("voc.report")
|
||||||
|
- if current_user.admin?
|
||||||
|
%a.dropdown-item{ href: rails_admin_path_for_resource(answer), target: "_blank" }
|
||||||
|
%i.fa.fa-fw.fa-gears
|
||||||
|
= t("voc.view_in_rails_admin")
|
|
@ -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")
|
|
@ -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")
|
|
@ -0,0 +1,9 @@
|
||||||
|
.dropdown-menu.dropdown-menu-right{ role: :menu }
|
||||||
|
%a.dropdown-item{ href: twitter_share_url(answer), target: "_blank" }
|
||||||
|
%i.fa.fa-fw.fa-twitter
|
||||||
|
= t(".twitter")
|
||||||
|
%a.dropdown-item{ href: tumblr_share_url(answer), target: "_blank" }
|
||||||
|
%i.fa.fa-fw.fa-tumblr
|
||||||
|
= t(".tumblr")
|
||||||
|
%a.dropdown-item{ href: "#", name: "ab-share" }
|
||||||
|
= t(".other")
|
|
@ -19,38 +19,9 @@
|
||||||
.btn-group
|
.btn-group
|
||||||
%button.btn.btn-link.answerbox__action{ data: { toggle: :dropdown }, aria: { expanded: false } }
|
%button.btn.btn-link.answerbox__action{ data: { toggle: :dropdown }, aria: { expanded: false } }
|
||||||
%i.fa.fa-fw.fa-share-alt{ title: t(".share.title") }
|
%i.fa.fa-fw.fa-share-alt{ title: t(".share.title") }
|
||||||
.dropdown-menu.dropdown-menu-right{ role: :menu }
|
= render "actions/share", answer: a
|
||||||
%a.dropdown-item{ href: twitter_share_url(a), target: "_blank" }
|
|
||||||
%i.fa.fa-fw.fa-twitter
|
|
||||||
= t(".share.twitter")
|
|
||||||
%a.dropdown-item{ href: tumblr_share_url(a), target: "_blank" }
|
|
||||||
%i.fa.fa-fw.fa-tumblr
|
|
||||||
= t(".share.tumblr")
|
|
||||||
%a.dropdown-item{ href: "#", name: "ab-share" }
|
|
||||||
= t(".share.other")
|
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
.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/answer", answer: a
|
||||||
- if Subscription.is_subscribed(current_user, a)
|
|
||||||
-# fun joke should subscribe?
|
|
||||||
%a.dropdown-item{ href: "#", data: { a_id: a.id, action: "ab-submarine", torpedo: "no" } }
|
|
||||||
%i.fa.fa-anchor
|
|
||||||
= t(".unsubscribe")
|
|
||||||
- else
|
|
||||||
%a.dropdown-item{ href: "#", data: { a_id: a.id, action: "ab-submarine", torpedo: "yes" } }
|
|
||||||
%i.fa.fa-anchor
|
|
||||||
= t(".subscribe")
|
|
||||||
- if privileged? a.user
|
|
||||||
%a.dropdown-item.text-danger{ href: "#", data: { a_id: a.id, action: "ab-destroy" } }
|
|
||||||
%i.fa.fa-trash-o
|
|
||||||
= t(".return")
|
|
||||||
- unless a.user == current_user
|
|
||||||
%a.dropdown-item{ href: "#", data: { a_id: a.id, action: "ab-report" } }
|
|
||||||
%i.fa.fa-exclamation-triangle
|
|
||||||
= t("voc.report")
|
|
||||||
- if current_user.has_role? :administrator
|
|
||||||
%a.dropdown-item{ href: rails_admin_path_for_resource(a), target: "_blank" }
|
|
||||||
%i.fa.fa-gears
|
|
||||||
= t("voc.view_in_rails_admin")
|
|
||||||
|
|
|
@ -34,18 +34,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/comment", comment: comment, answer: a
|
||||||
%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")
|
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
.form-group.has-feedback.comment__input-group{ name: "ab-comment-new-group", data: { a_id: a.id } }
|
.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 } }
|
%input.form-control.comment__input{ type: :text, placeholder: t(".placeholder"), name: "ab-comment-new", data: { a_id: a.id } }
|
||||||
|
|
|
@ -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") }
|
||||||
|
|
|
@ -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 } }
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -69,6 +69,15 @@ en:
|
||||||
two_factor_authentication:
|
two_factor_authentication:
|
||||||
heading: "Two-factor authentication"
|
heading: "Two-factor authentication"
|
||||||
otp_attempt: "Please enter the code from your authenticator app"
|
otp_attempt: "Please enter the code from your authenticator app"
|
||||||
|
actions:
|
||||||
|
answer:
|
||||||
|
return: "Return to Inbox"
|
||||||
|
comment:
|
||||||
|
view_smiles: "View comment smiles"
|
||||||
|
share:
|
||||||
|
twitter: "Share on Twitter"
|
||||||
|
tumblr: "Share on Tumblr"
|
||||||
|
other: "Share on other apps..."
|
||||||
announcement:
|
announcement:
|
||||||
index:
|
index:
|
||||||
title: :activerecord.models.announcement.other
|
title: :activerecord.models.announcement.other
|
||||||
|
@ -89,17 +98,9 @@ en:
|
||||||
actions:
|
actions:
|
||||||
share:
|
share:
|
||||||
title: "Share"
|
title: "Share"
|
||||||
twitter: "Share on Twitter"
|
|
||||||
tumblr: "Share on Tumblr"
|
|
||||||
other: "Share on other apps..."
|
|
||||||
subscribe: "Subscribe"
|
|
||||||
unsubscribe: "Unsubscribe"
|
|
||||||
return: "Return to Inbox"
|
|
||||||
comments:
|
comments:
|
||||||
none: "There are no comments yet."
|
none: "There are no comments yet."
|
||||||
placeholder: "Comment..."
|
placeholder: "Comment..."
|
||||||
actions:
|
|
||||||
view_smiles: "View comment smiles"
|
|
||||||
smiles:
|
smiles:
|
||||||
none: "No one smiled this yet."
|
none: "No one smiled this yet."
|
||||||
application:
|
application:
|
||||||
|
|
|
@ -14,6 +14,8 @@ en:
|
||||||
logout: "Sign out"
|
logout: "Sign out"
|
||||||
save: "Save changes"
|
save: "Save changes"
|
||||||
show_anonymous_questions: "Show all questions from this user"
|
show_anonymous_questions: "Show all questions from this user"
|
||||||
|
subscribe: "Subscribe"
|
||||||
|
unsubscribe: "Unsubscribe"
|
||||||
register: "Sign up"
|
register: "Sign up"
|
||||||
report: "Report"
|
report: "Report"
|
||||||
terms: "Terms of Service"
|
terms: "Terms of Service"
|
||||||
|
|
Loading…
Reference in New Issue