|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
<template> |
|
|
|
|
<div id="lilcity__course-redactor" v-on:course_publish="onCoursePublish"> |
|
|
|
|
<div id="lilcity__course-redactor" v-on:course_publish="onCoursePublish" v-on:course_preview="onCoursePreview"> |
|
|
|
|
<div v-if="!courseLoading"> |
|
|
|
|
<form v-if="viewSection !== 'lessons-edit'" @submit.prevent="onSubmit"> |
|
|
|
|
<div class="info"> |
|
|
|
|
@ -10,9 +10,11 @@ |
|
|
|
|
<div class="info__ava ava"> |
|
|
|
|
<img :src="authorPicture" alt="Аватар" class="ava__pic"> |
|
|
|
|
</div> |
|
|
|
|
<div class="info__group"> |
|
|
|
|
<div v-if="me" class="info__group info__field--light"> |
|
|
|
|
<div class="info__label">АВТОР</div> |
|
|
|
|
<div class="info__value">{{ authorName }}</div> |
|
|
|
|
<div v-if="me.role != ROLE_ADMIN" class="info__value">{{ authorName }}</div> |
|
|
|
|
<div v-else class="info__value"><lil-select :value.sync="userSelect" :options="users" |
|
|
|
|
placeholder="Выберите автора"/></div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="info__upload upload"> |
|
|
|
|
@ -239,6 +241,7 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { ROLE_ADMIN, ROLE_AUTHOR } from './consts' |
|
|
|
|
import LinkInput from './inputs/LinkInput' |
|
|
|
|
import DatePicker from 'vuejs-datepicker' |
|
|
|
|
import BlockText from './blocks/BlockText' |
|
|
|
|
@ -251,6 +254,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 { |
|
|
|
|
@ -259,11 +263,15 @@ |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
viewSection: 'course', |
|
|
|
|
me: null, |
|
|
|
|
users: null, |
|
|
|
|
ROLE_ADMIN: ROLE_ADMIN, |
|
|
|
|
course: { |
|
|
|
|
title: '', |
|
|
|
|
category: null, |
|
|
|
|
categorySelect: null, |
|
|
|
|
duration: 1, |
|
|
|
|
author: null, |
|
|
|
|
price: 0, |
|
|
|
|
url: '', |
|
|
|
|
coverImage: '', |
|
|
|
|
@ -492,6 +500,19 @@ |
|
|
|
|
}, |
|
|
|
|
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'); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
onCoursePreview() { |
|
|
|
|
let newTab = window.open(`/course/${this.course.id}`, '_blank'); |
|
|
|
|
newTab.focus(); |
|
|
|
|
}, |
|
|
|
|
saveCourseDraft: debounce(function (newValue, oldValue) { |
|
|
|
|
if (!oldValue.id) { |
|
|
|
|
@ -528,6 +549,27 @@ |
|
|
|
|
this.updateCategory(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
api.getCurrentUser(this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
if (response.data) { |
|
|
|
|
this.me = response.data; |
|
|
|
|
|
|
|
|
|
if(this.me.role == ROLE_ADMIN) { |
|
|
|
|
api.getUsers({role: [ROLE_AUTHOR,ROLE_ADMIN], page_size: 1000}, this.accessToken) |
|
|
|
|
.then((usersResponse) => { |
|
|
|
|
if (usersResponse.data) { |
|
|
|
|
this.users = usersResponse.data.results.map((user) => { |
|
|
|
|
return { |
|
|
|
|
title: `${user.first_name} ${user.last_name} (${user.email})`, |
|
|
|
|
value: user.id |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (this.courseId) { |
|
|
|
|
this.loadCourse() |
|
|
|
|
} else { |
|
|
|
|
@ -563,6 +605,23 @@ |
|
|
|
|
this.course.category = value.value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
userSelect: { |
|
|
|
|
get() { |
|
|
|
|
if (!this.users || this.users.length === 0 || !this.course || !this.course.author) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
let value; |
|
|
|
|
this.users.forEach((user) => { |
|
|
|
|
if (user.value === this.course.author) { |
|
|
|
|
value = user; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return value; |
|
|
|
|
}, |
|
|
|
|
set(value) { |
|
|
|
|
this.course.author = value.value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
courseFullUrl() { |
|
|
|
|
let suffix = this.course.url ? this.course.url : 'ваша_ссылка'; |
|
|
|
|
return `https://lil.city/course/${suffix}`; |
|
|
|
|
|