diff --git a/web/src/components/CourseRedactor.vue b/web/src/components/CourseRedactor.vue index 18e850f2..490031eb 100644 --- a/web/src/components/CourseRedactor.vue +++ b/web/src/components/CourseRedactor.vue @@ -251,6 +251,7 @@ import {api} from "../js/modules/api"; import BlockAdd from "./blocks/BlockAdd"; import debounce from 'lodash.debounce'; + import $ from 'jquery'; import {required, minValue, numeric } from 'vuelidate/lib/validators' export default { @@ -492,6 +493,15 @@ }, onCoursePublish() { console.log('publish course'); + const publishButton = $('#course-redactor__publish-button'); + publishButton.attr('disabled', 'disabled'); + api.publishCourse(this.course.id, this.accessToken) + .then((response) => { + document.getElementById('course-redactor__saving-status').innerText = 'НА МОДЕРАЦИИ'; + }) + .catch(() => { + publishButton.removeAttr('disabled'); + }); }, saveCourseDraft: debounce(function (newValue, oldValue) { if (!oldValue.id) { diff --git a/web/src/js/modules/api.js b/web/src/js/modules/api.js index cded5e99..39be3a69 100644 --- a/web/src/js/modules/api.js +++ b/web/src/js/modules/api.js @@ -378,5 +378,12 @@ export const api = { 'Authorization': `Token ${accessToken}`, } }); + }, + publishCourse: (courseId, accessToken) => { + return axios.patch(`/api/v1/courses/${courseId}/`, {status: 1}, { + headers: { + 'Authorization': `Token ${accessToken}`, + } + }); } }; \ No newline at end of file