2020-07-11 03:13:11 +02:00
|
|
|
<template>
|
2020-10-17 13:12:00 +02:00
|
|
|
<XModalWindow ref="dialog"
|
|
|
|
:width="400"
|
|
|
|
:can-close="false"
|
|
|
|
:with-ok-button="true"
|
|
|
|
:ok-button-disabled="false"
|
|
|
|
@click="cancel()"
|
|
|
|
@ok="ok()"
|
|
|
|
@close="cancel()"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
>
|
2020-07-11 03:13:11 +02:00
|
|
|
<template #header>
|
|
|
|
{{ title }}
|
|
|
|
</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
<div class="xkpnjxcv _section">
|
2020-07-11 03:13:11 +02:00
|
|
|
<label v-for="item in Object.keys(form).filter(item => !form[item].hidden)" :key="item">
|
2020-10-17 13:12:00 +02:00
|
|
|
<MkInput v-if="form[item].type === 'number'" v-model:value="values[item]" type="number" :step="form[item].step || 1">
|
2020-07-29 17:35:07 +02:00
|
|
|
<span v-text="form[item].label || item"></span>
|
|
|
|
<template v-if="form[item].description" #desc>{{ form[item].description }}</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-else-if="form[item].type === 'string' && !item.multiline" v-model:value="values[item]" type="text">
|
2020-07-29 17:35:07 +02:00
|
|
|
<span v-text="form[item].label || item"></span>
|
|
|
|
<template v-if="form[item].description" #desc>{{ form[item].description }}</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
</MkInput>
|
|
|
|
<MkTextarea v-else-if="form[item].type === 'string' && item.multiline" v-model:value="values[item]">
|
2020-07-29 17:35:07 +02:00
|
|
|
<span v-text="form[item].label || item"></span>
|
|
|
|
<template v-if="form[item].description" #desc>{{ form[item].description }}</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
</MkTextarea>
|
|
|
|
<MkSwitch v-else-if="form[item].type === 'boolean'" v-model:value="values[item]">
|
2020-07-29 17:35:07 +02:00
|
|
|
<span v-text="form[item].label || item"></span>
|
|
|
|
<template v-if="form[item].description" #desc>{{ form[item].description }}</template>
|
2020-10-17 13:12:00 +02:00
|
|
|
</MkSwitch>
|
2020-07-11 03:13:11 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</XModalWindow>
|
2020-07-11 03:13:11 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import XModalWindow from '@/components/ui/modal-window.vue';
|
2020-07-11 03:13:11 +02:00
|
|
|
import MkInput from './ui/input.vue';
|
|
|
|
import MkTextarea from './ui/textarea.vue';
|
|
|
|
import MkSwitch from './ui/switch.vue';
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-07-11 03:13:11 +02:00
|
|
|
components: {
|
2020-10-17 13:12:00 +02:00
|
|
|
XModalWindow,
|
2020-07-11 03:13:11 +02:00
|
|
|
MkInput,
|
|
|
|
MkTextarea,
|
|
|
|
MkSwitch,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
form: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
emits: ['done'],
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
values: {}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
for (const item in this.form) {
|
2020-10-17 13:12:00 +02:00
|
|
|
this.values[item] = this.form[item].hasOwnProperty('default') ? this.form[item].default : null;
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
ok() {
|
2020-10-17 13:12:00 +02:00
|
|
|
this.$emit('done', {
|
|
|
|
result: this.values
|
|
|
|
});
|
|
|
|
this.$refs.dialog.close();
|
2020-07-11 03:13:11 +02:00
|
|
|
},
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
cancel() {
|
|
|
|
this.$emit('done', {
|
|
|
|
canceled: true
|
|
|
|
});
|
|
|
|
this.$refs.dialog.close();
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xkpnjxcv {
|
|
|
|
> label {
|
|
|
|
display: block;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-bottom: 32px;
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|