From 8b65a8acec797147356bc7897f236d592edef8ad Mon Sep 17 00:00:00 2001 From: Vitaly Baev Date: Wed, 14 Feb 2018 20:34:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BE=D0=BB=D0=B5=D0=B5=20=D1=82=D0=BE?= =?UTF-8?q?=D1=87=D0=BD=D0=B0=D1=8F=20=D0=BD=D0=B0=D0=B4=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D1=8C=20"=D0=A1=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/CourseRedactor.vue | 10 ++++++++++ web/src/js/modules/api.js | 7 +++++++ 2 files changed, 17 insertions(+) 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