2019-04-29 00:11:57 +00:00
|
|
|
<template>
|
2019-05-02 08:55:59 +00:00
|
|
|
<x-container @remove="() => $emit('remove')" :draggable="true">
|
2019-04-29 00:11:57 +00:00
|
|
|
<template #header><fa :icon="faStickyNote"/> {{ value.title }}</template>
|
|
|
|
<template #func>
|
|
|
|
<button @click="rename()">
|
|
|
|
<fa :icon="faPencilAlt"/>
|
|
|
|
</button>
|
|
|
|
<button @click="add()">
|
|
|
|
<fa :icon="faPlus"/>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<section class="ilrvjyvi">
|
2019-05-02 08:55:59 +00:00
|
|
|
<x-blocks class="children" v-model="value.children" :ai-script="aiScript"/>
|
2019-04-29 00:11:57 +00:00
|
|
|
</section>
|
|
|
|
</x-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-08-18 03:42:58 +00:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2019-04-29 00:11:57 +00:00
|
|
|
import { faPlus, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faStickyNote } from '@fortawesome/free-regular-svg-icons';
|
2020-01-29 19:37:25 +00:00
|
|
|
import i18n from '../../../i18n';
|
2019-04-29 21:40:02 +00:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2019-04-29 00:11:57 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2020-01-29 19:37:25 +00:00
|
|
|
i18n,
|
2019-04-29 00:11:57 +00:00
|
|
|
|
|
|
|
components: {
|
|
|
|
XContainer
|
|
|
|
},
|
|
|
|
|
2019-04-29 21:40:02 +00:00
|
|
|
inject: ['getPageBlockList'],
|
|
|
|
|
2019-04-29 00:11:57 +00:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: true
|
|
|
|
},
|
2019-04-29 21:40:02 +00:00
|
|
|
aiScript: {
|
|
|
|
required: true,
|
|
|
|
},
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
faStickyNote, faPlus, faPencilAlt
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeCreate() {
|
2019-05-02 08:55:59 +00:00
|
|
|
this.$options.components.XBlocks = require('../page-editor.blocks.vue').default
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
if (this.value.title == null) Vue.set(this.value, 'title', null);
|
|
|
|
if (this.value.children == null) Vue.set(this.value, 'children', []);
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
if (this.value.title == null) {
|
|
|
|
this.rename();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async rename() {
|
|
|
|
const { canceled, result: title } = await this.$root.dialog({
|
|
|
|
title: 'Enter title',
|
|
|
|
input: {
|
|
|
|
type: 'text',
|
|
|
|
default: this.value.title
|
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
this.value.title = title;
|
|
|
|
},
|
|
|
|
|
|
|
|
async add() {
|
|
|
|
const { canceled, result: type } = await this.$root.dialog({
|
|
|
|
type: null,
|
2020-03-22 01:51:40 +00:00
|
|
|
title: this.$t('_pages.chooseBlock'),
|
2019-04-29 00:11:57 +00:00
|
|
|
select: {
|
2019-04-30 03:15:41 +00:00
|
|
|
groupedItems: this.getPageBlockList()
|
2019-04-29 00:11:57 +00:00
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2019-08-18 03:42:58 +00:00
|
|
|
const id = uuid();
|
2019-04-29 00:11:57 +00:00
|
|
|
this.value.children.push({ id, type });
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ilrvjyvi {
|
|
|
|
> .children {
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 00:11:57 +00:00
|
|
|
</style>
|