|
|
|
|
@ -35,6 +35,18 @@ |
|
|
|
|
v-model="course.title"></textarea> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="info__field field field_info" |
|
|
|
|
v-bind:class="{ error: ($v.course.short_description.$dirty || showErrors) && $v.course.short_description.$invalid }"> |
|
|
|
|
<div class="field__label">КРАТКО О КУРСЕ</div> |
|
|
|
|
<div class="field__wrap"> |
|
|
|
|
<textarea class="field__input" |
|
|
|
|
rows="1" |
|
|
|
|
placeholder="Кратко о курсе" |
|
|
|
|
v-autosize="course.short_description" |
|
|
|
|
@input="$v.course.short_description.$touch()" |
|
|
|
|
v-model="course.short_description"></textarea> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="info__foot" v-if="!live"> |
|
|
|
|
<div class="info__field field field_info info__field--light" |
|
|
|
|
@ -138,25 +150,6 @@ |
|
|
|
|
<div class="section"> |
|
|
|
|
<div class="section__center center"> |
|
|
|
|
<div class="kit"> |
|
|
|
|
<div class="kit__section"> |
|
|
|
|
<div class="kit__field field" |
|
|
|
|
v-bind:class="{ error: ($v.course.short_description.$dirty || showErrors) && $v.course.short_description.$invalid }"> |
|
|
|
|
<div class="field__wrap"> |
|
|
|
|
<textarea class="field__input" |
|
|
|
|
rows="1" |
|
|
|
|
placeholder="Кратко о курсе" |
|
|
|
|
v-autosize="course.short_description" |
|
|
|
|
@input="$v.course.short_description.$touch()" |
|
|
|
|
v-model="course.short_description"></textarea> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<block-images |
|
|
|
|
:index="0" |
|
|
|
|
:readOnly="true" |
|
|
|
|
title="Результаты урока" |
|
|
|
|
:images.sync="course.gallery.images" |
|
|
|
|
:access-token="accessToken"/> |
|
|
|
|
</div> |
|
|
|
|
<div v-if="!live" id="course-redactor__nav" class="kit__nav"> |
|
|
|
|
<button class="kit__btn btn btn_lg" |
|
|
|
|
v-bind:class="{ 'btn_stroke': viewSection === 'course', 'btn_gray': viewSection !== 'course' }" |
|
|
|
|
@ -323,7 +316,11 @@ |
|
|
|
|
lessons: [], |
|
|
|
|
lessonsLoading: false, |
|
|
|
|
lessonSaving: false, |
|
|
|
|
currentLesson: null, |
|
|
|
|
currentLesson: { |
|
|
|
|
title: '', |
|
|
|
|
short_description: '', |
|
|
|
|
content: [], |
|
|
|
|
}, |
|
|
|
|
is_adding_block: false, |
|
|
|
|
timeOptions: [ |
|
|
|
|
{ |
|
|
|
|
@ -469,9 +466,7 @@ |
|
|
|
|
}, |
|
|
|
|
editLesson(lessonIndex) { |
|
|
|
|
this.currentLesson = this.lessons[lessonIndex]; |
|
|
|
|
if (this.viewSection !== 'lessons-edit') { |
|
|
|
|
history.push("/course/create/lessons/new"); |
|
|
|
|
} |
|
|
|
|
history.push("/course/create/lessons/edit/"+this.currentLesson.id); |
|
|
|
|
this.viewSection = 'lessons-edit'; |
|
|
|
|
}, |
|
|
|
|
showCourse() { |
|
|
|
|
@ -490,7 +485,6 @@ |
|
|
|
|
this.currentLesson = { |
|
|
|
|
title: '', |
|
|
|
|
short_description: '', |
|
|
|
|
course_id: this.course.id, |
|
|
|
|
content: [], |
|
|
|
|
}; |
|
|
|
|
if (this.viewSection !== 'lessons-edit') { |
|
|
|
|
@ -513,6 +507,7 @@ |
|
|
|
|
onLessonSubmit() { |
|
|
|
|
this.lessonSaving = true; |
|
|
|
|
const currentLessonId = this.currentLesson.id; |
|
|
|
|
this.currentLesson.course_id = this.course.id; |
|
|
|
|
api.saveLesson(this.currentLesson, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
this.lessonSaving = false; |
|
|
|
|
@ -535,6 +530,7 @@ |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
goToLessons() { |
|
|
|
|
history.push("/course/create/lessons"); |
|
|
|
|
this.viewSection = 'lessons'; |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
const elementTop = $('#course-redactor__nav').position().top - 130; |
|
|
|
|
@ -543,7 +539,9 @@ |
|
|
|
|
}, |
|
|
|
|
loadCourseDraft() { |
|
|
|
|
this.courseLoading = true; |
|
|
|
|
api.getCourseDraft(this.accessToken) |
|
|
|
|
let response = api.getCourseDraft(this.accessToken); |
|
|
|
|
|
|
|
|
|
response |
|
|
|
|
.then((response) => { |
|
|
|
|
this.courseLoading = false; |
|
|
|
|
this.course = api.convertCourseJson(response.data); |
|
|
|
|
@ -555,10 +553,13 @@ |
|
|
|
|
this.courseLoading = false; |
|
|
|
|
console.log('error course loading', err); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return response; |
|
|
|
|
}, |
|
|
|
|
loadCourse() { |
|
|
|
|
this.courseLoading = true; |
|
|
|
|
api.loadCourse(this.courseId, this.accessToken) |
|
|
|
|
let response = api.loadCourse(this.courseId, this.accessToken) |
|
|
|
|
response |
|
|
|
|
.then((response) => { |
|
|
|
|
this.courseLoading = false; |
|
|
|
|
this.course = api.convertCourseJson(response.data); |
|
|
|
|
@ -570,6 +571,8 @@ |
|
|
|
|
this.courseLoading = false; |
|
|
|
|
console.log('error course loading', err); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return response; |
|
|
|
|
}, |
|
|
|
|
loadLessons(courseId) { |
|
|
|
|
|
|
|
|
|
@ -651,22 +654,35 @@ |
|
|
|
|
.catch((err) => { |
|
|
|
|
this.courseSyncHook = false; |
|
|
|
|
this.courseSaving = false; |
|
|
|
|
console.error(err); |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = 'ОШИБКА'; |
|
|
|
|
this.savingTimeout = setTimeout(() => { |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = ''; |
|
|
|
|
}, 2000); |
|
|
|
|
alert('Произошло что-то страшное: '+err.toString()); |
|
|
|
|
}); |
|
|
|
|
}, 3000); |
|
|
|
|
}, 500); |
|
|
|
|
}, |
|
|
|
|
updateViewSection(location, action) { |
|
|
|
|
console.log('updateViewSection[action]', action); |
|
|
|
|
if (location.pathname === '/course/create/lessons') { |
|
|
|
|
this.viewSection = 'lessons'; |
|
|
|
|
} else if (location.pathname === '/course/create') { |
|
|
|
|
this.viewSection = 'course'; |
|
|
|
|
} else if (location.pathname === '/course/create/lessons/new') { |
|
|
|
|
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})); |
|
|
|
|
this.currentLesson = this.lessons.find((i)=>{return i.id === lessonId}); |
|
|
|
|
this.viewSection = 'lessons-edit'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
console.log('live', this.live); |
|
|
|
|
// Listen for changes to the current location. |
|
|
|
|
this.unlisten = history.listen((location, action) => { |
|
|
|
|
if (location.pathname === '/course/create/lessons') { |
|
|
|
|
this.viewSection = 'lessons'; |
|
|
|
|
} else if (location.pathname === '/course/create') { |
|
|
|
|
this.viewSection = 'course'; |
|
|
|
|
} else if (location.pathname === '/course/create/lessons/new') { |
|
|
|
|
this.viewSection = 'lessons-edit'; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.unlisten = history.listen(this.updateViewSection); |
|
|
|
|
|
|
|
|
|
api.getCategories(this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
@ -703,10 +719,12 @@ |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (this.courseId) { |
|
|
|
|
this.loadCourse() |
|
|
|
|
this.loadCourse().then(()=>{this.updateViewSection(window.location, 'load')}) |
|
|
|
|
} else { |
|
|
|
|
this.loadCourseDraft(); |
|
|
|
|
this.loadCourseDraft().then(()=>{this.updateViewSection(window.location, 'load draft')}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// this.updateViewSection(window.location); |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
coverBackgroundStyle() { |
|
|
|
|
|