From 5e69e52bcd997d0ea86daa00d2d9eaee09163c44 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Fri, 14 Jun 2019 15:35:08 +0100 Subject: [PATCH] Added strict one-way binding to all form components --- src/components/panelLeft.vue | 43 ++++++++++++---- .../formComponents/JsonForm.vue | 50 +++++++++++++++---- .../fieldComponents/checkList.vue | 47 +++++++++++++++++ .../fieldComponents/htmlBlock.vue | 1 + .../fieldComponents/numberInput.vue | 16 ++++-- .../fieldComponents/radioList.vue | 29 +++++++++++ .../fieldComponents/selectList.vue | 18 ++++--- .../fieldComponents/textInput.vue | 10 ++-- 8 files changed, 181 insertions(+), 33 deletions(-) create mode 100644 src/components/pluginComponents/formComponents/fieldComponents/checkList.vue create mode 100644 src/components/pluginComponents/formComponents/fieldComponents/radioList.vue diff --git a/src/components/panelLeft.vue b/src/components/panelLeft.vue index 7631cc40..915b0a75 100644 --- a/src/components/panelLeft.vue +++ b/src/components/panelLeft.vue @@ -94,15 +94,10 @@ export default { }, { fieldType: "textInput", - placeholder: "First Name", - label: "First Name", - name: "firstName" - }, - { - fieldType: "textInput", - placeholder: "Last Name", - label: "Last Name", - name: "lastName" + placeholder: "Name", + label: "Name", + name: "name", + value: "Squidward" }, { fieldType: "numberInput", @@ -110,7 +105,35 @@ export default { name: "age", label: "Age", minValue: 0 - } + }, + [ + { + fieldType: "numberInput", + placeholder: "Number", + name: "leftnum", + label: "Left" + }, + { + fieldType: "numberInput", + placeholder: "Number", + name: "rightnum", + label: "Right" + } + ], + { + fieldType: "radioList", + name: "coolness", + label: "Coolness", + options: ["None", "Some", "Very"], + value: "Some" + }, + { + fieldType: "checkList", + name: "ingredients", + label: "Ingredients", + options: ["Pork", "Pie"], + value: ["Pork"] + }, ] } ] diff --git a/src/components/pluginComponents/formComponents/JsonForm.vue b/src/components/pluginComponents/formComponents/JsonForm.vue index aaae3906..27ef597f 100644 --- a/src/components/pluginComponents/formComponents/JsonForm.vue +++ b/src/components/pluginComponents/formComponents/JsonForm.vue @@ -1,12 +1,24 @@ @@ -16,6 +28,8 @@ import numberInput from "./fieldComponents/numberInput"; import selectList from "./fieldComponents/selectList"; import textInput from "./fieldComponents/textInput"; import htmlBlock from "./fieldComponents/htmlBlock"; +import radioList from "./fieldComponents/radioList"; +import checkList from "./fieldComponents/checkList" export default { name: 'JsonForm', @@ -24,7 +38,9 @@ export default { numberInput, selectList, textInput, - htmlBlock + htmlBlock, + radioList, + checkList }, props: { @@ -43,8 +59,24 @@ export default { created: function () { // `this` points to the vm instance console.log(this.schema) + }, + + methods: { + updateForm(fieldName, value) { + console.log(`${fieldName}: ${value}`) + this.$set(this.formData, fieldName, value); + this.$emit('input', this.formData) + } } } - \ No newline at end of file + \ No newline at end of file diff --git a/src/components/pluginComponents/formComponents/fieldComponents/checkList.vue b/src/components/pluginComponents/formComponents/fieldComponents/checkList.vue new file mode 100644 index 00000000..62a832f8 --- /dev/null +++ b/src/components/pluginComponents/formComponents/fieldComponents/checkList.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/src/components/pluginComponents/formComponents/fieldComponents/htmlBlock.vue b/src/components/pluginComponents/formComponents/fieldComponents/htmlBlock.vue index 3bc790b4..04728097 100644 --- a/src/components/pluginComponents/formComponents/fieldComponents/htmlBlock.vue +++ b/src/components/pluginComponents/formComponents/fieldComponents/htmlBlock.vue @@ -7,6 +7,7 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/src/components/pluginComponents/formComponents/fieldComponents/radioList.vue b/src/components/pluginComponents/formComponents/fieldComponents/radioList.vue new file mode 100644 index 00000000..67b8dcb6 --- /dev/null +++ b/src/components/pluginComponents/formComponents/fieldComponents/radioList.vue @@ -0,0 +1,29 @@ + + + + + \ No newline at end of file diff --git a/src/components/pluginComponents/formComponents/fieldComponents/selectList.vue b/src/components/pluginComponents/formComponents/fieldComponents/selectList.vue index bc139bc4..6009767c 100644 --- a/src/components/pluginComponents/formComponents/fieldComponents/selectList.vue +++ b/src/components/pluginComponents/formComponents/fieldComponents/selectList.vue @@ -1,14 +1,17 @@ @@ -16,6 +19,7 @@