asciibird/src/components/modals/PasteAscii.vue

96 lines
1.8 KiB
Vue
Raw Normal View History

<template>
<t-modal
name="paste-ascii-modal"
header="Import from Clipboard"
2021-08-04 03:21:06 +00:00
:click-to-close="false"
:esc-to-close="true"
@closed="$store.commit('closeModal', 'paste-ascii')"
>
Title
<t-input
type="text"
name="title"
v-model="title"
max="128"
/>
<t-textarea
v-model="pasteContent"
name="paste-ascii"
rows="10"
/>
<template v-slot:footer>
2021-08-05 05:38:01 +00:00
<div class="flex justify-between">
<t-button
type="button"
2021-08-05 05:38:01 +00:00
@click="$store.commit('closeModal', 'paste-ascii')"
>
2021-08-04 03:21:06 +00:00
Cancel
</t-button>
<t-button
type="button"
@click="importPasteAscii()"
:disabled="checkPasteContent"
>
2021-08-04 03:21:06 +00:00
Import Clipboard
</t-button>
</div>
</template>
</t-modal>
</template>
<script>
//
2021-08-05 05:38:01 +00:00
import { parseMircAscii } from "../../ascii";
export default {
2021-08-05 05:38:01 +00:00
name: "PasteAsciiModal",
created() {},
2021-08-19 01:42:33 +00:00
mounted() {
if (this.showPasteAscii) {
this.open()
} else {
this.close()
}
},
data: () => ({
2021-08-05 05:38:01 +00:00
pasteContent: "",
title: "clipboard.txt",
}),
computed: {
showPasteAscii() {
return this.$store.getters.modalState.pasteAscii;
},
checkPasteContent() {
2021-08-04 03:21:06 +00:00
return !this.pasteContent.length;
},
},
watch: {
showPasteAscii(val, old) {
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
}
},
},
methods: {
open() {
2021-08-05 05:38:01 +00:00
this.$modal.show("paste-ascii-modal");
},
close() {
2021-08-05 05:38:01 +00:00
this.pasteContent = "";
this.title = "clipboard.txt";
this.$modal.hide("paste-ascii-modal");
},
importPasteAscii() {
2021-08-05 05:38:01 +00:00
parseMircAscii(this.pasteContent, this.title);
this.close();
},
},
};
</script>