|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
<template> |
|
|
|
|
<div> |
|
|
|
|
<form @submit.prevent="onSubmit"> |
|
|
|
|
<div class="info"> |
|
|
|
|
<div class="info__section" :style="backgroundStyle"> |
|
|
|
|
<div class="info__main"> |
|
|
|
|
@ -31,7 +31,7 @@ |
|
|
|
|
<div class="info__field field field_info"> |
|
|
|
|
<div class="field__label field__label_gray">КАТЕГОРИЯ</div> |
|
|
|
|
<div class="field__wrap"> |
|
|
|
|
<input type="text" class="field__input" v-model="course.category"> |
|
|
|
|
<lil-select :value.sync="categorySelect" :options="categoryOptions" placeholder="Выберите категорию"/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="info__field field field_info"> |
|
|
|
|
@ -81,11 +81,11 @@ |
|
|
|
|
<div class="field__label field__label_gray">ЗАПУСК</div> |
|
|
|
|
<div class="field__wrap"> |
|
|
|
|
<label class="field__switch switch switch_lg switch_circle"> |
|
|
|
|
<input type="radio" :value="false" class="switch__input" v-model="course.is_delayed"> |
|
|
|
|
<input type="radio" :value="false" class="switch__input" v-model="course.is_deferred"> |
|
|
|
|
<span class="switch__content">Мгновенный</span> |
|
|
|
|
</label> |
|
|
|
|
<label class="field__switch switch switch_lg switch_circle"> |
|
|
|
|
<input type="radio" :value="true" class="switch__input" v-model="course.is_delayed"> |
|
|
|
|
<input type="radio" :value="true" class="switch__input" v-model="course.is_deferred"> |
|
|
|
|
<span class="switch__content">Отложенный</span> |
|
|
|
|
</label> |
|
|
|
|
</div> |
|
|
|
|
@ -117,24 +117,39 @@ |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div class="kit__nav"> |
|
|
|
|
<button class="kit__btn btn btn_lg btn_stroke">Описание курса</button> |
|
|
|
|
<button class="kit__btn btn btn_lg btn_gray">Уроки</button> |
|
|
|
|
<button class="kit__btn btn btn_lg btn_stroke" type="button" @click="viewSection = 'course'">Описание курса</button> |
|
|
|
|
<button class="kit__btn btn btn_lg btn_gray" type="button" @click="viewSection = 'lessons'" :disabled="!course.id">Уроки</button> |
|
|
|
|
</div> |
|
|
|
|
<div class="kit__body"> |
|
|
|
|
<div v-if="viewSection === 'course'" class="kit__body"> |
|
|
|
|
<div v-for="block in course.blocks"> |
|
|
|
|
<block-text v-if="block.type === 'text'" :title.sync="block.data.title" :text.sync="block.data.text"/> |
|
|
|
|
<block-image-text v-if="block.type === 'image-text'" :title.sync="block.data.title" |
|
|
|
|
:text.sync="block.data.text"/> |
|
|
|
|
<block-image v-if="block.type === 'image'" :title.sync="block.data.title"/> |
|
|
|
|
<block-images v-if="block.type === 'images'" :title.sync="block.data.title" :text.sync="block.data.text" |
|
|
|
|
:images.sync="block.data.images"/> |
|
|
|
|
<block-video v-if="block.type === 'video'" :title.sync="block.data.title" |
|
|
|
|
<block-text v-if="block.type === 'text'" |
|
|
|
|
:title.sync="block.data.title" |
|
|
|
|
:text.sync="block.data.text" |
|
|
|
|
:access-token="accessToken"/> |
|
|
|
|
<block-image-text v-if="block.type === 'image-text'" |
|
|
|
|
:title.sync="block.data.title" |
|
|
|
|
:text.sync="block.data.text" |
|
|
|
|
:image-id.sync="block.data.image_id" |
|
|
|
|
:image-url.sync="block.data.image_url" |
|
|
|
|
:access-token="accessToken"/> |
|
|
|
|
<block-image v-if="block.type === 'image'" |
|
|
|
|
:title.sync="block.data.title" |
|
|
|
|
:image-id.sync="block.data.image_id" |
|
|
|
|
:image-url.sync="block.data.image_url" |
|
|
|
|
:access-token="accessToken"/> |
|
|
|
|
<block-images v-if="block.type === 'images'" |
|
|
|
|
:title.sync="block.data.title" |
|
|
|
|
:text.sync="block.data.text" |
|
|
|
|
:images.sync="block.data.images" |
|
|
|
|
:access-token="accessToken"/> |
|
|
|
|
<block-video v-if="block.type === 'video'" |
|
|
|
|
:title.sync="block.data.title" |
|
|
|
|
:video-url.sync="block.data.video_url"/> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div class="kit__section"> |
|
|
|
|
<div v-if="!is_adding_block" class="kit__add add"> |
|
|
|
|
<button class="add__toggle" @click="is_adding_block = true"> |
|
|
|
|
<button type="button" class="add__toggle" @click="is_adding_block = true"> |
|
|
|
|
<span class="add__circle"> |
|
|
|
|
<svg class="icon icon-add-plus"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-add-plus"></use> |
|
|
|
|
@ -144,7 +159,7 @@ |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
<div v-if="is_adding_block" class="kit__add add open"> |
|
|
|
|
<button class="add__toggle" @click="is_adding_block = false"> |
|
|
|
|
<button type="button" class="add__toggle" @click="is_adding_block = false"> |
|
|
|
|
<span class="add__circle"> |
|
|
|
|
<svg class="icon icon-add-plus"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-add-plus"></use> |
|
|
|
|
@ -163,17 +178,17 @@ |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-image"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
<button class="add__btn" @click="addBlockImageText"> |
|
|
|
|
<button type="button" class="add__btn" @click="addBlockImageText"> |
|
|
|
|
<svg class="icon icon-image-text"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-image-text"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
<button class="add__btn" @click="addBlockImages"> |
|
|
|
|
<button type="button" class="add__btn" @click="addBlockImages"> |
|
|
|
|
<svg class="icon icon-images"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-images"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
<button class="add__btn" @click="addBlockVideo"> |
|
|
|
|
<button type="button" class="add__btn" @click="addBlockVideo"> |
|
|
|
|
<svg class="icon icon-video-stroke"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-video-stroke"></use> |
|
|
|
|
</svg> |
|
|
|
|
@ -186,18 +201,27 @@ |
|
|
|
|
<vue-redactor :value.sync="course.about" /> |
|
|
|
|
</div> |
|
|
|
|
<div class="kit__foot"> |
|
|
|
|
<button class="kit__submit btn btn_md">Сохранить</button> |
|
|
|
|
<button type="submit" class="kit__submit btn btn_md">Сохранить</button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div v-if="viewSection === 'lessons'" class="kit__body"> |
|
|
|
|
<div class="lessons__title title">Содержание курса</div> |
|
|
|
|
<div class="lessons__list"> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
<div class="lessons__foot"> |
|
|
|
|
<button class="lessons__btn btn btn_md">СОЗДАТЬ УРОК</button> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</form> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import LinkInput from './inputs/LinkInput' |
|
|
|
|
import Datepicker from 'vuejs-datepicker' |
|
|
|
|
import DatePicker from 'vuejs-datepicker' |
|
|
|
|
import BlockText from './blocks/BlockText' |
|
|
|
|
import BlockImage from './blocks/BlockImage' |
|
|
|
|
import BlockImages from './blocks/BlockImages' |
|
|
|
|
@ -205,27 +229,33 @@ |
|
|
|
|
import BlockVideo from './blocks/BlockVideo' |
|
|
|
|
import VueRedactor from './redactor/VueRedactor' |
|
|
|
|
import LilSelect from "./inputs/LilSelect"; |
|
|
|
|
import {api} from "../js/modules/api"; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: "course-redactor", |
|
|
|
|
props: ["authorName", "authorPicture"], |
|
|
|
|
props: ["authorName", "authorPicture", "accessToken"], |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
viewSection: 'course', |
|
|
|
|
course: { |
|
|
|
|
title: 'Как просто научиться рисовать простых персонажей.', |
|
|
|
|
category: 'Акварель', |
|
|
|
|
category: 9, |
|
|
|
|
categorySelect: null, |
|
|
|
|
duration: 1, |
|
|
|
|
price: 1000, |
|
|
|
|
url: 'my-awesome-url', |
|
|
|
|
backgroundImage: '', |
|
|
|
|
is_paid: true, |
|
|
|
|
is_featured: true, |
|
|
|
|
is_delayed: false, |
|
|
|
|
is_deferred: false, |
|
|
|
|
date: '2018-03-08', |
|
|
|
|
time: null, |
|
|
|
|
short_description: 'Этот курс поможет детям освоить базовые навыки рисования простых персонажей', |
|
|
|
|
blocks: [], |
|
|
|
|
about: '<b>Главная цель курса</b> - рассказать...', |
|
|
|
|
}, |
|
|
|
|
lessons: { |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
is_adding_block: false, |
|
|
|
|
timeOptions: [ |
|
|
|
|
@ -265,7 +295,8 @@ |
|
|
|
|
'title': '18:00', |
|
|
|
|
'value': '18:00', |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
], |
|
|
|
|
categoryOptions: [] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
@ -297,6 +328,8 @@ |
|
|
|
|
type: 'image', |
|
|
|
|
data: { |
|
|
|
|
title: 'тест картинка', |
|
|
|
|
image_id: null, |
|
|
|
|
image_url: null, |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
@ -306,6 +339,8 @@ |
|
|
|
|
data: { |
|
|
|
|
title: 'тест картинка-текст', |
|
|
|
|
text: 'текст какой-то', |
|
|
|
|
image_id: null, |
|
|
|
|
image_url: null, |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
@ -327,8 +362,37 @@ |
|
|
|
|
video_url: 'http://vimeo.com/safmklsamfk', |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
updateCategory() { |
|
|
|
|
if (this.categoryOptions && Array.isArray(this.categoryOptions) && this.course.category) { |
|
|
|
|
this.categoryOptions.forEach((category) => { |
|
|
|
|
if (category.id === this.course.category) { |
|
|
|
|
this.course.categorySelect = category; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onSubmit() { |
|
|
|
|
api.saveCourse(this.course, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
this.course = api.convertCourseJson(response.course); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
api.getCategories(this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
if (response.data) { |
|
|
|
|
this.categoryOptions = response.data.results.map((category) => { |
|
|
|
|
return { |
|
|
|
|
title: category.title, |
|
|
|
|
value: category.id |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.updateCategory(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
backgroundStyle() { |
|
|
|
|
return this.course.backgroundImage ? `background-image: url(${this.course.backgroundImage});` : ''; |
|
|
|
|
@ -340,13 +404,30 @@ |
|
|
|
|
set: function (value) { |
|
|
|
|
this.course.price = value; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
categorySelect: { |
|
|
|
|
get() { |
|
|
|
|
if (!this.categoryOptions || this.categoryOptions.length === 0 || !this.course || !this.course.category) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
let value; |
|
|
|
|
this.categoryOptions.forEach((category) => { |
|
|
|
|
if (category.value === this.course.category) { |
|
|
|
|
value = category; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return value; |
|
|
|
|
}, |
|
|
|
|
set(value) { |
|
|
|
|
this.course.category = value.value; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
components: { |
|
|
|
|
LilSelect, |
|
|
|
|
BlockText, |
|
|
|
|
'link-input': LinkInput, |
|
|
|
|
'vue-datepicker': Datepicker, |
|
|
|
|
'vue-datepicker': DatePicker, |
|
|
|
|
'block-text': BlockText, |
|
|
|
|
'block-image': BlockImage, |
|
|
|
|
'block-image-text': BlockImageText, |
|
|
|
|
|