Мелкие правки

remotes/origin/hasaccess
Vitaly Baev 8 years ago
parent 465a927b96
commit 9605f88a09
  1. 46
      web/src/components/CourseRedactor.vue

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

Loading…
Cancel
Save