From c54e5fad403835ac68c6c41e6841658fc1189044 Mon Sep 17 00:00:00 2001 From: guerler Date: Thu, 27 May 2021 12:42:43 -0400 Subject: [PATCH 01/58] Replace legacy tool form wrapper with Vue component --- client/package.json | 1 + client/src/components/Form/Form.vue | 81 +++- client/src/components/Form/FormCardTool.vue | 2 + client/src/components/Form/FormElement.vue | 11 +- client/src/components/Tool/services.js | 39 ++ client/src/entry/analysis/AnalysisRouter.js | 4 +- client/src/mvc/form/form-input.js | 4 +- client/src/mvc/form/form-view.js | 2 +- client/src/mvc/tool/tool-form.js | 472 -------------------- client/tests/qunit/tests/form_tests.js | 18 +- client/yarn.lock | 12 + 11 files changed, 154 insertions(+), 492 deletions(-) delete mode 100644 client/src/mvc/tool/tool-form.js diff --git a/client/package.json b/client/package.json index b0ef323b5aa..2faba245fb7 100644 --- a/client/package.json +++ b/client/package.json @@ -81,6 +81,7 @@ "vue-observe-visibility": "^1.0.0", "vue-router": "^3.3.1", "vue-rx": "^6.2.0", + "vue-scrollto": "^2.20.0", "vuedraggable": "2.24.1", "vueisotope": "^3.1.2", "vuex": "^3.4.0", diff --git a/client/src/components/Form/Form.vue b/client/src/components/Form/Form.vue index 078671ffa80..a9bc63db550 100644 --- a/client/src/components/Form/Form.vue +++ b/client/src/components/Form/Form.vue @@ -3,6 +3,7 @@ diff --git a/client/src/components/Common/Webhook.vue b/client/src/components/Common/Webhook.vue new file mode 100644 index 00000000000..72cdbceadb8 --- /dev/null +++ b/client/src/components/Common/Webhook.vue @@ -0,0 +1,27 @@ + + diff --git a/client/src/components/Form/Elements/FormBoolean.vue b/client/src/components/Form/Elements/FormBoolean.vue new file mode 100644 index 00000000000..6e3b3366ee7 --- /dev/null +++ b/client/src/components/Form/Elements/FormBoolean.vue @@ -0,0 +1,34 @@ + + + diff --git a/client/src/components/Form/Elements/FormInput.test.js b/client/src/components/Form/Elements/FormInput.test.js new file mode 100644 index 00000000000..ebe24aa5960 --- /dev/null +++ b/client/src/components/Form/Elements/FormInput.test.js @@ -0,0 +1,38 @@ +import { mount } from "@vue/test-utils"; +import { getLocalVue } from "jest/helpers"; +import FormInput from "./FormInput"; + +jest.mock("app"); + +const localVue = getLocalVue(); + +describe("FormInput", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(FormInput, { + propsData: { + id: "input", + value: "initial_value", + }, + localVue, + }); + }); + + it("check initial value and value change", async () => { + const input = wrapper.find("input"); + expect(input.element.value).toBe("initial_value"); + await input.setValue("new_value"); + expect(input.element.value).toBe("new_value"); + expect(wrapper.emitted().onChange[0][0]).toBe("new_value"); + }); + + it("check switching to text area", async () => { + await wrapper.setProps({ area: true }); + const input = wrapper.find("textarea"); + expect(input.element.value).toBe("initial_value"); + await input.setValue("new_value"); + expect(input.element.value).toBe("new_value"); + expect(wrapper.emitted().onChange[0][0]).toBe("new_value"); + }); +}); diff --git a/client/src/components/Form/Elements/FormInput.vue b/client/src/components/Form/Elements/FormInput.vue new file mode 100644 index 00000000000..ee344d00eb5 --- /dev/null +++ b/client/src/components/Form/Elements/FormInput.vue @@ -0,0 +1,37 @@ +