Show toasts on pin/unpin
This commit is contained in:
parent
dcad9073a8
commit
520f7eb9ef
|
@ -3,6 +3,10 @@
|
||||||
class AnswerController < ApplicationController
|
class AnswerController < ApplicationController
|
||||||
before_action :authenticate_user!, only: %i[pin unpin]
|
before_action :authenticate_user!, only: %i[pin unpin]
|
||||||
|
|
||||||
|
include TurboStreamable
|
||||||
|
|
||||||
|
turbo_stream_actions :pin, :unpin
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@answer = Answer.includes(comments: %i[user smiles], question: [:user], smiles: [:user]).find(params[:id])
|
@answer = Answer.includes(comments: %i[user smiles], question: [:user], smiles: [:user]).find(params[:id])
|
||||||
@display_all = true
|
@display_all = true
|
||||||
|
@ -25,7 +29,12 @@ class AnswerController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(user_path(username: current_user.screen_name)) }
|
format.html { redirect_to(user_path(username: current_user.screen_name)) }
|
||||||
format.turbo_stream { render "pin", locals: { answer: } }
|
format.turbo_stream do
|
||||||
|
render turbo_stream: [
|
||||||
|
turbo_stream.update("ab-pin-#{answer.id}", partial: "actions/pin", locals: { answer: }),
|
||||||
|
render_toast(t(".success"))
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,7 +44,12 @@ class AnswerController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(user_path(username: current_user.screen_name)) }
|
format.html { redirect_to(user_path(username: current_user.screen_name)) }
|
||||||
format.turbo_stream { render "pin", locals: { answer: } }
|
format.turbo_stream do
|
||||||
|
render turbo_stream: [
|
||||||
|
turbo_stream.update("ab-pin-#{answer.id}", partial: "actions/pin", locals: { answer: }),
|
||||||
|
render_toast(t(".success"))
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -212,3 +212,8 @@ en:
|
||||||
timeline:
|
timeline:
|
||||||
public:
|
public:
|
||||||
title: "Public Timeline"
|
title: "Public Timeline"
|
||||||
|
answer:
|
||||||
|
pin:
|
||||||
|
success: "This answer will now appear at the top of your profile."
|
||||||
|
unpin:
|
||||||
|
success: "This answer will no longer be pinned to the top of your profile."
|
||||||
|
|
Loading…
Reference in New Issue