-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FAQにカテゴリを追加する #7093
Merged
Merged
FAQにカテゴリを追加する #7093
Changes from all commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
a6e2b44
FAQモデルを作った
yuma-matsui 9bd837d
FAQモデル用のlocalesを追加した
yuma-matsui ac816ca
管理者ページにFAQの一覧表示、新規作成機能を追加した
yuma-matsui c1c5ab7
FAQの編集、更新機能を追加した
yuma-matsui 634ef8f
FAQの削除機能を追加した
yuma-matsui 0041891
faqに関するseedデータを用意した
yuma-matsui 372726f
FAQ一覧ページでFAQのデータを表示するようにした
yuma-matsui b5b7c50
FAQを作成した順で表示するようにした
yuma-matsui 4555b22
FAQの作成をMarkdownで行えるようにした
yuma-matsui 04a9757
FAQ一覧ページのシステムテストを書いた
yuma-matsui 2e41701
FAQHelperのテストを書いた
yuma-matsui 76e2b6b
管理ページのFAQに関するシステムテストを書いた
yuma-matsui 1a7d034
FAQの追加に伴う既存テストの修正
yuma-matsui 34bfb14
FAQ一覧ページのシステムテストを修正した
yuma-matsui 0fd3584
circleCIのテストを通すためにクラス名を変更した
yuma-matsui f3dd78e
FAQの表示を作成時間が古い順に変更した
yuma-matsui 04015a7
FAQHelperの実装を変更して常時?マークが1つだけ表示されるようにした
yuma-matsui 15a568b
本番環境にFAQのデータを投入するためのスクリプトファイルを用意した
yuma-matsui d9e9f62
ページ上部の表示漏れを修正した
yuma-matsui 067c205
FAQの詳細ページを用意した
yuma-matsui acf10f7
FAQ更新時のリダイレクト先を個別ページに変更した
yuma-matsui fd6d8e4
管理者ページでFAQタブをクリックしている状態でアクティブにならないバグを修正した
yuma-matsui 9282de8
詳細ページにヘッダーを追加した
yuma-matsui 772e3ee
FAQテーブルにpositionカラムを追加した
yuma-matsui 18eb608
管理ページでFAQの並び替えを行えるようにした
yuma-matsui f2c2437
circleCIを通すためにテストのクラス名を変更した
yuma-matsui d339cda
テスト名のタイポを修正した
yuma-matsui c2db540
FAQテーブルのanswerカラムをtext型に変更した
yuma-matsui 9763ca0
質問の入力フォームをtext_areaからinputに変更した
yuma-matsui ad6f76d
デザインの構造をざっと構築
machida c6e1cd1
Admin の FAQ詳細にデザイン入れた
machida d6a485c
新デザインを適用した
machida 3b694b8
FAQモデル用のlocalesを追加した
yuma-matsui ac9ef5d
FAQの編集、更新機能を追加した
yuma-matsui fbe7ba8
FAQ一覧ページでFAQのデータを表示するようにした
yuma-matsui 0fcf324
FAQの作成をMarkdownで行えるようにした
yuma-matsui 46a4f27
FAQの追加に伴う既存テストの修正
yuma-matsui 2057030
FAQHelperの実装を変更して常時?マークが1つだけ表示されるようにした
yuma-matsui 031df9e
FAQの詳細ページを用意した
yuma-matsui 712442f
デザインの構造をざっと構築
machida e77a8c2
ja.ymlにカテゴリを追加
sochi419 648dd45
クエリパラメータにカテゴリ情報を追加
sochi419 f5bba8b
adminページのfaqのradioボタンを実装(仮)
sochi419 23de8ca
formヘルパーを用いたradioボタンを実装
sochi419 9fafb73
編集画面、新規作成画面からカテゴリ選択できるようにした
sochi419 956bc03
ja.ymlに記載した文字を使った処理に修正
sochi419 3c02730
faqテーブルのcategoryにnot null制約を追加
sochi419 24a6530
category未選択時のエラー対応のため、Faqmodelにvalidateを追加
sochi419 0265936
seedのデータ修正、カテゴリタブをrenderを使って呼び出す処理に修正
sochi419 3a8ba09
rubocop対応
sochi419 334caab
コードの冗長部分を修正
sochi419 c61156c
rubocop違反を再修正
sochi419 aca203c
seedにtypoがあったので修正
sochi419 50e8044
test/fixtures/faqs.ymlのデータに、カテゴリ情報を追加
sochi419 2d43d82
既存のyumaさんが実装したfaq関連のtestが落ちてしまう問題を修正
sochi419 dbacd47
faqページでカテゴリ毎にfaqを表示する確認のtestを追加
sochi419 1577fa1
admin/faqの個別ページにカテゴリを追加
sochi419 db54741
faqs_categoryテーブルを作成, faqテーブルにあったcategoryのcalumnを削除
sochi419 a453364
DB構造の修正に伴い、model, controller, viewsを修正した
sochi419 891c0fb
test/fixtures/faqs.ymlの記述を修正
sochi419 20a5bf5
Zeitwork::NameErrorに対応
sochi419 6a7425a
ymlファイルに時間情報を追加、テストの一部を修正
sochi419 f282e6b
落ちるテストを修正
sochi419 81fe5b9
テーブルのカラムに、null制約を追加
sochi419 d485923
ymlファイルのデータの記述を修正、testを修正
sochi419 e0af99c
slim lintの指摘点を修正
sochi419 c46b643
nameのvalidateを追加
sochi419 2cb8d29
モデル名を変更
sochi419 c62bacf
モデル名の修正に合わせて、DBのカラム名を変更。
sochi419 69f5fb5
controller名とファイル名変更、nameカラムにunique制約追加
sochi419 e7b07a8
データの記載場所をviews → controllerに移動
sochi419 3a7b55b
enumを使った処理に変更 faqs_categoriesテーブルのデータを使った処理群とテーブルを削除
sochi419 e08d6e0
slimLint違反を修正
sochi419 4b4b09b
FAQのPCでの見た目を作成
machida ec58966
FAQにデザインを入れた
machida 3b091a6
FAQに関する細かいデザイン調整
machida 608a48c
radio input を隠した
machida ff3c38e
不要な記述を削除
sochi419 ac682c7
デザイン修正影響で通らなくなったテストを修正
sochi419 4b0858d
admin側のFAQのshowを削除
sochi419 855db3f
FAQページのカテゴリタブをeach文で簡略化
sochi419 c6c51c6
lintエラーを解消
sochi419 84b519b
モバイル表示されるselectタグの選択肢を日本語化、カテゴリを選択しても「全て」になったままだった不具合を修正
sochi419 8a509fb
セレクトタブでカテゴリ選択すると、即座にページが切り替わるよう修正
sochi419 fa010f8
enum削除、faq_categoryモデルを使った処理に変更
sochi419 ab1dc78
enum削除に合わせてtestを修正
sochi419 0264bbd
rubocop指摘点を修正
sochi419 f8821c8
モバイル表示の不具合修正、lintエラー修正
sochi419 84e72e7
データ取得時に並び順を指定する処理を追加
sochi419 670c85f
モデル、テーブル名の変更
sochi419 10a30b5
新デザインを適用し、とりあえず動くようにした
machida 431f183
FAQデザイン更新
machida 0e778c2
FAQカテゴリーの管理画面を追加
komagata 9072ca4
不要になったテストの削除
komagata dd23a7e
FAQカテゴリーに関するテストを追加
komagata 3717493
使っていないroutesを削除
komagata f61c0bd
FAQ関連の失敗しているテストを修正
komagata 3481ba6
FAQにデザインを入れ、初期データのカテゴリを修正、管理画面のタブを整理した
machida de66a6e
UIの変更にテストを追従させた
komagata a4833bc
fixtureに不要な文字が混入していたのを修正
komagata 4b55446
スマホ時のフォームの微調整
machida File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class Admin::FAQCategories::FaqsController < AdminController | ||
before_action :set_faq_category, only: %i[index update] | ||
|
||
def index | ||
@faqs = @faq_category.faqs | ||
end | ||
|
||
def update | ||
faq = @faq_category.faqs.find(params[:id]) | ||
faq.insert_at(params[:faq][:insert_at].to_i) | ||
head :ok | ||
end | ||
|
||
private | ||
|
||
def set_faq_category | ||
@faq_category = FAQCategory.find(params[:faq_category_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
class Admin::FAQCategoriesController < AdminController | ||
before_action :set_faq_category, only: %i[edit update destroy] | ||
|
||
def index | ||
@faq_categories = FAQCategory.order(:created_at) | ||
end | ||
|
||
def new | ||
@faq_category = FAQCategory.new | ||
end | ||
|
||
def create | ||
@faq_category = FAQCategory.new(faq_category_params) | ||
|
||
if @faq_category.save | ||
redirect_to admin_faq_categories_path, notice: 'FAQカテゴリーを作成しました。' | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
def edit; end | ||
|
||
def update | ||
if params[:faq_category][:insert_at] | ||
@faq_category.insert_at(params[:faq_category][:insert_at].to_i) | ||
return head :ok | ||
end | ||
|
||
if @faq_category.update(faq_category_params) | ||
redirect_to admin_faq_categories_path, notice: 'FAQカテゴリーを更新しました。' | ||
else | ||
render 'edit' | ||
end | ||
end | ||
|
||
def destroy | ||
@faq_category.destroy | ||
redirect_to admin_faq_categories_path, notice: 'FAQカテゴリーを削除しました。' | ||
end | ||
|
||
private | ||
|
||
def faq_category_params | ||
params.require(:faq_category).permit(:name, :insert_at) | ||
end | ||
|
||
def set_faq_category | ||
@faq_category = FAQCategory.find(params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
class Admin::FaqsController < AdminController | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FAQは略語なので複数形でもsが不要なようにInflectorを設定するのが良いかもです。 ActiveSupport::Inflectorでacronymを追加するときにはunderscoreメソッドへの影響にも注意が必要 #Ruby - Qiita |
||
before_action :set_faq, only: %i[show edit update destroy] | ||
before_action :set_faq_category, only: %i[index edit new update create] | ||
|
||
def index; end | ||
|
||
def new | ||
@faq = FAQ.new | ||
end | ||
|
||
def create | ||
@faq = FAQ.new(faq_params) | ||
|
||
if @faq.save | ||
redirect_to admin_faqs_path, notice: 'FAQを作成しました。' | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
def show; end | ||
def edit; end | ||
|
||
def update | ||
if @faq.update(faq_params) | ||
redirect_to admin_faqs_path, notice: 'FAQを更新しました。' | ||
else | ||
render 'edit' | ||
end | ||
end | ||
|
||
def destroy | ||
@faq.destroy | ||
redirect_to admin_faqs_path, notice: 'FAQを削除しました。' | ||
end | ||
|
||
private | ||
|
||
def faq_params | ||
params.require(:faq).permit(:answer, :question, :faq_category_id) | ||
end | ||
|
||
def set_faq | ||
@faq = FAQ.find(params[:id]) | ||
end | ||
|
||
def set_faq_category | ||
@faq_categories = FAQCategory.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module FAQHelper | ||
def format_question(question) | ||
"#{question.delete('??')}?" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Sortable from 'sortablejs' | ||
import Bootcamp from 'bootcamp' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const element = document.querySelector('#js-faq-category-sortable') | ||
if (!element) return | ||
|
||
Sortable.create(element, { | ||
handle: '.js-grab', | ||
onEnd(event) { | ||
const id = event.item.id | ||
const url = `/admin/faq_categories/${id}` | ||
const params = { | ||
faq_category: { | ||
insert_at: event.newIndex + 1 | ||
} | ||
} | ||
|
||
Bootcamp.patch(url, params).catch((error) => { | ||
console.error('Error while updating an order:', error) | ||
}) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Sortable from 'sortablejs' | ||
import Bootcamp from 'bootcamp' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const element = document.querySelector('#js-faq-sortable') | ||
if (!element) return | ||
|
||
Sortable.create(element, { | ||
handle: '.js-grab', | ||
onEnd(event) { | ||
const id = event.item.id | ||
const categoryId = event.item.dataset.faqCategoryId | ||
const url = `/admin/faq_categories/${categoryId}/faqs/${id}` | ||
const params = { | ||
faq: { | ||
insert_at: event.newIndex + 1 | ||
} | ||
} | ||
|
||
Bootcamp.patch(url, params).catch((error) => { | ||
console.error('Error while updating an order:', error) | ||
}) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
flex-direction: column | ||
gap: 2rem | ||
max-width: 40rem | ||
float: right | ||
margin: 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すみません、調べてみたらFAQのQが
Questions
ですでに複数形だったみたいです。https://ja.wikipedia.org/wiki/FAQ
じゃあモデルを単数形でどう表すのという話になっちゃうので、今回は統一感あればどちらでもよかったかもです😅(APIの方のコントローラ名と合ってればいいかな、と思います)
前回細かい指摘してしまってすみません🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
私もFAQのQが複数形であることを知りませんでした😅
元々複数形だったんですね〜
勉強になりました!
今回はこのまま複数形の命名にしようと思います。