|
|
|
|
@ -1,7 +1,29 @@ |
|
|
|
|
<template> |
|
|
|
|
<div> |
|
|
|
|
<vue-draggable :list="content" @start="drag=true" @end="drag=false" :options="{ handle: '.sortable__handle' }"> |
|
|
|
|
<div v-for="(block, index) in content" :key="block.id ? block.id : block.uuid"> |
|
|
|
|
<div v-for="(block, index) in content" :key="block.id ? block.id : block.uuid" class="kit__section kit__section--block"> |
|
|
|
|
<div class="kit__section-remove"> |
|
|
|
|
<button if="index != 0" type="button" @click="moveUp(index)"> |
|
|
|
|
<svg class="icon icon-arrow-up"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-arrow-up"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
<button if="index < (content.length - 1)" type="button" @click="moveDown(index)"> |
|
|
|
|
<svg class="icon icon-arrow-down"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-arrow-down"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
<button class="sortable__handle" type="button"> |
|
|
|
|
<svg class="icon icon-hamburger"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-hamburger"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
<button type="button" @click="onBlockRemoved(index)"> |
|
|
|
|
<svg class="icon icon-delete"> |
|
|
|
|
<use xlink:href="/static/img/sprite.svg#icon-delete"></use> |
|
|
|
|
</svg> |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
<block-text v-if="block.type === 'text'" |
|
|
|
|
:index="index" |
|
|
|
|
:title.sync="block.data.title" |
|
|
|
|
@ -55,6 +77,22 @@ |
|
|
|
|
name: 'block-content', |
|
|
|
|
props: ['content'], |
|
|
|
|
methods: { |
|
|
|
|
moveUp(blockIndex) { |
|
|
|
|
if(blockIndex <= 0){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const block = this.content[blockIndex]; |
|
|
|
|
const prevBlock = this.content[blockIndex - 1]; |
|
|
|
|
this.content.splice(blockIndex - 1, 2, block, prevBlock); |
|
|
|
|
}, |
|
|
|
|
moveDown(blockIndex) { |
|
|
|
|
if(blockIndex >= this.content.length - 1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const block = this.content[blockIndex]; |
|
|
|
|
const nextBlock = this.content[blockIndex + 1]; |
|
|
|
|
this.content.splice(blockIndex, 2, nextBlock, block); |
|
|
|
|
}, |
|
|
|
|
onBlockRemoved(blockIndex) { |
|
|
|
|
const remove = () => { |
|
|
|
|
// Удаляем блок из Vue |
|
|
|
|
|