2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2020-10-17 13:12:00 +02:00
|
|
|
<XContainer @remove="() => $emit('remove')" :draggable="true">
|
2021-04-20 16:22:59 +02:00
|
|
|
<template #header><i class="fas fa-question"></i> {{ $ts._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">
|
2021-04-20 16:22:59 +02:00
|
|
|
<i class="fas fa-plus"></i>
|
2019-04-29 02:11:57 +02:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2019-04-29 23:40:02 +02:00
|
|
|
<section class="romcojzs">
|
2020-10-17 13:12:00 +02:00
|
|
|
<MkSelect v-model:value="value.var">
|
2020-12-26 02:47:36 +01:00
|
|
|
<template #label>{{ $ts._pages.blocks._if.variable }}</template>
|
2020-04-20 14:35:27 +02:00
|
|
|
<option v-for="v in hpml.getVarsByType('boolean')" :value="v.name">{{ v.name }}</option>
|
2020-12-26 02:47:36 +01:00
|
|
|
<optgroup :label="$ts._pages.script.pageVariables">
|
2020-04-20 14:35:27 +02:00
|
|
|
<option v-for="v in hpml.getPageVarsByType('boolean')" :value="v">{{ v }}</option>
|
2019-04-29 23:40:02 +02:00
|
|
|
</optgroup>
|
2020-12-26 02:47:36 +01:00
|
|
|
<optgroup :label="$ts._pages.script.enviromentVariables">
|
2020-04-20 14:35:27 +02:00
|
|
|
<option v-for="v in hpml.getEnvVarsByType('boolean')" :value="v">{{ v }}</option>
|
2019-04-29 23:40:02 +02:00
|
|
|
</optgroup>
|
2020-10-17 13:12:00 +02:00
|
|
|
</MkSelect>
|
2019-04-29 23:40:02 +02:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<XBlocks class="children" v-model:value="value.children" :hpml="hpml"/>
|
2019-04-29 02:11:57 +02:00
|
|
|
</section>
|
2020-10-17 13:12:00 +02:00
|
|
|
</XContainer>
|
2019-04-29 02:11:57 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-19 02:30:21 +02:00
|
|
|
import { defineComponent, defineAsyncComponent } 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 XContainer from '../page-editor.container.vue';
|
2021-03-23 09:30:14 +01:00
|
|
|
import MkSelect from '@client/components/ui/select.vue';
|
|
|
|
import * as os from '@client/os';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2019-04-29 02:11:57 +02:00
|
|
|
components: {
|
2020-10-19 02:30:21 +02:00
|
|
|
XContainer, MkSelect,
|
|
|
|
XBlocks: defineAsyncComponent(() => import('../page-editor.blocks.vue')),
|
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-20 14:35:27 +02:00
|
|
|
hpml: {
|
2019-04-29 23:40:02 +02:00
|
|
|
required: true,
|
|
|
|
},
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-10-17 13:12:00 +02:00
|
|
|
if (this.value.children == null) this.value.children = [];
|
|
|
|
if (this.value.var === undefined) this.value.var = null;
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async add() {
|
2020-10-17 13:12:00 +02:00
|
|
|
const { canceled, result: type } = await os.dialog({
|
2019-04-29 02:11:57 +02:00
|
|
|
type: null,
|
2020-12-26 02:47:36 +01:00
|
|
|
title: this.$ts._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>
|