Skip to content

Commit a5288f2

Browse files
committed
changeLessonを分割代入で対応
resolve: #139 (comment)
1 parent e53ca5e commit a5288f2

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

src/components/EditingScreen.vue

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -219,39 +219,26 @@ export default Vue.extend({
219219
},
220220
saveLessonData() {
221221
if (this.lessonId === '') {
222-
this.addLesson()
222+
this.registerLesson()
223223
} else {
224-
this.setLesson()
224+
this.changeLesson()
225225
}
226226
},
227-
setLesson() {
228-
const lessonOnlyAddData: classData.Lesson = this.buildLessonData()
229-
const lessonData: classData.LessonWithId = {
230-
startTime: lessonOnlyAddData.startTime,
231-
endTime: lessonOnlyAddData.endTime,
232-
title: lessonOnlyAddData.title,
233-
subject: lessonOnlyAddData.subject,
234-
goal: lessonOnlyAddData.goal,
235-
description: lessonOnlyAddData.description,
236-
videos: lessonOnlyAddData.videos,
237-
pages: lessonOnlyAddData.pages,
238-
materials: lessonOnlyAddData.materials,
239-
isHidden: lessonOnlyAddData.isHidden,
240-
docId: this.lessonId
241-
}
227+
changeLesson() {
228+
const lessonData: classData.Lesson = this.buildLessonData()
242229
vxm.classData
243-
.editLessonData(lessonData)
230+
.changeLesson({ editData: lessonData, id: this.lessonId })
244231
.then(() => {
245232
this.$emit('collapse')
246233
})
247234
.catch(() => {
248235
this.error = true
249236
})
250237
},
251-
addLesson() {
238+
registerLesson() {
252239
const lessonData: classData.Lesson = this.buildLessonData()
253240
vxm.classData
254-
.addLesson(lessonData)
241+
.registerLesson(lessonData)
255242
.then(() => {
256243
this.$emit('collapse')
257244
})

src/store/modules/classData.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
103103
}
104104

105105
@action
106-
public async addLesson(lessonData: classData.Lesson) {
106+
public async registerLesson(lessonData: classData.Lesson) {
107107
const classIdStr = 'あけしめたす'
108108
await firebase
109109
.firestore()
@@ -118,16 +118,20 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
118118
}
119119

120120
@action
121-
public async editLessonData(editData: classData.LessonWithId) {
121+
public async changeLesson({
122+
editData,
123+
id
124+
}: {
125+
editData: classData.Lesson
126+
id: classData.LessonId
127+
}) {
122128
const classIdStr = 'あけしめたす'
123-
const docId = editData.docId
124-
delete editData.docId
125129
await firebase
126130
.firestore()
127131
.collection('classData')
128132
.doc(classIdStr)
129133
.collection('Lessons')
130-
.doc(docId)
134+
.doc(id)
131135
.set(editData)
132136
.catch(() => {
133137
return Promise.reject(new Error('エラーによって処理に失敗しました'))

0 commit comments

Comments
 (0)