updated at field, lesson save before preview, moderation status to edit

remotes/origin/hasaccess
Sanasol 8 years ago
parent 61e4345fc6
commit 882a5368fe
  1. 2
      apps/course/templates/course/_items.html
  2. 35
      web/src/components/CourseRedactor.vue

@ -7,7 +7,7 @@
data-course data-course-id={{ course.id }} data-course data-course-id={{ course.id }}
{% if course.is_deferred_start and course.status == 2 %}data-future-course data-future-course-time={{ course.deferred_start_at.timestamp }}{% endif %} {% if course.is_deferred_start and course.status == 2 %}data-future-course data-future-course-time={{ course.deferred_start_at.timestamp }}{% endif %}
> >
<a class="courses__preview" href="{% if course.status == 0 %}{% url 'course_edit' course.id %}{% else %}{% url 'course' course.id %}?next={{ request.get_full_path }}{% endif %}"> <a class="courses__preview" href="{% if course.status <= 1 %}{% url 'course_edit' course.id %}{% else %}{% url 'course' course.id %}?next={{ request.get_full_path }}{% endif %}">
{% thumbnail course.cover.image "300x200" crop="center" as im %} {% thumbnail course.cover.image "300x200" crop="center" as im %}
<img class="courses__pic" src="{{ im.url }}" width="{{ im.width }}" /> <img class="courses__pic" src="{{ im.url }}" width="{{ im.width }}" />
{% empty %} {% empty %}

@ -552,17 +552,21 @@
}, },
onLessonSubmit() { onLessonSubmit() {
if(!this.validateLesson()) { if(!this.validateLesson()) {
return; return new Promise(function(resolve, reject) {
reject('validation reject');
});
} }
showNotification("success", "Момент, вносим последние правки!");
this.saveLesson(); return this.saveLesson();
}, },
saveLesson() { saveLesson() {
this.lessonSaving = true; this.lessonSaving = true;
const currentLessonId = this.currentLesson.id; const currentLessonId = this.currentLesson.id;
this.currentLesson.course_id = this.course.id; this.currentLesson.course_id = this.course.id;
api.saveLesson(this.currentLesson, this.accessToken) let req = api.saveLesson(this.currentLesson, this.accessToken);
.then((response) => {
req.then((response) => {
const newLesson = api.convertLessonJson(response.data); const newLesson = api.convertLessonJson(response.data);
newLesson.course_id = this.course.id; newLesson.course_id = this.course.id;
this.currentLesson = newLesson; this.currentLesson = newLesson;
@ -583,7 +587,7 @@
}, 2000); }, 2000);
showNotification("success", 'Урок сохранён'); showNotification("success", 'Урок сохранён');
this.goToLessons(); // this.goToLessons();
this.lessonSaving = false; this.lessonSaving = false;
}) })
@ -604,6 +608,8 @@
} }
} }
}); });
return req;
}, },
goToLessons() { goToLessons() {
history.push("/course/create/lessons"); history.push("/course/create/lessons");
@ -729,8 +735,17 @@
if(this.course.id) { if(this.course.id) {
let url; let url;
if(this.currentLesson && this.currentLesson.id) { if(this.viewSection === 'lessons-edit') {
url = `/lesson/${this.currentLesson.id}`; this.onLessonSubmit().then(()=>{
url = `/lesson/${this.currentLesson.id}`;
let newTab = window.open(url, '_blank');
newTab.focus();
}).catch((e)=>{
// showNotification("error", "Пока еще нечего посмотреть, давайте что-нибудь напишем");
console.log(e);
});
} else { } else {
if(this.live) { if(this.live) {
url = `/school/lessons/${this.course.id}`; url = `/school/lessons/${this.course.id}`;
@ -740,10 +755,10 @@
} }
url = `/course/${this.course.id}`; url = `/course/${this.course.id}`;
} }
}
let newTab = window.open(url, '_blank'); let newTab = window.open(url, '_blank');
newTab.focus(); newTab.focus();
}
} else { } else {
showNotification("error", "Пока еще нечего посмотреть, давайте что-нибудь напишем"); showNotification("error", "Пока еще нечего посмотреть, давайте что-нибудь напишем");
} }

Loading…
Cancel
Save