Commit 951765f2 authored by Joel Collins's avatar Joel Collins
Browse files

Plugin form refresh button updates form schema itself

parent 0d17508b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@
              :submit-label="form.submitLabel"
              :self-update="form.selfUpdate"
              :schema="form.schema"
              @reloadForms="updatePlugins()"
            />
            <hr />
          </div>
@@ -201,6 +202,7 @@ export default {

  methods: {
    updatePlugins: function() {
      console.log("Updating plugin forms");
      axios
        .get(this.pluginsUri)
        .then(response => {
+10 −11
Original line number Diff line number Diff line
@@ -4,11 +4,7 @@
      <div class="uk-text-bold uk-text-uppercase uk-width-expand">
        {{ name }}
      </div>
      <a
        v-if="selfUpdate"
        href="#"
        class="uk-icon uk-width-auto"
        @click="getFormData()"
      <a href="#" class="uk-icon uk-width-auto" @click="updateForm()"
        ><i class="material-icons">cached</i></a
      >
    </div>
@@ -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