|
|
|
|
@ -334,6 +334,7 @@ |
|
|
|
|
], |
|
|
|
|
showErrors: false, |
|
|
|
|
savingTimeout: null, |
|
|
|
|
savingDebounceTimeout: null, |
|
|
|
|
categoryOptions: [], |
|
|
|
|
courseSyncHook: false, // Если true, то watch не будет отправлять курс на обновление |
|
|
|
|
} |
|
|
|
|
@ -519,30 +520,35 @@ |
|
|
|
|
let newTab = window.open(`/course/${this.course.id}`, '_blank'); |
|
|
|
|
newTab.focus(); |
|
|
|
|
}, |
|
|
|
|
saveCourseDraft: debounce(function (newValue, oldValue) { |
|
|
|
|
saveCourseDraft: function (newValue, oldValue) { |
|
|
|
|
if (!oldValue.id) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.courseSaving = true; |
|
|
|
|
clearTimeout(this.savingTimeout); |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = 'СОХРАНЕНИЕ'; |
|
|
|
|
api.saveCourse(this.course, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
this.courseSaving = false; |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = 'СОХРАНЕНО'; |
|
|
|
|
this.savingTimeout = setTimeout(() => { |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = ''; |
|
|
|
|
}, 2000); |
|
|
|
|
this.courseSyncHook = true; |
|
|
|
|
this.course = api.convertCourseJson(response.data); |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.courseSyncHook = false; |
|
|
|
|
if (this.savingDebounceTimeout) { |
|
|
|
|
clearTimeout(this.savingDebounceTimeout); |
|
|
|
|
} |
|
|
|
|
this.savingDebounceTimeout = setTimeout(() => { |
|
|
|
|
this.courseSaving = true; |
|
|
|
|
clearTimeout(this.savingTimeout); |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = 'СОХРАНЕНИЕ'; |
|
|
|
|
api.saveCourse(this.course, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
this.courseSaving = false; |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = 'СОХРАНЕНО'; |
|
|
|
|
this.savingTimeout = setTimeout(() => { |
|
|
|
|
document.getElementById('course-redactor__saving-status').innerText = ''; |
|
|
|
|
}, 2000); |
|
|
|
|
this.courseSyncHook = true; |
|
|
|
|
this.course = api.convertCourseJson(response.data); |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.courseSyncHook = false; |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
|
this.courseSaving = false; |
|
|
|
|
}); |
|
|
|
|
}, 2000) |
|
|
|
|
.catch((err) => { |
|
|
|
|
this.courseSaving = false; |
|
|
|
|
}); |
|
|
|
|
}, 2000); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
api.getCategories(this.accessToken) |
|
|
|
|
|