Skip to content

Commit cd171ea

Browse files
committed
PeriodCardEditableをPeriodCardに置き換え・N時間目のグルーピングに対応
1 parent 0e13fd8 commit cd171ea

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

src/pages/edit/index.vue

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<template>
22
<div class="MainPage">
33
<div v-if="classData.lessonsOnCurrentDate.length">
4-
<period-card-editable :class-data="classData" @clickEditButton="doEdit" />
4+
<period-card
5+
v-for="(lessons, time, index) in lessonsGroupByPeriod"
6+
:key="index"
7+
:period="index"
8+
:time="time"
9+
:class-data="lessons"
10+
:editable="true"
11+
@clickEditButton="doEdit"
12+
/>
513
<ul class="Classes-List">
614
<li>おうちで時間割について</li>
715
<li>お問い合わせ</li>
@@ -44,20 +52,31 @@ import Vue from 'vue'
4452
import dayjs from 'dayjs'
4553
import isToday from 'date-fns/isToday'
4654
import { vxm } from '@/store'
47-
import PeriodCardEditable from '@/components/PeriodCardEditable.vue'
55+
import PeriodCard from '@/components/PeriodCard.vue'
4856
import SimpleBottomSheet from '@/components/SimpleBottomSheet.vue'
4957
import EditingScreen from '@/components/EditingScreen.vue'
50-
import { classData } from '~/types/store/classData'
58+
import { classData } from '@/types/store/classData'
59+
import LessonWithId = classData.LessonWithId
60+
61+
type LessonsGroupedBy = {
62+
[key: string]: LessonWithId[]
63+
}
5164
5265
type DataType = {
5366
classData: typeof vxm.classData
5467
editingMode: boolean
5568
editPageValue: object
5669
}
5770
71+
type Computed = {
72+
today: boolean
73+
dateTitle: string
74+
lessonsGroupByPeriod: LessonsGroupedBy
75+
}
76+
5877
export default Vue.extend({
5978
components: {
60-
PeriodCardEditable,
79+
PeriodCard,
6180
SimpleBottomSheet,
6281
EditingScreen
6382
},
@@ -100,6 +119,16 @@ export default Vue.extend({
100119
},
101120
dateTitle() {
102121
return dayjs(vxm.app.currentDate).format('M/D')
122+
},
123+
lessonsGroupByPeriod() {
124+
const groupBy = (targets: LessonWithId[], key: keyof LessonWithId) =>
125+
targets.reduce((acc: LessonsGroupedBy, currentLesson: LessonWithId) => {
126+
const valueToGroup = currentLesson[key].toString()
127+
acc[valueToGroup] = acc[valueToGroup] || []
128+
acc[valueToGroup].push(currentLesson)
129+
return acc
130+
}, {})
131+
return groupBy(this.classData.lessonsOnCurrentDate, 'startTime')
103132
}
104133
},
105134
methods: {

0 commit comments

Comments
 (0)