From 65ee1918810faab7cb763440c43b8e91dd8fd38a Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Tue, 5 Dec 2023 21:21:57 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=AB=E3=81=8A=E3=81=84=E3=81=A6=E4=BC=91?= =?UTF-8?q?=E4=BC=9A=E4=B8=AD=E3=81=AE=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E4=BC=91=E4=BC=9A=E7=B5=8C=E9=81=8E=E6=97=A5=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 15 +++++++++------ app/models/user.rb | 4 ++++ app/views/api/users/_list_user.json.jbuilder | 5 +++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index 2e41b00ec5f..e1c7ac7fe82 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -6,6 +6,9 @@ v-if='currentUser.mentor && user.student_or_trainee && !user.active') | 1ヶ月以上ログインがありません header.users-item__header + div( + v-if='(currentUser.mentor || currentUser.admin) && user.roles.includes("hibernationed")') + | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) .users-item__header-inner .users-item__header-start .users-item__icon @@ -16,12 +19,12 @@ :alt='user.icon_title', :src='user.avatar_url') .users-item__header-end - .card-list-item__rows - .card-list-item__row - .card-list-item-title - a.card-list-item-title__title.is-lg.a-text-link( - :href='user.url') - | {{ loginName }} + .card-list-item__rows + .card-list-item__row + .card-list-item-title + a.card-list-item-title__title.is-lg.a-text-link( + :href='user.url') + | {{ loginName }} a( v-if='user.company && user.company.logo_url', :href='user.company.url') diff --git a/app/models/user.rb b/app/models/user.rb index 87b327f8cd7..b604d7028c3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -712,6 +712,10 @@ def last_hibernation hibernations.order(:created_at).last end + def hibernation_elapsed_days + (Time.zone.today - hibernated_at.to_date).to_i + end + def update_last_returned_at! hibernation = last_hibernation hibernation.returned_at = Date.current diff --git a/app/views/api/users/_list_user.json.jbuilder b/app/views/api/users/_list_user.json.jbuilder index 78fc3bd8f14..88d5ba5e72d 100644 --- a/app/views/api/users/_list_user.json.jbuilder +++ b/app/views/api/users/_list_user.json.jbuilder @@ -39,3 +39,8 @@ json.company do json.url company_url(user.company) end end + +if user.hibernated? + json.hibernated_at l(user.hibernated_at, format: :year_and_date) + json.hibernation_elapsed_days user.hibernation_elapsed_days +end From 74a94d1644dae031d96f64c9e05c6ad4d05b7ebd Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Thu, 7 Dec 2023 09:02:24 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=A8=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index e1c7ac7fe82..aadd7cafef7 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -6,7 +6,7 @@ v-if='currentUser.mentor && user.student_or_trainee && !user.active') | 1ヶ月以上ログインがありません header.users-item__header - div( + .is-only-mentor( v-if='(currentUser.mentor || currentUser.admin) && user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) .users-item__header-inner @@ -19,12 +19,12 @@ :alt='user.icon_title', :src='user.avatar_url') .users-item__header-end - .card-list-item__rows - .card-list-item__row - .card-list-item-title - a.card-list-item-title__title.is-lg.a-text-link( - :href='user.url') - | {{ loginName }} + .card-list-item__rows + .card-list-item__row + .card-list-item-title + a.card-list-item-title__title.is-lg.a-text-link( + :href='user.url') + | {{ loginName }} a( v-if='user.company && user.company.logo_url', :href='user.company.url') From 19aca7090ad36c6b830c62d7fe99225c5ba34fe0 Mon Sep 17 00:00:00 2001 From: machida Date: Sat, 16 Dec 2023 18:02:17 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=88=86=E5=B2=90?= =?UTF-8?q?=E3=81=A8=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3=E3=82=92=E5=BE=AE?= =?UTF-8?q?=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 13 +++++++------ .../application/blocks/user/_users-item.sass | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index aadd7cafef7..07da6c56ff4 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -2,13 +2,14 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 .users-item .users-item__inner.a-card - .users-item__inactive-message.is-only-mentor( - v-if='currentUser.mentor && user.student_or_trainee && !user.active') - | 1ヶ月以上ログインがありません - header.users-item__header - .is-only-mentor( - v-if='(currentUser.mentor || currentUser.admin) && user.roles.includes("hibernationed")') + .users-item__inactive-message-container(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') + .users-item__inactive-message.is-only-mentor(v-if='user.roles.includes("retired")') + | 退会しました + .users-item__inactive-message.is-only-mentor(v-else-if='user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) + .users-item__inactive-message.is-only-mentor(v-else-if='!user.active') + | 1ヶ月以上ログインがありません + header.users-item__header .users-item__header-inner .users-item__header-start .users-item__icon diff --git a/app/javascript/stylesheets/application/blocks/user/_users-item.sass b/app/javascript/stylesheets/application/blocks/user/_users-item.sass index 19daf3998d2..08600e85124 100644 --- a/app/javascript/stylesheets/application/blocks/user/_users-item.sass +++ b/app/javascript/stylesheets/application/blocks/user/_users-item.sass @@ -2,11 +2,11 @@ height: 100% .users-item__inactive-message - background-color: var(--background) + background-color: var(--disabled) +text-block(.625rem 1.4, center) padding: .25rem +border-radius(top, .1875rem) - margin-bottom: -.25rem + margin: -1px -1px -.25rem .users-item__inner +media-breakpoint-up(md) From 57699f0d624a3dd0c5122d87e996bf8ab642763f Mon Sep 17 00:00:00 2001 From: machida Date: Sat, 16 Dec 2023 18:05:26 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E4=BB=A5=E5=A4=96=E3=81=AB=E3=81=AF=E9=9A=A0=E3=81=99=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=82=AF=E3=81=AB=E4=BD=BF=E3=81=86=E3=82=AF?= =?UTF-8?q?=E3=83=A9=E3=82=B9=E4=BB=98=E3=81=AE=E4=BD=8D=E7=BD=AE=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=80=81=E4=BD=99=E7=99=BD=E5=BE=AE=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 8 ++++---- .../stylesheets/application/blocks/user/_users-item.sass | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index 07da6c56ff4..c1dfa90a3ff 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -2,12 +2,12 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 .users-item .users-item__inner.a-card - .users-item__inactive-message-container(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') - .users-item__inactive-message.is-only-mentor(v-if='user.roles.includes("retired")') + .users-item__inactive-message-container.is-only-mentor(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') + .users-item__inactive-message(v-if='user.roles.includes("retired")') | 退会しました - .users-item__inactive-message.is-only-mentor(v-else-if='user.roles.includes("hibernationed")') + .users-item__inactive-message(v-else-if='user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) - .users-item__inactive-message.is-only-mentor(v-else-if='!user.active') + .users-item__inactive-message(v-else-if='!user.active') | 1ヶ月以上ログインがありません header.users-item__header .users-item__header-inner diff --git a/app/javascript/stylesheets/application/blocks/user/_users-item.sass b/app/javascript/stylesheets/application/blocks/user/_users-item.sass index 08600e85124..32ac6317bb2 100644 --- a/app/javascript/stylesheets/application/blocks/user/_users-item.sass +++ b/app/javascript/stylesheets/application/blocks/user/_users-item.sass @@ -16,7 +16,7 @@ .users-item__header +position(relative) - padding: 1rem + padding: .75rem 1rem border-bottom: solid 1px var(--border-tint) .users-item__header-inner From 9d9e56658bce42718eadc616f09082598f3f078b Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sun, 17 Dec 2023 14:44:48 +0900 Subject: [PATCH 5/6] =?UTF-8?q?vue=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/user.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/components/user.vue b/app/javascript/components/user.vue index c1dfa90a3ff..ef8e49fa2c8 100644 --- a/app/javascript/components/user.vue +++ b/app/javascript/components/user.vue @@ -2,10 +2,12 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 .users-item .users-item__inner.a-card - .users-item__inactive-message-container.is-only-mentor(v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') + .users-item__inactive-message-container.is-only-mentor( + v-if='(currentUser.mentor || currentUser.admin) && user.student_or_trainee') .users-item__inactive-message(v-if='user.roles.includes("retired")') | 退会しました - .users-item__inactive-message(v-else-if='user.roles.includes("hibernationed")') + .users-item__inactive-message( + v-else-if='user.roles.includes("hibernationed")') | 休会中: {{ user.hibernated_at }}〜({{ user.hibernation_elapsed_days }}日経過) .users-item__inactive-message(v-else-if='!user.active') | 1ヶ月以上ログインがありません From 3f9e802055a9eb1c2ce7e77522bb41c6fcaabe5d Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Sun, 17 Dec 2023 21:25:13 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/user_test.rb | 10 ++++++++++ test/system/users_test.rb | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 10fd634aa2a..0c3de7535f7 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -623,6 +623,16 @@ class UserTest < ActiveSupport::TestCase assert target.sent_student_followup_message end + test '#hibernation_elapsed_days' do + user = users(:kyuukai) + + travel_to Time.zone.local(2020, 1, 10) do + elapsed_days = user.hibernation_elapsed_days + + assert assert_equal 9, elapsed_days + end + end + test '#country_name' do assert_equal '日本', users(:kimura).country_name assert_equal '米国', users(:tom).country_name diff --git a/test/system/users_test.rb b/test/system/users_test.rb index 589349354a3..5cd191b74a8 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -629,4 +629,18 @@ class UsersTest < ApplicationSystemTestCase visit_with_auth user_path(user), 'komagata' assert_no_text '休会中 / 休会から' end + + test 'show retirement message on users page' do + visit_with_auth users_path, 'komagata' + click_link('退会') + assert_selector '.users-item__inactive-message-container.is-only-mentor .users-item__inactive-message', text: '退会しました' + end + + test 'show hibernation elasped days message on users page' do + travel_to Time.zone.local(2020, 1, 11, 0, 0, 0) do + visit_with_auth users_path, 'komagata' + click_link('休会') + assert_selector '.users-item__inactive-message-container.is-only-mentor .users-item__inactive-message', text: '休会中: 2020年01月01日〜(10日経過)' + end + end end