|
|
|
|
@ -451,7 +451,7 @@ |
|
|
|
|
this.course.coverImageId = response.data.id; |
|
|
|
|
}) |
|
|
|
|
.catch((error) => { |
|
|
|
|
console.log('error', error); |
|
|
|
|
//console.log('error', error); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
if (file) { |
|
|
|
|
@ -528,7 +528,7 @@ |
|
|
|
|
window.scrollTo(0, 0); |
|
|
|
|
}, |
|
|
|
|
onSubmit() { |
|
|
|
|
console.log('submit'); |
|
|
|
|
//console.log('onSubmit'); |
|
|
|
|
this.courseSaving = true; |
|
|
|
|
api.saveCourse(this.course, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
@ -574,7 +574,7 @@ |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
loadCourseDraft() { |
|
|
|
|
console.log('loadCourseDraft'); |
|
|
|
|
//console.log('loadCourseDraft'); |
|
|
|
|
if(this.live) { return; } |
|
|
|
|
|
|
|
|
|
this.courseLoading = true; |
|
|
|
|
@ -591,13 +591,13 @@ |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
this.courseLoading = false; |
|
|
|
|
console.log('error course loading', err); |
|
|
|
|
//console.log('error course loading', err); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return response; |
|
|
|
|
}, |
|
|
|
|
loadCourse() { |
|
|
|
|
console.log('loadCourse'); |
|
|
|
|
//console.log('loadCourse'); |
|
|
|
|
this.courseLoading = true; |
|
|
|
|
let request = null; |
|
|
|
|
if(this.live) { |
|
|
|
|
@ -625,7 +625,7 @@ |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
this.courseLoading = false; |
|
|
|
|
console.log('error course loading', err); |
|
|
|
|
//console.log('error course loading', err); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return request; |
|
|
|
|
@ -652,7 +652,7 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
validate(silent) { |
|
|
|
|
console.log('valadte', arguments); |
|
|
|
|
//console.log('valadte', arguments); |
|
|
|
|
this.showErrors = true; |
|
|
|
|
if (this.$v.$invalid) { |
|
|
|
|
if(!silent) { |
|
|
|
|
@ -687,6 +687,7 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
saveCourseDraft: function (newValue, oldValue) { |
|
|
|
|
//console.log('saveCourseDraft'); |
|
|
|
|
// if (!oldValue.id) { |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
@ -694,12 +695,12 @@ |
|
|
|
|
|
|
|
|
|
// if(this.live) { |
|
|
|
|
// if(!this.course.date || this.course.short_description == '' || this.course.title == '') { |
|
|
|
|
// console.log('live valiedation error'); |
|
|
|
|
// //console.log('live valiedation error'); |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
// } else { |
|
|
|
|
// if(this.course.short_description == '' || this.course.title == '') { |
|
|
|
|
// console.log('course validation error'); |
|
|
|
|
// //console.log('course validation error'); |
|
|
|
|
// return; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
@ -734,15 +735,24 @@ |
|
|
|
|
courseData.is_deferred = true; |
|
|
|
|
} |
|
|
|
|
let remoteUUIDMapper = {} |
|
|
|
|
let remoteDataMapper = {} |
|
|
|
|
if (courseData.content) { |
|
|
|
|
courseData.content.forEach((contentElement) => { |
|
|
|
|
remoteUUIDMapper[contentElement.uuid] = contentElement.data.id |
|
|
|
|
remoteUUIDMapper[contentElement.uuid] = contentElement.data.id; |
|
|
|
|
remoteDataMapper[contentElement.uuid] = contentElement.data; |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.course.content.forEach((contentElement, index) => { |
|
|
|
|
if (!contentElement.data.id) { |
|
|
|
|
this.$set(this.course.content[index].data, 'id', remoteUUIDMapper[contentElement.uuid]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(contentElement.type === 'images') { |
|
|
|
|
remoteDataMapper[contentElement.uuid].images.forEach((image, imageIndex) => { |
|
|
|
|
this.$set(this.course.content[index].data.images[imageIndex], 'id', image.id) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (courseData.url) { |
|
|
|
|
this.slugChanged = true; |
|
|
|
|
@ -764,13 +774,13 @@ |
|
|
|
|
.catch((err) => { |
|
|
|
|
this.courseSyncHook = false; |
|
|
|
|
this.courseSaving = false; |
|
|
|
|
console.error(err); |
|
|
|
|
//console.error(err); |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = 'ОШИБКА'; |
|
|
|
|
this.savingTimeout = setTimeout(() => { |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = ''; |
|
|
|
|
}, 2000); |
|
|
|
|
// alert('Произошло что-то страшное: '+err.toString()); |
|
|
|
|
console.log(err.response.data); |
|
|
|
|
//console.log(err.response.data); |
|
|
|
|
if(err.response.data) { |
|
|
|
|
for(let i in err.response.data) { |
|
|
|
|
showNotification("error", this.fields[i]+": "+err.response.data[i].join(', ')); |
|
|
|
|
@ -782,7 +792,7 @@ |
|
|
|
|
}, 500); |
|
|
|
|
}, |
|
|
|
|
updateViewSection(location, action) { |
|
|
|
|
console.log('updateViewSection[action]', action); |
|
|
|
|
//console.log('updateViewSection[action]', action); |
|
|
|
|
if (location.pathname === '/course/create/lessons') { |
|
|
|
|
this.viewSection = 'lessons'; |
|
|
|
|
} else if (location.pathname === '/course/create') { |
|
|
|
|
@ -791,8 +801,8 @@ |
|
|
|
|
this.viewSection = 'lessons-edit'; |
|
|
|
|
} else if (location.pathname.indexOf('/course/create/lessons/edit') !== -1) { |
|
|
|
|
let lessonId = parseInt(location.pathname.split('/').pop()); |
|
|
|
|
console.log('lessonId', lessonId, this.lessons.toString()); |
|
|
|
|
console.log('lessod edit', this.lessons.find((i)=>{return i.id === lessonId})); |
|
|
|
|
//console.log('lessonId', lessonId, this.lessons.toString()); |
|
|
|
|
//console.log('lessod edit', this.lessons.find((i)=>{return i.id === lessonId})); |
|
|
|
|
this.currentLesson = this.lessons.find((i)=>{return i.id === lessonId}); |
|
|
|
|
this.viewSection = 'lessons-edit'; |
|
|
|
|
} |
|
|
|
|
@ -887,9 +897,9 @@ |
|
|
|
|
// }); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
console.log('wait promises'); |
|
|
|
|
//console.log('wait promises'); |
|
|
|
|
Promise.all(promises.map(p => p.catch(e => e))).then(()=>{ |
|
|
|
|
console.log('promises end'); |
|
|
|
|
//console.log('promises end'); |
|
|
|
|
this.mounting = false; |
|
|
|
|
let load; |
|
|
|
|
if (this.courseId) { |
|
|
|
|
@ -906,7 +916,7 @@ |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
console.log('mounted end'); |
|
|
|
|
//console.log('mounted end'); |
|
|
|
|
// this.updateViewSection(window.location); |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
@ -969,17 +979,17 @@ |
|
|
|
|
watch: { |
|
|
|
|
'course': { |
|
|
|
|
handler: function (newValue, oldValue) { |
|
|
|
|
// console.log('watch', JSON.stringify(newValue), JSON.stringify(oldValue)); |
|
|
|
|
// //console.log('watch', JSON.stringify(newValue), JSON.stringify(oldValue)); |
|
|
|
|
// Если курс загрузился и есть ID - делаем кнопки превью и публикации активными |
|
|
|
|
console.log('newValue.id', newValue.id); |
|
|
|
|
//console.log('newValue.id', newValue.id); |
|
|
|
|
if (newValue.id) { |
|
|
|
|
// console.log('newValue.id disabled remove', newValue.id); |
|
|
|
|
// //console.log('newValue.id disabled remove', newValue.id); |
|
|
|
|
$('#course-redactor__preview-button').removeAttr('disabled'); |
|
|
|
|
$('#course-redactor__publish-button').removeAttr('disabled'); |
|
|
|
|
} |
|
|
|
|
// console.log('courseSyncHook', this.courseSyncHook); |
|
|
|
|
// //console.log('courseSyncHook', this.courseSyncHook); |
|
|
|
|
if (this.courseSyncHook || this.courseLoading) { |
|
|
|
|
console.log('abort save draft', this.courseSyncHook, this.courseLoading); |
|
|
|
|
//console.log('abort save draft', this.courseSyncHook, this.courseLoading); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.saveCourseDraft(newValue, oldValue); |
|
|
|
|
|