| 1 |
<template> |
| 2 |
<div :class="{'ff_backdrop': visibility}"> |
| 3 |
<el-dialog :visible="visibility" :before-close="close"> |
| 4 |
<span slot="title" class="el-dialog__title"> |
| 5 |
Add a New Form |
| 6 |
</span> |
| 7 |
<el-form :model="{}" label-position="top" @submit.native.prevent="add"> |
| 8 |
<el-form-item label="Your Form Name"> |
| 9 |
<el-input class="addNewForm" v-model="form_title" type="text" placeholder="Awesome Form"></el-input> |
| 10 |
</el-form-item> |
| 11 |
</el-form> |
| 12 |
|
| 13 |
<span slot="footer" class="dialog-footer"> |
| 14 |
<el-button @click="close">Cancel</el-button> |
| 15 |
<el-button :loading="loading" type="primary" @click="add"> |
| 16 |
<span v-if="loading">Creating Form...</span> |
| 17 |
<span v-else>Add Form</span> |
| 18 |
</el-button> |
| 19 |
</span> |
| 20 |
</el-dialog> |
| 21 |
</div> |
| 22 |
</template> |
| 23 |
|
| 24 |
<script> |
| 25 |
export default { |
| 26 |
name: 'AddFormModal', |
| 27 |
props: { |
| 28 |
visibility: Boolean |
| 29 |
}, |
| 30 |
data() { |
| 31 |
return { |
| 32 |
loading: false, |
| 33 |
status: 'published', |
| 34 |
templates: { |
| 35 |
blank: 'Blank Form', |
| 36 |
contact: 'Contact Form', |
| 37 |
support: 'Support Form', |
| 38 |
eventRegistration: 'Event Registration', |
| 39 |
}, |
| 40 |
template: '', |
| 41 |
form_title: '' |
| 42 |
} |
| 43 |
}, |
| 44 |
methods: { |
| 45 |
close() { |
| 46 |
this.$emit('update:visibility', false); |
| 47 |
}, |
| 48 |
add() { |
| 49 |
this.loading = true; |
| 50 |
let data = { |
| 51 |
action: this.$action.saveForm, |
| 52 |
type: this.template, |
| 53 |
title: this.form_title, |
| 54 |
status: this.status |
| 55 |
}; |
| 56 |
|
| 57 |
jQuery.post(ajaxurl, data) |
| 58 |
.then((response) => { |
| 59 |
this.$notify.success({ |
| 60 |
title: 'Congratulations!', |
| 61 |
message: response.data.message, |
| 62 |
offset: 30 |
| 63 |
}); |
| 64 |
window.location.href = response.data.redirect_url; |
| 65 |
}) |
| 66 |
.fail(error => { |
| 67 |
this.$message.error('Please Provide the form name'); |
| 68 |
}) |
| 69 |
.always(() => { |
| 70 |
this.loading = false; |
| 71 |
}) |
| 72 |
} |
| 73 |
}, |
| 74 |
watch: { |
| 75 |
visibility() { |
| 76 |
if (this.visibility) |
| 77 |
this.$nextTick( _ => jQuery('.addNewForm input').focus()); |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
</script> |
| 82 |
|
| 83 |
<style> |
| 84 |
small { |
| 85 |
font-weight: normal; |
| 86 |
font-size: 13px; |
| 87 |
margin-left: 15px; |
| 88 |
} |
| 89 |
</style> |