2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2019-05-02 10:55:59 +02:00
|
|
|
<x-container @remove="() => $emit('remove')" :draggable="true">
|
2020-01-29 20:37:25 +01:00
|
|
|
<template #header><fa :icon="faQuestion"/> {{ $t('_pages.blocks.if') }}</template>
|
2019-04-29 02:11:57 +02:00
|
|
|
<template #func>
|
2020-04-16 16:13:33 +02:00
|
|
|
<button @click="add()" class="_button">
|
2019-04-29 02:11:57 +02:00
|
|
|
<fa :icon="faPlus"/>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2019-04-29 23:40:02 +02:00
|
|
|
<section class="romcojzs">
|
2020-01-29 20:37:25 +01:00
|
|
|
<mk-select v-model="value.var">
|
|
|
|
<template #label>{{ $t('_pages.blocks._if.variable') }}</template>
|
2020-04-12 20:23:23 +02:00
|
|
|
<option v-for="v in aoiScript.getVarsByType('boolean')" :value="v.name">{{ v.name }}</option>
|
2020-01-29 20:37:25 +01:00
|
|
|
<optgroup :label="$t('_pages.script.pageVariables')">
|
2020-04-12 20:23:23 +02:00
|
|
|
<option v-for="v in aoiScript.getPageVarsByType('boolean')" :value="v">{{ v }}</option>
|
2019-04-29 23:40:02 +02:00
|
|
|
</optgroup>
|
2020-01-29 20:37:25 +01:00
|
|
|
<optgroup :label="$t('_pages.script.enviromentVariables')">
|
2020-04-12 20:23:23 +02:00
|
|
|
<option v-for="v in aoiScript.getEnvVarsByType('boolean')" :value="v">{{ v }}</option>
|
2019-04-29 23:40:02 +02:00
|
|
|
</optgroup>
|
2020-01-29 20:37:25 +01:00
|
|
|
</mk-select>
|
2019-04-29 23:40:02 +02:00
|
|
|
|
2020-04-12 20:23:23 +02:00
|
|
|
<x-blocks class="children" v-model="value.children" :aoi-script="aoiScript"/>
|
2019-04-29 02:11:57 +02:00
|
|
|
</section>
|
|
|
|
</x-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-08-18 05:42:58 +02:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2019-04-29 23:40:02 +02:00
|
|
|
import { faPlus, faQuestion } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 20:37:25 +01:00
|
|
|
import i18n from '../../../i18n';
|
2019-04-29 23:40:02 +02:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
import MkSelect from '../../../components/ui/select.vue';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2020-01-29 20:37:25 +01:00
|
|
|
i18n,
|
2019-04-29 02:11:57 +02:00
|
|
|
|
|
|
|
components: {
|
2020-01-29 20:37:25 +01:00
|
|
|
XContainer, MkSelect
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
2019-04-29 23:40:02 +02:00
|
|
|
inject: ['getPageBlockList'],
|
|
|
|
|
2019-04-29 02:11:57 +02:00
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
required: true
|
|
|
|
},
|
2020-04-12 20:23:23 +02:00
|
|
|
aoiScript: {
|
2019-04-29 23:40:02 +02:00
|
|
|
required: true,
|
|
|
|
},
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2019-04-29 23:40:02 +02:00
|
|
|
faPlus, faQuestion
|
2019-04-29 02:11:57 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeCreate() {
|
2019-05-02 10:55:59 +02:00
|
|
|
this.$options.components.XBlocks = require('../page-editor.blocks.vue').default
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
if (this.value.children == null) Vue.set(this.value, 'children', []);
|
2019-04-29 23:40:02 +02:00
|
|
|
if (this.value.var === undefined) Vue.set(this.value, 'var', null);
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async add() {
|
|
|
|
const { canceled, result: type } = await this.$root.dialog({
|
|
|
|
type: null,
|
2020-03-22 02:51:40 +01:00
|
|
|
title: this.$t('_pages.chooseBlock'),
|
2019-04-29 02:11:57 +02:00
|
|
|
select: {
|
2019-04-30 05:15:41 +02:00
|
|
|
groupedItems: this.getPageBlockList()
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2019-08-18 05:42:58 +02:00
|
|
|
const id = uuid();
|
2019-04-29 02:11:57 +02:00
|
|
|
this.value.children.push({ id, type });
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.romcojzs {
|
|
|
|
padding: 0 16px 16px 16px;
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
</style>
|