asciibird/src/components/modals/NewAscii.vue

113 lines
2.1 KiB
Vue
Raw Normal View History

2021-04-24 00:20:11 +00:00
<template>
2021-04-24 00:42:33 +00:00
<t-modal
name="new-ascii-modal"
2021-04-24 00:42:33 +00:00
header="Create new ASCII"
2021-08-04 03:21:06 +00:00
:click-to-close="false"
:esc-to-close="true"
@closed="$store.commit('closeModal', 'new-ascii')"
2021-04-24 00:42:33 +00:00
>
Width
<t-input
type="number"
name="width"
v-model="forms.createAscii.width"
min="1"
/>
2021-04-24 00:20:11 +00:00
2021-04-24 00:42:33 +00:00
Height
<t-input
type="number"
name="height"
v-model="forms.createAscii.height"
min="1"
/>
2021-04-24 00:20:11 +00:00
2021-04-24 00:42:33 +00:00
Title
<t-input
type="text"
name="title"
v-model="forms.createAscii.title"
max="128"
/>
2021-04-24 00:20:11 +00:00
2021-04-24 00:42:33 +00:00
<template v-slot:footer>
<div
class="flex justify-between"
@click="$store.commit('closeModal', 'new-ascii')"
2021-04-24 00:42:33 +00:00
>
2021-08-17 00:24:41 +00:00
<t-button
type="button"
class="p-2"
>
Cancel
</t-button>
<t-button
type="button"
2021-08-17 00:24:41 +00:00
class="p-2"
@click="initiateNewAscii()"
>
Ok
</t-button>
2021-04-24 00:42:33 +00:00
</div>
</template>
</t-modal>
2021-04-24 00:20:11 +00:00
</template>
<script>
2021-08-05 05:38:01 +00:00
import createNewASCII from "../../ascii";
2021-04-24 00:20:11 +00:00
export default {
2021-08-05 05:38:01 +00:00
name: "NewAsciiModal",
2021-04-24 00:20:11 +00:00
created() {},
2021-08-19 01:42:33 +00:00
mounted() {
if (this.showNewAsciiModal) {
this.open()
} else {
this.close()
}
},
2021-04-24 00:20:11 +00:00
data: () => ({
forms: {
createAscii: {
2021-05-08 01:51:30 +00:00
width: 80,
height: 30,
2021-08-05 05:38:01 +00:00
title: "ascii",
2021-04-24 00:20:11 +00:00
},
},
}),
2021-04-24 00:42:33 +00:00
computed: {
showNewAsciiModal() {
return this.$store.getters.modalState.newAscii;
},
},
2021-04-24 00:20:11 +00:00
watch: {
showNewAsciiModal(val) {
if (val === true) {
this.open();
2021-08-05 05:38:01 +00:00
}
if (val === false) {
this.close();
2021-08-05 05:38:01 +00:00
}
2021-04-24 00:42:33 +00:00
},
2021-04-24 00:20:11 +00:00
},
methods: {
open() {
2021-08-05 05:38:01 +00:00
this.$modal.show("new-ascii-modal");
this.forms.createAscii.title = `New ASCII ${
this.$store.getters.asciibirdMeta.length + 1
}`;
2021-04-24 00:20:11 +00:00
},
close() {
2021-08-05 05:38:01 +00:00
this.$modal.hide("new-ascii-modal");
2021-05-08 01:51:30 +00:00
this.forms.createAscii.width = 80;
this.forms.createAscii.height = 30;
2021-08-05 05:38:01 +00:00
this.forms.createAscii.title = "New ASCII";
2021-04-24 00:20:11 +00:00
},
initiateNewAscii() {
2021-08-05 05:38:01 +00:00
createNewASCII(this.forms);
},
2021-04-24 00:20:11 +00:00
},
};
</script>