LIL-515 Превью при создании урока курса

remotes/origin/feature/effective_amount
gzbender 8 years ago
parent 5c43c43d91
commit cda44840f5
  1. 38
      web/src/components/LessonRedactor.vue
  2. 3
      web/src/js/modules/api.js

@ -14,16 +14,22 @@
</div> </div>
<div class="kit__title title">{{ title }}</div> <div class="kit__title title">{{ title }}</div>
<div class="kit__section"> <div class="kit__section">
<div class="kit__field field" <div class="kit__row">
v-bind:class="{ error: $v.currentLesson.title.$invalid }"> <lil-image :image-id.sync="lesson.coverImageId" :image-url.sync="lesson.coverImage"
<div class="field__wrap"> v-on:update:imageUrl="onUpdateCoverUrl" v-on:update:imageId="onUpdateCoverId" :access-token="accessToken"/>
<input type="text" class="field__input" placeholder="Название урока" v-model="lesson.title"> <div class="kit__fieldset">
</div> <div class="kit__field field"
</div> v-bind:class="{ error: $v.currentLesson.title.$invalid }">
<div class="kit__field field" <div class="field__wrap">
v-bind:class="{ error: $v.currentLesson.short_description.$invalid }"> <input type="text" class="field__input" placeholder="Название урока" v-model="lesson.title">
<div class="field__wrap"> </div>
<textarea class="field__input" v-autosize="lesson.short_description" placeholder="Описание урока" v-model="lesson.short_description"></textarea> </div>
<div class="kit__field field"
v-bind:class="{ error: $v.currentLesson.short_description.$invalid }">
<div class="field__wrap">
<textarea class="field__input" v-autosize="lesson.short_description" placeholder="Описание урока" v-model="lesson.short_description"></textarea>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -81,6 +87,7 @@
import BlockImages from './blocks/BlockImages' import BlockImages from './blocks/BlockImages'
import BlockImageText from './blocks/BlockImageText' import BlockImageText from './blocks/BlockImageText'
import BlockVideo from './blocks/BlockVideo' import BlockVideo from './blocks/BlockVideo'
import LilImage from "./blocks/Image"
import {api} from "../js/modules/api"; import {api} from "../js/modules/api";
import Draggable from 'vuedraggable'; import Draggable from 'vuedraggable';
import _ from 'lodash' import _ from 'lodash'
@ -105,7 +112,13 @@
if (blockToRemove.data.id) { if (blockToRemove.data.id) {
api.removeContentBlock(blockToRemove, this.accessToken); api.removeContentBlock(blockToRemove, this.accessToken);
} }
} },
onUpdateCoverUrl(newValue) {
this.lesson.coverImage = newValue;
},
onUpdateCoverId(newValue) {
this.lesson.coverImageId = newValue;
},
}, },
computed: { computed: {
title() { title() {
@ -120,10 +133,11 @@
'block-images': BlockImages, 'block-images': BlockImages,
'block-video': BlockVideo, 'block-video': BlockVideo,
'vue-draggable': Draggable, 'vue-draggable': Draggable,
'lil-image': LilImage,
} }
} }
</script> </script>
<style scoped> <style scoped>
</style> </style>

@ -204,6 +204,7 @@ export const api = {
const isAdding = (!lessonObject.hasOwnProperty('id') || !lessonObject.hasOwnProperty('id')); const isAdding = (!lessonObject.hasOwnProperty('id') || !lessonObject.hasOwnProperty('id'));
const lessonJson = { const lessonJson = {
cover: lessonObject.coverImageId ? lessonObject.coverImageId : null,
title: lessonObject.title, title: lessonObject.title,
short_description: lessonObject.short_description, short_description: lessonObject.short_description,
course: lessonObject.course_id, course: lessonObject.course_id,
@ -284,6 +285,8 @@ export const api = {
id: lessonJSON.id, id: lessonJSON.id,
title: lessonJSON.title, title: lessonJSON.title,
short_description: lessonJSON.short_description, short_description: lessonJSON.short_description,
coverImageId: lessonJSON.cover && lessonJSON.cover.id ? lessonJSON.cover.id : null,
coverImage: lessonJSON.cover && lessonJSON.cover.image ? lessonJSON.cover.image : null,
content: api.convertContentResponse(lessonJSON.content) content: api.convertContentResponse(lessonJSON.content)
} }
}, },

Loading…
Cancel
Save