Appease the dog overlords
This commit is contained in:
parent
14d841d31a
commit
8f0ae5171d
|
@ -1,4 +1,6 @@
|
||||||
require 'cgi'
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cgi"
|
||||||
|
|
||||||
class Ajax::AnswerController < AjaxController
|
class Ajax::AnswerController < AjaxController
|
||||||
include SocialHelper::TwitterMethods
|
include SocialHelper::TwitterMethods
|
||||||
|
@ -9,7 +11,7 @@ class Ajax::AnswerController < AjaxController
|
||||||
params.require :answer
|
params.require :answer
|
||||||
params.require :inbox
|
params.require :inbox
|
||||||
|
|
||||||
inbox = (params[:inbox] == 'true')
|
inbox = (params[:inbox] == "true")
|
||||||
|
|
||||||
if inbox
|
if inbox
|
||||||
inbox_entry = Inbox.find(params[:id])
|
inbox_entry = Inbox.find(params[:id])
|
||||||
|
@ -35,7 +37,6 @@ class Ajax::AnswerController < AjaxController
|
||||||
current_user.answer question, params[:answer]
|
current_user.answer question, params[:answer]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
@response[:message] = t(".success")
|
@response[:message] = t(".success")
|
||||||
@response[:success] = true
|
@response[:success] = true
|
||||||
|
@ -48,11 +49,11 @@ class Ajax::AnswerController < AjaxController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
unless inbox
|
return if inbox
|
||||||
|
|
||||||
# this assign is needed because shared/_answerbox relies on it, I think
|
# this assign is needed because shared/_answerbox relies on it, I think
|
||||||
@question = 1
|
@question = 1
|
||||||
@response[:render] = render_to_string(partial: 'answerbox', locals: { a: answer, show_question: false })
|
@response[:render] = render_to_string(partial: "answerbox", locals: { a: answer, show_question: false })
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -60,15 +61,13 @@ class Ajax::AnswerController < AjaxController
|
||||||
|
|
||||||
answer = Answer.find(params[:answer])
|
answer = Answer.find(params[:answer])
|
||||||
|
|
||||||
unless (current_user == answer.user) or (privileged? answer.user)
|
unless (current_user == answer.user) || (privileged? answer.user)
|
||||||
@response[:status] = :nopriv
|
@response[:status] = :nopriv
|
||||||
@response[:message] = t(".nopriv")
|
@response[:message] = t(".nopriv")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if answer.user == current_user
|
Inbox.create!(user: answer.user, question: answer.question, new: true, returning: true) if answer.user == current_user
|
||||||
Inbox.create!(user: answer.user, question: answer.question, new: true, returning: true)
|
|
||||||
end
|
|
||||||
answer.destroy
|
answer.destroy
|
||||||
|
|
||||||
@response[:status] = :okay
|
@response[:status] = :okay
|
||||||
|
|
|
@ -16,7 +16,7 @@ export default class extends Controller {
|
||||||
declare readonly configValue: Record<string, string>;
|
declare readonly configValue: Record<string, string>;
|
||||||
declare readonly autoCloseValue: boolean;
|
declare readonly autoCloseValue: boolean;
|
||||||
|
|
||||||
connect() {
|
connect(): void {
|
||||||
if (this.autoCloseValue) {
|
if (this.autoCloseValue) {
|
||||||
this.twitterTarget.addEventListener('click', () => this.close());
|
this.twitterTarget.addEventListener('click', () => this.close());
|
||||||
this.tumblrTarget.addEventListener('click', () => this.close());
|
this.tumblrTarget.addEventListener('click', () => this.close());
|
||||||
|
@ -27,7 +27,7 @@ export default class extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configValueChanged(value): void {
|
configValueChanged(value: Record<string, string>): void {
|
||||||
if (Object.keys(value).length === 0) {
|
if (Object.keys(value).length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,11 @@
|
||||||
%p.format-help.ms-auto.align-self-center.mt-2.mt-sm-0.text-center
|
%p.format-help.ms-auto.align-self-center.mt-2.mt-sm-0.text-center
|
||||||
= render "shared/format_link"
|
= render "shared/format_link"
|
||||||
- if current_user.sharing_enabled
|
- if current_user.sharing_enabled
|
||||||
.inbox-entry__sharing.text-center.p-2.justify-content-center.d-none{ data: { controller: "inbox-sharing", inbox_sharing_config_value: "{}", inbox_sharing_auto_close_value: current_user.sharing_autoclose.to_s }}
|
.inbox-entry__sharing.text-center.p-2.justify-content-center.d-none{
|
||||||
|
data: { controller: "inbox-sharing", inbox_sharing_config_value: "{}", inbox_sharing_auto_close_value: current_user.sharing_autoclose.to_s } }
|
||||||
%button.btn-close.inbox-entry__close{ data: { action: "inbox-sharing#close" } }
|
%button.btn-close.inbox-entry__close{ data: { action: "inbox-sharing#close" } }
|
||||||
%span.visually-hidden= t("voc.close")
|
%span.visually-hidden= t("voc.close")
|
||||||
%div.align-self-center
|
.align-self-center
|
||||||
%p.fs-3.fw-bold= t(".sharing.heading")
|
%p.fs-3.fw-bold= t(".sharing.heading")
|
||||||
%p
|
%p
|
||||||
%a.btn.btn-primary{ href: "https://twitter.com/intent/tweet?text=", data: { inbox_sharing_target: "twitter" }, target: "_blank" }
|
%a.btn.btn-primary{ href: "https://twitter.com/intent/tweet?text=", data: { inbox_sharing_target: "twitter" }, target: "_blank" }
|
||||||
|
|
Loading…
Reference in New Issue