File tree Expand file tree Collapse file tree 2 files changed +16
-25
lines changed Expand file tree Collapse file tree 2 files changed +16
-25
lines changed Original file line number Diff line number Diff line change @@ -219,39 +219,26 @@ export default Vue.extend({
219
219
},
220
220
saveLessonData() {
221
221
if (this .lessonId === ' ' ) {
222
- this .addLesson ()
222
+ this .registerLesson ()
223
223
} else {
224
- this .setLesson ()
224
+ this .changeLesson ()
225
225
}
226
226
},
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 ()
242
229
vxm .classData
243
- .editLessonData ( lessonData )
230
+ .changeLesson ({ editData: lessonData , id: this . lessonId } )
244
231
.then (() => {
245
232
this .$emit (' collapse' )
246
233
})
247
234
.catch (() => {
248
235
this .error = true
249
236
})
250
237
},
251
- addLesson () {
238
+ registerLesson () {
252
239
const lessonData: classData .Lesson = this .buildLessonData ()
253
240
vxm .classData
254
- .addLesson (lessonData )
241
+ .registerLesson (lessonData )
255
242
.then (() => {
256
243
this .$emit (' collapse' )
257
244
})
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
103
103
}
104
104
105
105
@action
106
- public async addLesson ( lessonData : classData . Lesson ) {
106
+ public async registerLesson ( lessonData : classData . Lesson ) {
107
107
const classIdStr = 'あけしめたす'
108
108
await firebase
109
109
. firestore ( )
@@ -118,16 +118,20 @@ export class ClassDataStore extends VuexModule implements classData.ClassData {
118
118
}
119
119
120
120
@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
+ } ) {
122
128
const classIdStr = 'あけしめたす'
123
- const docId = editData . docId
124
- delete editData . docId
125
129
await firebase
126
130
. firestore ( )
127
131
. collection ( 'classData' )
128
132
. doc ( classIdStr )
129
133
. collection ( 'Lessons' )
130
- . doc ( docId )
134
+ . doc ( id )
131
135
. set ( editData )
132
136
. catch ( ( ) => {
133
137
return Promise . reject ( new Error ( 'エラーによって処理に失敗しました' ) )
You can’t perform that action at this time.
0 commit comments