From 7a931aadcd2df63516685b564b0e31ff10d86232 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 3 Jul 2018 14:23:01 +0500 Subject: [PATCH] =?UTF-8?q?LIL-467=20=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D0=BE=D0=B9,=20=D0=B0=20=D0=BD=D0=B5=20'0'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/CourseRedactor.vue | 29 ++++++++++----------------- web/src/js/modules/api.js | 4 ++-- 2 files changed, 13 insertions(+), 20 deletions(-) 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,