From b1f58276d051be3507a10f1ebf38c6b52209b207 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Thu, 26 Jan 2023 20:21:41 +0200 Subject: [PATCH] more form changes --- package-lock.json | 60 +++++++ package.json | 4 + src/components/Accordion.vue | 52 ++++++ src/components/form/FormField.vue | 21 ++- src/components/form/FormInput.vue | 65 -------- src/components/{ => form/base}/ColorInput.vue | 0 src/components/form/base/Select.vue | 130 +++++++++++++++ src/components/form/fields/FormColorField.vue | 35 +++++ .../form/fields/FormSelectField.vue | 40 +++++ src/components/header/Dropdown.vue | 41 ----- src/components/header/Header.vue | 148 +++++++++++++----- .../house-planner/PropertyFormItem.vue | 2 +- src/components/item/NewStorageModal.vue | 21 ++- src/enums/item-type.enum.ts | 31 ++++ src/enums/storage-set-type.enum.ts | 12 ++ src/enums/storage-type.enum.ts | 15 ++ src/enums/transaction-type.enum.ts | 21 +++ 17 files changed, 547 insertions(+), 151 deletions(-) create mode 100644 src/components/Accordion.vue delete mode 100644 src/components/form/FormInput.vue rename src/components/{ => form/base}/ColorInput.vue (100%) create mode 100644 src/components/form/base/Select.vue create mode 100644 src/components/form/fields/FormColorField.vue create mode 100644 src/components/form/fields/FormSelectField.vue delete mode 100644 src/components/header/Dropdown.vue diff --git a/package-lock.json b/package-lock.json index 84783eb..d7c55c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,10 @@ "@heroicons/vue": "^2.0.13", "@vueuse/core": "^9.10.0", "jwt-decode": "^3.1.2", + "lodash.get": "^4.4.2", "lodash.omit": "^4.5.0", "lodash.pick": "^4.4.0", + "lodash.set": "^4.3.2", "pinia": "^2.0.28", "sass": "^1.57.1", "vue": "^3.2.45", @@ -22,8 +24,10 @@ "devDependencies": { "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", + "@types/lodash.get": "^4.4.7", "@types/lodash.omit": "^4.5.7", "@types/lodash.pick": "^4.4.7", + "@types/lodash.set": "^4.3.7", "@vitejs/plugin-vue": "^4.0.0", "autoprefixer": "^10.4.13", "postcss": "^8.4.21", @@ -479,6 +483,15 @@ "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", "dev": true }, + "node_modules/@types/lodash.get": { + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/lodash.get/-/lodash.get-4.4.7.tgz", + "integrity": "sha512-af34Mj+KdDeuzsJBxc/XeTtOx0SZHZNLd+hdrn+PcKGQs0EG2TJTzQAOTCZTgDJCArahlCzLWSy8c2w59JRz7Q==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/lodash.omit": { "version": "4.5.7", "resolved": "https://registry.npmjs.org/@types/lodash.omit/-/lodash.omit-4.5.7.tgz", @@ -497,6 +510,15 @@ "@types/lodash": "*" } }, + "node_modules/@types/lodash.set": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/@types/lodash.set/-/lodash.set-4.3.7.tgz", + "integrity": "sha512-bS5Wkg/nrT82YUfkNYPSccFrNZRL+irl7Yt4iM6OTSQ0VZJED2oUIVm15NkNtUAQ8SRhCe+axqERUV6MJgkeEg==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/web-bluetooth": { "version": "0.0.16", "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.16.tgz", @@ -1248,6 +1270,11 @@ "node": ">=10" } }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==" + }, "node_modules/lodash.omit": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz", @@ -1258,6 +1285,11 @@ "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", "integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==" }, + "node_modules/lodash.set": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", + "integrity": "sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==" + }, "node_modules/magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", @@ -2218,6 +2250,15 @@ "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", "dev": true }, + "@types/lodash.get": { + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/lodash.get/-/lodash.get-4.4.7.tgz", + "integrity": "sha512-af34Mj+KdDeuzsJBxc/XeTtOx0SZHZNLd+hdrn+PcKGQs0EG2TJTzQAOTCZTgDJCArahlCzLWSy8c2w59JRz7Q==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/lodash.omit": { "version": "4.5.7", "resolved": "https://registry.npmjs.org/@types/lodash.omit/-/lodash.omit-4.5.7.tgz", @@ -2236,6 +2277,15 @@ "@types/lodash": "*" } }, + "@types/lodash.set": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/@types/lodash.set/-/lodash.set-4.3.7.tgz", + "integrity": "sha512-bS5Wkg/nrT82YUfkNYPSccFrNZRL+irl7Yt4iM6OTSQ0VZJED2oUIVm15NkNtUAQ8SRhCe+axqERUV6MJgkeEg==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/web-bluetooth": { "version": "0.0.16", "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.16.tgz", @@ -2786,6 +2836,11 @@ "integrity": "sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==" + }, "lodash.omit": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz", @@ -2796,6 +2851,11 @@ "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", "integrity": "sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==" }, + "lodash.set": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", + "integrity": "sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==" + }, "magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", diff --git a/package.json b/package.json index 907e5c9..4253085 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,10 @@ "@heroicons/vue": "^2.0.13", "@vueuse/core": "^9.10.0", "jwt-decode": "^3.1.2", + "lodash.get": "^4.4.2", "lodash.omit": "^4.5.0", "lodash.pick": "^4.4.0", + "lodash.set": "^4.3.2", "pinia": "^2.0.28", "sass": "^1.57.1", "vue": "^3.2.45", @@ -23,8 +25,10 @@ "devDependencies": { "@tailwindcss/forms": "^0.5.3", "@tailwindcss/line-clamp": "^0.4.2", + "@types/lodash.get": "^4.4.7", "@types/lodash.omit": "^4.5.7", "@types/lodash.pick": "^4.4.7", + "@types/lodash.set": "^4.3.7", "@vitejs/plugin-vue": "^4.0.0", "autoprefixer": "^10.4.13", "postcss": "^8.4.21", diff --git a/src/components/Accordion.vue b/src/components/Accordion.vue new file mode 100644 index 0000000..f715052 --- /dev/null +++ b/src/components/Accordion.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/components/form/FormField.vue b/src/components/form/FormField.vue index c0755a1..22732b2 100644 --- a/src/components/form/FormField.vue +++ b/src/components/form/FormField.vue @@ -23,19 +23,18 @@ :onBlur="onBlur" :setValue="setValue" > - @@ -54,7 +53,6 @@ import get from 'lodash.get'; import { computed, ref, Ref } from 'vue'; import { inject } from 'vue'; import { FormData, FormErrors } from './form.types'; -import FormInput from './FormInput.vue'; const props = withDefaults( defineProps<{ @@ -68,10 +66,12 @@ const props = withDefaults( | 'radio'; label: string; name: string; + disabled?: boolean; placeholder?: string; }>(), { type: 'text', + disabled: false, } ); @@ -90,7 +90,7 @@ const fieldName = computed(() => formGroup?.value ? `${formGroup.value}.${props.name}` : props.name ); -const forId = computed(() => `form-${fieldName}`); +const forId = computed(() => `form-${fieldName.value}`); const value = computed(() => get(formData?.value, fieldName.value)); const errors = computed(() => formErrors?.value[fieldName.value] || []); @@ -122,4 +122,13 @@ const onBlur = () => { emit('blur'); fieldChange?.(fieldName.value); }; + +const inputClass = computed(() => { + return [ + errors.value.length + ? 'border-red-300 focus:border-red-500 focus:ring-red-500' + : 'border-gray-300 focus:border-blue-500 focus:ring-blue-500', + `mt-1 block w-full rounded-md shadow-sm sm:text-sm transition-colors duration-200`, + ]; +}); diff --git a/src/components/form/FormInput.vue b/src/components/form/FormInput.vue deleted file mode 100644 index 28131ea..0000000 --- a/src/components/form/FormInput.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - diff --git a/src/components/ColorInput.vue b/src/components/form/base/ColorInput.vue similarity index 100% rename from src/components/ColorInput.vue rename to src/components/form/base/ColorInput.vue diff --git a/src/components/form/base/Select.vue b/src/components/form/base/Select.vue new file mode 100644 index 0000000..b2a6cb3 --- /dev/null +++ b/src/components/form/base/Select.vue @@ -0,0 +1,130 @@ + + + diff --git a/src/components/form/fields/FormColorField.vue b/src/components/form/fields/FormColorField.vue new file mode 100644 index 0000000..42005bf --- /dev/null +++ b/src/components/form/fields/FormColorField.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/components/form/fields/FormSelectField.vue b/src/components/form/fields/FormSelectField.vue new file mode 100644 index 0000000..40fb5ee --- /dev/null +++ b/src/components/form/fields/FormSelectField.vue @@ -0,0 +1,40 @@ + + + diff --git a/src/components/header/Dropdown.vue b/src/components/header/Dropdown.vue deleted file mode 100644 index 296f1e4..0000000 --- a/src/components/header/Dropdown.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/src/components/header/Header.vue b/src/components/header/Header.vue index d7626d3..f7a527a 100644 --- a/src/components/header/Header.vue +++ b/src/components/header/Header.vue @@ -1,65 +1,143 @@