This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
IcyNet.eu/src/script/component/MailerModal.vue

60 lines
1.6 KiB
Vue

<template lang="pug">
modal(:show='show', @close='close')
.modal-header
h3 Send Email
.modal-body.aligned-form
.alert.alert-danger(v-if='error') {{ error }}
.form-group
label(for="email") Email
input.form-control(type="email" id="email" name="email" v-model="email")
.form-group
label(for="title") Title
input.form-control(type="text" id="title" name="title" v-model="title")
.form-group
label(for="content") Content
textarea.form-control(type="text" id="content" name="content" v-model="content")
.modal-footer.text-right
button.btn.btn-primary(@click='submit') Done
button.btn.btn-secondary(@click='close') Cancel
</template>
<script type="text/javascript">
import Modal from './Modal.vue'
const csrfToken = document.querySelector('meta[name="csrf-token"]').content
export default {
props: ['show', 'email'],
data: function () {
return {
error: '',
title: '',
content: ''
}
},
components: {
Modal
},
methods: {
close: function () {
this.$emit('close')
this.error = ''
this.title = ''
this.content = ''
},
submit: function () {
this.$http.post('/admin/api/email', {
email: this.email,
title: this.title,
content: this.content,
csrf: csrfToken
}).then(data => {
this.close()
}).catch(err => {
console.error(err)
if (err.body && err.body.error) this.error = err.body.error
})
}
}
}
</script>