Allow plugins to emit events on submission response
This commit is contained in:
parent
6a46b11997
commit
1a55be12cf
1 changed files with 16 additions and 5 deletions
|
|
@ -111,6 +111,11 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: "Submit"
|
default: "Submit"
|
||||||
|
},
|
||||||
|
emitOnResponse: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -201,6 +206,13 @@ export default {
|
||||||
this.$emit("reloadForms");
|
this.$emit("reloadForms");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSubmissionCompleted: function() {
|
||||||
|
if (this.emitOnResponse) {
|
||||||
|
this.$root.$emit(this.emitOnResponse);
|
||||||
|
}
|
||||||
|
this.updateForm();
|
||||||
|
},
|
||||||
|
|
||||||
newQuickRequest: function(params) {
|
newQuickRequest: function(params) {
|
||||||
console.log(this.submitApiUri);
|
console.log(this.submitApiUri);
|
||||||
console.log(params);
|
console.log(params);
|
||||||
|
|
@ -210,8 +222,8 @@ export default {
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// Do something with the response
|
// Do something with the response
|
||||||
console.log(response);
|
console.log(response);
|
||||||
// Update the form data if we're self-updating
|
// Do all the finished request stuff
|
||||||
this.updateForm();
|
this.onSubmissionCompleted();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.modalError(error); // Let mixin handle error
|
this.modalError(error); // Let mixin handle error
|
||||||
|
|
@ -222,9 +234,8 @@ export default {
|
||||||
|
|
||||||
onTaskResponse: function(responseData) {
|
onTaskResponse: function(responseData) {
|
||||||
console.log("Task finished with response data: ", responseData);
|
console.log("Task finished with response data: ", responseData);
|
||||||
if (this.selfUpdate) {
|
// Do all the finished request stuff
|
||||||
this.getFormData();
|
this.onSubmissionCompleted();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onTaskError: function(error) {
|
onTaskError: function(error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue