hippofish/src/client/pages/page-editor/els/page-editor.el.if.vue

92 lines
2.2 KiB
Vue
Raw Normal View History

<template>
2019-05-02 10:55:59 +02:00
<x-container @remove="() => $emit('remove')" :draggable="true">
<template #header><fa :icon="faQuestion"/> {{ $t('_pages.blocks.if') }}</template>
<template #func>
<button @click="add()">
<fa :icon="faPlus"/>
</button>
</template>
<section class="romcojzs">
<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>
<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>
</optgroup>
<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>
</optgroup>
</mk-select>
2020-04-12 20:23:23 +02:00
<x-blocks class="children" v-model="value.children" :aoi-script="aoiScript"/>
</section>
</x-container>
</template>
<script lang="ts">
import Vue from 'vue';
import { v4 as uuid } from 'uuid';
import { faPlus, faQuestion } from '@fortawesome/free-solid-svg-icons';
import i18n from '../../../i18n';
import XContainer from '../page-editor.container.vue';
import MkSelect from '../../../components/ui/select.vue';
export default Vue.extend({
i18n,
components: {
XContainer, MkSelect
},
inject: ['getPageBlockList'],
props: {
value: {
required: true
},
2020-04-12 20:23:23 +02:00
aoiScript: {
required: true,
},
},
data() {
return {
faPlus, faQuestion
};
},
beforeCreate() {
2019-05-02 10:55:59 +02:00
this.$options.components.XBlocks = require('../page-editor.blocks.vue').default
},
created() {
if (this.value.children == null) Vue.set(this.value, 'children', []);
if (this.value.var === undefined) Vue.set(this.value, 'var', null);
},
methods: {
async add() {
const { canceled, result: type } = await this.$root.dialog({
type: null,
title: this.$t('_pages.chooseBlock'),
select: {
2019-04-30 05:15:41 +02:00
groupedItems: this.getPageBlockList()
},
showCancelButton: true
});
if (canceled) return;
const id = uuid();
this.value.children.push({ id, type });
},
}
});
</script>
<style lang="scss" scoped>
.romcojzs {
padding: 0 16px 16px 16px;
}
</style>