diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue index 3ba9359e..1a9a0779 100644 --- a/web/src/components/CourseRedactor.vue +++ b/web/src/components/CourseRedactor.vue @@ -619,6 +619,14 @@ $(window).scrollTop(elementTop); }); }, + processCourseJson(data) { + this.course = api.convertCourseJson(data); + this.course.live = this.live; + this.lessons = data.lessons.map((lessonJson) => { + return api.convertLessonJson(lessonJson); + }); + this.course.duration = this.course.duration || ''; + }, loadCourseDraft() { //console.log('loadCourseDraft'); if(this.live) { return; } @@ -628,12 +636,8 @@ response .then((response) => { - this.course = api.convertCourseJson(response.data); - this.course.live = this.live; + this.processCourseJson(response.data); this.courseLoading = false; - this.lessons = response.data.lessons.map((lessonJson) => { - return api.convertLessonJson(lessonJson); - }); }) .catch((err) => { this.courseLoading = false; @@ -653,21 +657,10 @@ } request .then((response) => { - this.course = api.convertCourseJson(response.data); - this.course.live = this.live; - - /* if (this.live && this.course.date) { - this.course.date = _.find(this.scheduleOptions, (item) => { - return item.value == this.course.date; - }) - } */ - + this.processCourseJson(response.data); this.$nextTick(() => { this.courseLoading = false; }); - this.lessons = response.data.lessons.map((lessonJson) => { - return api.convertLessonJson(lessonJson); - }); }) .catch((err) => { this.courseLoading = false; @@ -1025,7 +1018,7 @@ }, displayPrice: { get: function () { - return this.course.is_paid ? (this.course.price || 0) : 0; + return this.course.is_paid ? (this.course.price || '') : ''; }, set: function (value) { this.course.price = value || 0; diff --git a/web/src/js/modules/api.js b/web/src/js/modules/api.js index 36dc5f99..31787852 100644 --- a/web/src/js/modules/api.js +++ b/web/src/js/modules/api.js @@ -107,9 +107,9 @@ export const api = { author: courseObject.author ? courseObject.author : null, short_description: courseObject.short_description, category: courseObject.category, - price: courseObject.is_paid ? courseObject.price : 0, + price: courseObject.is_paid && courseObject.price || 0, deferred_start_at: deferredStart, - duration: courseObject.duration, + duration: courseObject.duration || 0, is_featured: courseObject.is_featured, slug: courseObject.url, date: (courseObject.date) ? courseObject.date.value:null,