Skip to content

Commit 0fb0df6

Browse files
authored
Merge pull request #646 from kaizumaki/feature/add-func-removeEmpty
参考動画登録時にthumbnailUrlがinvalidになる不具合を修正
2 parents 5610f60 + a7bff57 commit 0fb0df6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/components/EditLessonScreen.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import EditLessonScreenInner2 from '@/components/EditLessonScreenInner2.vue'
5959
import EditLessonScreenInner3 from '@/components/EditLessonScreenInner3.vue'
6060
import EditLessonScreenInner4 from '@/components/EditLessonScreenInner4.vue'
6161
import classData from '@/types/store/classData'
62+
import { removeEmpty } from '@/utils/remove'
6263
6364
type LessonDataType = {
6465
lessonId: string
@@ -234,7 +235,7 @@ export default Vue.extend({
234235
try {
235236
const lessonData: classData.Lesson = await this.buildLessonData()
236237
await vxm.classData.changeLesson({
237-
editData: lessonData,
238+
editData: removeEmpty(lessonData),
238239
id: this.lessonData.lessonId,
239240
})
240241
await this.$emit('collapse')

src/utils/remove.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import _ from 'lodash'
2+
3+
export const removeEmpty = (obj) => {
4+
return _.transform(obj, function (result, value, key) {
5+
if (!_.isEmpty(value) || _.isBoolean(value)) {
6+
if (typeof value === 'object') {
7+
result[key] = removeEmpty(value)
8+
} else {
9+
result[key] = value
10+
}
11+
} else if (_.isArray(value)) {
12+
result[key] = []
13+
}
14+
})
15+
}

0 commit comments

Comments
 (0)