tailbone/tailbone/static/themes/falafel/js/tailbone.feedback.js
Lance Edgar 069ccab0ae Clear feedback message after sending
that way user can open dialog again, and things not be weird
2019-07-05 19:54:57 -05:00

44 lines
1 KiB
JavaScript

let FeedbackForm = {
props: ['action'],
template: '#feedback-template',
methods: {
showFeedback() {
this.message = ''
this.showDialog = true
this.$nextTick(function() {
this.$refs.textarea.focus()
})
},
sendFeedback() {
let params = {
referrer: this.referrer,
user: this.userUUID,
user_name: this.userName,
message: this.message.trim(),
}
let headers = {
// TODO: should find a better way to handle CSRF token
'X-CSRF-TOKEN': this.csrftoken,
}
this.$http.post(this.action, params, {headers: headers}).then(({ data }) => {
this.showDialog = false
alert("Message successfully sent.\n\nThank you for your feedback.")
})
},
}
}
let FeedbackFormData = {
referrer: null,
userUUID: null,
userName: null,
message: '',
showDialog: false,
}