Skip to content

Commit

Permalink
Merge pull request #8033 from fjordllc/chore/answer-non-vue-conversion
Browse files Browse the repository at this point in the history
Q&AのAnswer部分を非Vue化
  • Loading branch information
komagata authored Jan 5, 2025
2 parents d3f7c76 + 1f4ea05 commit 1011a48
Show file tree
Hide file tree
Showing 16 changed files with 678 additions and 794 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create
if @answer.save
Newspaper.publish(:answer_create, { answer: @answer })
Newspaper.publish(:answer_save, { answer: @answer })
render :create, status: :created
render partial: 'questions/answer', locals: { question:, answer: @answer, user: current_user }, status: :created
else
head :bad_request
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/correct_answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create
Newspaper.publish(:answer_save, { answer: @answer })
Newspaper.publish(:correct_answer_save, { answer: @answer })
ChatNotifier.message("質問:「#{@answer.question.title}」のベストアンサーが選ばれました。\r#{url_for(@answer.question)}")
render json: @answer
head :ok
else
head :bad_request
end
Expand Down
25 changes: 25 additions & 0 deletions app/javascript/answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import initializeAnswer from './initializeAnswer'

document.addEventListener('DOMContentLoaded', () => {
const answerAnchor = location.hash
if (answerAnchor) {
setTimeout(() => {
const anchorElement = document.querySelector(answerAnchor)
if (anchorElement) {
anchorElement.scrollIntoView({ behavior: 'instant' })
}
}, 300)
}

const answers = document.querySelectorAll('.answer')
const loadingContent = document.querySelector('.loading-content')
const answerContent = document.querySelector('.answer-content')
if (answers) {
loadingContent.style.display = 'none'
answerContent.style.display = 'block'

answers.forEach((answer) => {
initializeAnswer(answer)
})
}
})
263 changes: 0 additions & 263 deletions app/javascript/answer.vue

This file was deleted.

Loading

0 comments on commit 1011a48

Please sign in to comment.