Skip to content
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

「プログラミング経験」を複数選択可能なチェックボックス形式へ変更 #7970

Merged
merged 15 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def user_params
:twitter_account, :facebook_url, :blog_url,
:password, :password_confirmation, :job,
:organization, :os, :study_place,
:experience, :company_id,
{ experiences: [] }, :company_id,
:trainee, :job_seeking, :nda,
:graduated_on, :retired_on, :free,
:job_seeker, :github_collaborator,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/current_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def user_params
:github_account, :twitter_account, :facebook_url,
:blog_url, :password, :password_confirmation,
:job, :organization, :os,
:experience, :editor, :other_editor, :company_id,
{ experiences: [] }, :editor, :other_editor, :company_id,
:nda, :avatar, :trainee,
:mail_notification, :job_seeker, :tag_list,
:after_graduation_hope, :training_ends_on, :profile_image,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def user_params
:github_account, :twitter_account,
:facebook_url, :blog_url, :password,
:password_confirmation, :job, :organization,
:os, :experience, :editor, :other_editor,
:os, { experiences: [] }, :editor, :other_editor,
:company_id, :nda, :avatar,
:trainee, :adviser, :job_seeker,
:tag_list, :after_graduation_hope, :feed_url,
Expand Down
10 changes: 9 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class User < ApplicationRecord
with_options if: -> { !adviser? && validation_context != :reset_password && validation_context != :retirement } do
validates :job, presence: true
validates :os, presence: true
validates :experience, presence: true
end

with_options if: -> { validation_context == :retirement } do
Expand Down Expand Up @@ -257,6 +256,15 @@ class User < ApplicationRecord
training_end
]

flag :experiences, %i[
html_css
ruby
rails
javascript
react
languages_other_than_ruby_and_javascript
]

scope :in_school, -> { where(graduated_on: nil) }
scope :graduated, -> { where.not(graduated_on: nil) }
scope :hibernated, -> { where.not(hibernated_at: nil) }
Expand Down
3 changes: 1 addition & 2 deletions app/views/api/users/_list_user.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
json.(user, :id, :login_name, :name, :description, :github_account, :twitter_account, :facebook_url, :blog_url, :job_seeker, :free, :job, :os, :experience, :email, :roles, :primary_role, :icon_title, :cached_completed_percentage, :completed_fraction, :graduated_on)
json.(user, :id, :login_name, :name, :description, :github_account, :twitter_account, :facebook_url, :blog_url, :job_seeker, :free, :job, :os, :email, :roles, :primary_role, :icon_title, :cached_completed_percentage, :completed_fraction, :graduated_on)
Copy link
Contributor Author

@motohiro-mm motohiro-mm Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apiで既存のexperienceカラムは使用されていませんでしたので、experiencesカラムに修正せず削除するようにしました。
dfda897

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@motohiro-mm
ありがとうございます!

json.tag_list user.tags.pluck(:name)
json.url user_url(user)
json.updated_at l(user.updated_at)
Expand All @@ -8,7 +8,6 @@ json.student user.student?
json.card user.card?
json.job_name t("activerecord.enums.user.job.#{user.job}")
json.os_name t("activerecord.enums.user.os.#{user.os}")
json.experience_name t("activerecord.enums.user.experience.#{user.experience}")
json.student_or_trainee user.student_or_trainee?
json.edit_admin_user_path edit_admin_user_path(user)
json.isFollowing current_user.following?(user)
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
= render 'users/form/after_graduation_hope', f:, user:
= render 'users/form/job', f: f
= render 'users/form/os', f: f
= render 'users/form/experience', f:
= render 'users/form/experiences', f:
- if from == :edit
= render 'users/form/editor', f:, user:
- if user.student?
Expand Down
8 changes: 5 additions & 3 deletions app/views/users/_user_secret_attributes.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
.user-metas__item-label
| 経験
.user-metas__item-value
- if user.experience
= t("activerecord.enums.user.experience.#{user.experience}")
- if user.experiences.raw.zero?
| 未経験
- else
| 回答なし
ul
- user.experiences.to_a.each do |e|
li = User.experiences.humans[e]
.user-metas__item
.user-metas__item-label
|
Expand Down
10 changes: 8 additions & 2 deletions app/views/users/form/_editor.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.form-item
= f.label :editor, class: 'a-form-label'
= t('activerecord.attributes.user.editor')
ul.block-checks.is-2-items
| #{t('activerecord.attributes.user.editor')}(任意)

.a-form-help
p
| もしプログラミング経験がある場合、その際に使用しているエディターをお知らせください。
| この情報はサポートを提供する際の参考にさせていただきます。

ul.block-checks.is-2-items.mt-4
- editors = User.editors.keys
- editors.each do |editor|
li.block-checks__item
Expand Down
7 changes: 0 additions & 7 deletions app/views/users/form/_experience.html.slim

This file was deleted.

