| 1 |
Vue.component('wpuf-template-modal', { |
| 2 |
template: '#tmpl-wpuf-template-modal', |
| 3 |
|
| 4 |
props: { |
| 5 |
show: Boolean, |
| 6 |
onClose: Function, |
| 7 |
}, |
| 8 |
|
| 9 |
data: function() { |
| 10 |
return { |
| 11 |
loading: false, |
| 12 |
category: 'all', |
| 13 |
}; |
| 14 |
}, |
| 15 |
|
| 16 |
methods: { |
| 17 |
|
| 18 |
blankForm: function(target) { |
| 19 |
this.createForm( 'blank', target ); |
| 20 |
}, |
| 21 |
|
| 22 |
createForm: function(form, target) { |
| 23 |
var self = this; |
| 24 |
|
| 25 |
// already on a request? |
| 26 |
if ( self.loading ) { |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
self.loading = true; |
| 31 |
|
| 32 |
$(target).addClass('updating-message'); |
| 33 |
|
| 34 |
wp.ajax.send( 'weforms_contact_form_template', { |
| 35 |
data: { |
| 36 |
template: form, |
| 37 |
_wpnonce: weForms.nonce |
| 38 |
}, |
| 39 |
|
| 40 |
success: function(response) { |
| 41 |
self.$router.push({ |
| 42 |
name: 'edit', |
| 43 |
params: { id: response.id } |
| 44 |
}); |
| 45 |
}, |
| 46 |
|
| 47 |
error: function(error) { |
| 48 |
|
| 49 |
}, |
| 50 |
|
| 51 |
complete: function() { |
| 52 |
self.loading = false; |
| 53 |
|
| 54 |
$(target).removeClass('updating-message'); |
| 55 |
} |
| 56 |
}); |
| 57 |
} |
| 58 |
} |
| 59 |
}); |
| 60 |
|