Skip to content

Commit 95725f3

Browse files
authored
Merge branch 'development' into feature/177-tos
2 parents 0482e30 + 98e1d12 commit 95725f3

File tree

3 files changed

+42
-105
lines changed

3 files changed

+42
-105
lines changed

src/components/PeriodCard.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
</div>
1414
<v-row>
1515
<v-col v-for="(item, i) in classData" :key="i" cols="12" md="6">
16-
<content-card :lesson="item" />
16+
<content-card
17+
:lesson="item"
18+
:editable="editable"
19+
@clickEditButton="$emit('clickEditButton', item)"
20+
/>
1721
</v-col>
1822
</v-row>
1923
</div>
@@ -41,6 +45,10 @@ export default Vue.extend({
4145
classData: {
4246
type: Array as () => classData.LessonWithId[],
4347
default: () => []
48+
},
49+
editable: {
50+
type: Boolean,
51+
default: false
4452
}
4553
},
4654
computed: {

src/components/PeriodCardEditable.vue

Lines changed: 0 additions & 100 deletions
This file was deleted.

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(vxm.classData.lessonsOnCurrentDate, 'startTime')
103132
}
104133
},
105134
methods: {

0 commit comments

Comments
 (0)