17 changes: 17 additions & 0 deletions app/views/users/form/_experiences.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.form-item
= f.label :experiences, 'プログラミング経験(複数選択可)', class: 'a-form-label'

.a-form-help
p
| プログラミング経験の有無について、以下のいずれかに該当する場合は該当する
| 項目にチェックを入れてください。多くの方はどの項目にも該当しない「未経験」であるため、
| 心配なさらずにご回答ください。
| この情報は他のフィヨルドブートキャンプの参加者に公開されることはありません。

ul.block-checks.is-2-items.mt-4
= f.collection_check_boxes :experiences, User.experiences.pairs, :second, :first, class: 'label-checkbox' do |b|
li.block-checks__item
.a-block-check.is-checkbox
= b.check_box(class: 'a-toggle-checkbox')
= b.label(class: 'a-block-check__label is-ta-left')
= b.text
10 changes: 7 additions & 3 deletions app/views/users/form/_job_seeker.html.slim
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.form-item
= f.label :job_seeker, class: 'a-form-label'
= f.label :job_seeker, class: 'a-form-label' do
| #{User.human_attribute_name :job_seeker}(任意)
ul.block-checks.is-1-item
li.block-checks__item
.a-block-check.is-checkbox
= f.check_box :job_seeker, class: 'a-toggle-checkbox'
= f.label :job_seeker, class: 'a-block-check__label is-ta-left' do
= User.human_attribute_name :job_seeker
| 就職サポートを希望する
.a-form-help
p
| 就職を希望する場合は、就職相談や就職先企業の紹介を行います(フィヨルドブートキャンプが紹介する企業に就職することが必須ではありません)。状況に合わせていつでも変更できます。この情報は他のフィヨルドブートキャンプ参加者には公開されません。
| 就職サポートを希望する場合、就職相談、提出書類のレビュー、
| 面接対策、企業の紹介など、就職に関する広範なサポートを提供します。
| 状況に応じて、サポートの内容をいつでも変更することが可能です。
| この情報は他のフィヨルドブートキャンプ参加者には公開されません。
3 changes: 2 additions & 1 deletion app/views/users/form/_os.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
= f.label :os, '学習に使うマシン・OS を選択してください', class: 'a-form-label is-required'
.a-form-help.mb-4
p
| この情報は他のフィヨルドブートキャンプ参加者に公開されます
| この情報はサポートを提供する際の参考にさせていただきます
| 学習に使うマシン・OS が変わりましたら、この情報を更新してください。
| この情報は他のフィヨルドブートキャンプ参加者に公開されます。
.form-item__groups
.form-item-group
.form-item-group__header
Expand Down
3 changes: 2 additions & 1 deletion app/views/users/form/_sns.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
| GitHub アカウントを登録する
.a-form-help
p
| GitHub アカウントを登録すると、GitHub アカウントを使ってワンクリックでログインができるようになります。
| GitHub アカウントを登録すると、GitHub アカウントを使ってワンクリックで
| ログインができるようになります。
.form-item
= f.label :twitter_account, class: 'a-form-label'
.form-item__mention-input
Expand Down
11 changes: 10 additions & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ ja:
os: 利用OS
study_place: 主な学習場所
experience: プログラミング経験
experiences: プログラミング経験
editor: 使用しているエディタ
organization: 現在の所属組織
company: 企業
Expand All @@ -93,7 +94,7 @@ ja:
satisfaction: 満足度
opinion: ご意見
mail_notification: メール通知
job_seeker: 就職を希望する
job_seeker: 就職サポート
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらの修正はデザイン修正時にmachidaさんに修正していただいた部分で、今回のissueには直接関係のない部分です。

github_collaborator: GitHubチーム
tag_list: タグ
training_ends_on: 研修終了日
Expand Down Expand Up @@ -422,6 +423,14 @@ ja:
cost: 受講料が高いから
job_change: 転職や引っ越しなど環境の変化によって学びが継続できなくなったから
training_end: 企業研修で利用をしていて研修期間が終了したため
experiences:
inexperienced: 未経験
html_css: HTML/CSSの経験あり
ruby: Rubyの経験あり
rails: Railsの経験あり
javascript: JavaScriptの経験あり
react: Reactの経験あり
languages_other_than_ruby_and_javascript: Ruby、JS以外の言語経験あり
notification:
announcement: お知らせ
mention: メンション
Expand Down
23 changes: 23 additions & 0 deletions db/data/20240718110343_copy_experience_to_experiences_for_user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

class CopyExperienceToExperiencesForUser < ActiveRecord::Migration[6.1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

def up
User.find_each do |user|
case user.experience
when 'rails'
user.experiences.set(:rails)
when 'ruby'
user.experiences.set(:ruby)
when 'other_ruby'
user.experiences.set(:languages_other_than_ruby_and_javascript)
when 'html_css'
user.experiences.set(:html_css)
end
user.save!(validate: false)
end
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
Loading