From 951765f2c14bfdc175f7f15d3e57163447997543 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 27 Nov 2019 14:38:25 +0000 Subject: [PATCH] Plugin form refresh button updates form schema itself --- src/components/panelLeft.vue | 2 ++ src/components/pluginComponents/JsonForm.vue | 21 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/panelLeft.vue b/src/components/panelLeft.vue index 8e294df9..a3e927ab 100644 --- a/src/components/panelLeft.vue +++ b/src/components/panelLeft.vue @@ -116,6 +116,7 @@ :submit-label="form.submitLabel" :self-update="form.selfUpdate" :schema="form.schema" + @reloadForms="updatePlugins()" />
@@ -201,6 +202,7 @@ export default { methods: { updatePlugins: function() { + console.log("Updating plugin forms"); axios .get(this.pluginsUri) .then(response => { diff --git a/src/components/pluginComponents/JsonForm.vue b/src/components/pluginComponents/JsonForm.vue index da0862b2..fcbb5570 100644 --- a/src/components/pluginComponents/JsonForm.vue +++ b/src/components/pluginComponents/JsonForm.vue @@ -4,11 +4,7 @@
{{ name }}
- cached @@ -171,9 +167,14 @@ export default { } }, - updateForm(fieldName, value) { - this.$set(this.formData, fieldName, value); - this.$emit("input", this.formData); + updateForm() { + // Trigger a plugin form update + this.$emit("reloadForms"); + // If the form can self-update (GET request to update component values) + if (this.selfUpdate) { + // Update form data values using a GET request + this.getFormData(); + } }, getFormData: function() { @@ -199,9 +200,7 @@ export default { // Do something with the response console.log(response); // Update the form data if we're self-updating - if (this.selfUpdate) { - this.getFormData(); - } + this.updateForm(); }) .catch(error => { this.modalError(error); // Let mixin handle error