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

研修終了日が7日以内の研修生の提出物一覧をメンターのダッシュボードに表示 #8066

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
11 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
6 changes: 3 additions & 3 deletions app/javascript/components/ElapsedDays.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function ElapsedDays({ countProductsGroupedBy }) {
<div className="page-nav a-card">
<ol className="page-nav__items elapsed-days">
<li
className={`page-nav__item is-reply-deadline border-b-0 ${activeClass(
className={`page-nav__item is-danger border-b-0 ${activeClass(
countProductsGroupedBy(7)
)}`}>
<a className="page-nav__item-link" href="#7days-elapsed">
Expand All @@ -20,7 +20,7 @@ export default function ElapsedDays({ countProductsGroupedBy }) {
</a>
</li>
<li
className={`page-nav__item is-reply-alert border-b-0 ${activeClass(
className={`page-nav__item is-alert border-b-0 ${activeClass(
countProductsGroupedBy(6)
)}`}>
<a className="page-nav__item-link" href="#6days-elapsed">
Expand All @@ -30,7 +30,7 @@ export default function ElapsedDays({ countProductsGroupedBy }) {
</a>
</li>
<li
className={`page-nav__item is-reply-warning border-b-0 ${activeClass(
className={`page-nav__item is-warning border-b-0 ${activeClass(
countProductsGroupedBy(5)
)}`}>
<a className="page-nav__item-link" href="#5days-elapsed">
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/components/Products.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ function ProductHeader({
elapsedDaysId,
countProductsGroupedBy
}) {
let headerClass = 'card-header a-elapsed-days'
let headerClass = 'card-header a-highlight'
if (productsNDaysPassed.elapsed_days === 5) {
headerClass += ' is-reply-warning'
headerClass += ' is-warning'
} else if (productsNDaysPassed.elapsed_days === 6) {
headerClass += ' is-reply-alert'
headerClass += ' is-alert'
} else if (productsNDaysPassed.elapsed_days >= 7) {
headerClass += ' is-reply-deadline'
headerClass += ' is-danger'
}

const headerLabel = () => {
Expand Down
14 changes: 12 additions & 2 deletions app/javascript/product.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@
span.a-meta__label 更新
| {{ product.updated_at }}
.card-list-item-meta__item(
v-if='isUnassignedProductsPage || isDashboardPage')
v-if='isGroupedByDaysElapsed && (isUnassignedProductsPage || isDashboardPage)')
reckyy marked this conversation as resolved.
Show resolved Hide resolved
time.a-meta(v-if='untilNextElapsedDays(product) < 1')
span.a-meta__label 次の経過日数まで
| 1時間未満
time.a-meta(v-else-if='calcElapsedTimes(product) < 7')
span.a-meta__label 次の経過日数まで
| 約{{ untilNextElapsedDays(product) }}時間
.card-list-item-meta__item(v-else)
time.a-meta
span.a-meta__label 研修終了日
span.a-meta__value {{ product.user.training_ends_on }}
span.a-meta__value.is-danger(
v-if='product.user.training_remaining_days === 0')
| (本日研修最終日)
span.a-meta__value.is-danger(v-else)
| (あと{{ product.user.training_remaining_days }}日)

hr.card-list-item__row-separator(v-if='product.comments.size > 0')
.card-list-item__row(v-if='product.comments.size > 0')
Expand Down Expand Up @@ -123,7 +132,8 @@ export default {
product: { type: Object, required: true },
isMentor: { type: Boolean, required: true },
currentUserId: { type: Number, required: true },
displayUserIcon: { type: Boolean }
displayUserIcon: { type: Boolean },
isGroupedByDaysElapsed: { type: Boolean }
},
computed: {
roleClass() {
Expand Down
40 changes: 33 additions & 7 deletions app/javascript/products.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,61 @@

//- ダッシュボード
.is-vue(v-else-if='isDashboard')
template(v-if='traineeProductsEndDateWithin7Days.length > 0')
.a-card.h-auto
header.card-header.a-highlight.is-danger
h2.card-header__title
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maedana
研修終了日が7日以内の提出物一覧を追加しました。
スクリーンショット 2024-09-13 12 40 41

現在、カードタイトルに .a-elapsed-days のクラスを使用することで文字の中央寄せや文字間隔を他のカードと統一することができますが、elapsed days が経過日数を意味するため、今回追加したカードタイトルとは適切ではないと感じています。質問タイムで相談したように、クラス名の抽象化をお願いしたいです。

| 研修終了まで7日以内
span.card-header__count ({{ traineeProductsEndDateWithin7Days.length }})

.card-list
.card-list__items
product(
v-for='product in traineeProductsEndDateWithin7Days',
:key='product.id',
:product='product',
:currentUserId='currentUserId',
:isMentor='isMentor',
:display-user-icon='displayUserIcon',
:isGroupedByDaysElapsed='false')

template(v-for='product_n_days_passed in productsGroupedByElapsedDays') <!-- product_n_days_passedはn日経過の提出物 -->
.a-card.h-auto(
v-if='!isDashboard || (isDashboard && product_n_days_passed.elapsed_days >= 5)')
//- TODO 以下を共通化する
//- prettier-ignore: need space between v-if and id
header.card-header.a-elapsed-days(
header.card-header.a-highlight(
v-if='product_n_days_passed.elapsed_days === 0', id='0days-elapsed'
)
h2.card-header__title
| 今日提出
span.card-header__count
| ({{ countProductsGroupedBy(product_n_days_passed) }})
//- prettier-ignore: need space between v-else-if and id
header.card-header.a-elapsed-days.is-reply-warning(
header.card-header.a-highlight.is-warning(
v-else-if='product_n_days_passed.elapsed_days === 5', id='5days-elapsed'
)
h2.card-header__title
| {{ product_n_days_passed.elapsed_days }}日経過
span.card-header__count
| ({{ countProductsGroupedBy(product_n_days_passed) }})
//- prettier-ignore: need space between v-else-if and id
header.card-header.a-elapsed-days.is-reply-alert(
header.card-header.a-highlight.is-alert(
v-else-if='product_n_days_passed.elapsed_days === 6', id='6days-elapsed'
)
h2.card-header__title
| {{ product_n_days_passed.elapsed_days }}日経過
span.card-header__count
| ({{ countProductsGroupedBy(product_n_days_passed) }})
//- prettier-ignore: need space between v-else-if and id
header.card-header.a-elapsed-days.is-reply-deadline(
header.card-header.a-highlight.is-danger(
v-else-if='product_n_days_passed.elapsed_days === 7', id='7days-elapsed'
)
h2.card-header__title
| {{ product_n_days_passed.elapsed_days }}日以上経過
span.card-header__count
| ({{ countProductsGroupedBy(product_n_days_passed) }})
header.card-header.a-elapsed-days(
header.card-header.a-highlight(
v-else,
:id='elapsedDaysId(product_n_days_passed.elapsed_days)')
h2.card-header__title
Expand All @@ -70,7 +88,8 @@
:product='product',
:currentUserId='currentUserId',
:isMentor='isMentor',
:display-user-icon='displayUserIcon')
:display-user-icon='displayUserIcon',
:isGroupedByDaysElapsed='true')

.under-cards
.under-cards__links.mt-4.text-center.leading-normal.text-sm
Expand Down Expand Up @@ -106,7 +125,8 @@ export default {
return {
products: [],
loaded: false,
productsGroupedByElapsedDays: null
productsGroupedByElapsedDays: null,
traineeProductsEndDateWithin7Days: []
}
},
computed: {
Expand Down Expand Up @@ -153,6 +173,12 @@ export default {
this.products = []
json.products.forEach((product) => {
this.products.push(product)
if (
product.user.training_remaining_days >= 0 &&
product.user.training_remaining_days <= 7
) {
this.traineeProductsEndDateWithin7Days.push(product)
}
})
this.loaded = true
})
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/stylesheets/_common-imports.sass
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
@import "atoms/a-completion-message"
@import "atoms/a-count-badge"
@import "atoms/a-dropdown"
@import "atoms/a-elapsed-days"
@import "atoms/a-highlight"
@import "atoms/a-empty-message"
@import "atoms/a-file-input"
@import "atoms/a-form-frame"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.card-header.a-elapsed-days
letter-spacing: .125em
text-indent: .125em
.card-header.a-highlight
margin: -1px -1px 0
background-color: var(--base)
border: solid 1px var(--border)
Expand All @@ -12,14 +10,14 @@
+media-breakpoint-down(sm)
+text-block(.875rem 1.4, 600 center)
padding: .375rem .75rem
&.is-reply-warning
&.is-warning
background-color: var(--reply-warning-background)
border-color: var(--reply-warning-border)
&.is-reply-alert
&.is-alert
color: var(--reversal-text)
background-color: var(--reply-alert-background)
border-color: var(--reply-alert-border)
&.is-reply-deadline
&.is-danger
color: var(--reversal-text)
background-color: var(--reply-deadline-background)
border-color: var(--reply-deadline-border)
6 changes: 3 additions & 3 deletions app/javascript/stylesheets/shared/blocks/_page-nav.sass
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ a.page-nav__title-inner
font-weight: 700
&.is-current
+page-nav-current(var(--primary-tint), var(--primary), var(--primary-text), true)
&.is-reply-warning
&.is-warning
+page-nav-current(var(--reply-warning-background), var(--reply-warning-border), var(--default-text), false)
&.is-reply-alert
&.is-alert
+page-nav-current(var(--reply-alert-background), var(--reply-alert-border), var(--reversal-text), false)
&.is-reply-deadline
&.is-danger
+page-nav-current(var(--reply-deadline-background), var(--reply-deadline-border), var(--reversal-text), false)
&.is-inactive
position: static
Expand Down
72 changes: 72 additions & 0 deletions test/system/home_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,78 @@ def assert_events_count(event_label, count)
assert_no_text '今日提出(48)'
end

test 'show products of trainees whose training end date is within 7 days' do
reckyy marked this conversation as resolved.
Show resolved Hide resolved
user_kensyu_end_within_1_week = User.create!(
login_name: 'kensyu-end-within-1-week',
email: 'kensyu-end-within-1-week@fjord.jp',
password: 'testtest',
name: 'kensyu-end-within-1-week',
name_kana: 'ケンシュウ モウスコシデシュウリョウ',
company: companies(:company2),
description: 'test',
course: courses(:course1),
job: 'office_worker',
os: 'mac',
experience: 'inexperienced',
trainee: true,
training_ends_on: Time.current + 7.days
)
user_kensyu_end_within_24_hour = User.create!(
login_name: 'kensyu-end-within-24-hour',
email: 'kensyu-end-within-24-hour@fjord.jp',
password: 'testtest',
name: 'kensyu-end-within-24-hour',
name_kana: 'ケンシュウ キョウシュウリョウ',
company: companies(:company2),
description: 'test',
course: courses(:course1),
job: 'office_worker',
os: 'mac',
experience: 'inexperienced',
trainee: true,
training_ends_on: Time.current
)
practice1 = practices(:practice1)
practice2 = practices(:practice2)
product1 = Product.create!(
practice_id: practice1.id,
user_id: user_kensyu_end_within_1_week.id,
body: '研修終了日が1週間以内の研修生の提出物'
)
product2 = Product.create!(
practice_id: practice2.id,
user_id: user_kensyu_end_within_24_hour.id,
body: '今日研修が終了する研修生の提出物'
)

visit_with_auth '/', 'mentormentaro'
assert_text '研修終了まで7日以内(2)'
within all('.card-list-item')[0] do
assert_text 'OS X Mountain Lionをクリーンインストールするの提出物'
assert_text 'kensyu-end-within-1-week (ケンシュウ モウスコシデシュウリョウ)'
assert_selector '.a-meta__label', text: '提出'
assert_text I18n.l product1.created_at, format: :default
assert_selector '.a-meta__label', text: '更新'
assert_text I18n.l product1.updated_at, format: :default
assert_selector '.a-meta__label', text: '研修終了日'
assert_text I18n.l user_kensyu_end_within_1_week.training_ends_on, format: :default
assert_selector '.a-meta__value.is-danger', text: '(あと7日)'
assert_selector 'button', text: '担当する'
end
within all('.card-list-item')[1] do
assert_text 'Terminalの基礎を覚えるの提出物'
assert_text 'kensyu-end-within-24-hour (ケンシュウ キョウシュウリョウ)'
assert_selector '.a-meta__label', text: '提出'
assert_text I18n.l product2.created_at, format: :default
assert_selector '.a-meta__label', text: '更新'
assert_text I18n.l product2.updated_at, format: :default
assert_selector '.a-meta__label', text: '研修終了日'
assert_text I18n.l user_kensyu_end_within_24_hour.training_ends_on, format: :default
assert_selector '.a-meta__value.is-danger', text: '(本日研修最終日)'
assert_selector 'button', text: '担当する'
end
end

test 'display counts of passed almost 5days' do
visit_with_auth '/', 'mentormentaro'
assert_text "2件の提出物が、\n8時間以内に5日経過に到達します。"
Expand Down