From 44426b6bf821582e0b801436beb81b2dc45c79c1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 10 Sep 2020 13:04:45 +0100 Subject: [PATCH 1/3] data form component date picker aware, form component refactor --- package.json | 2 +- packages/standard-components/package.json | 1 + .../standard-components/src/DataForm.svelte | 155 +++++++----------- .../src/DataFormWide.svelte | 155 +++++++----------- 4 files changed, 116 insertions(+), 197 deletions(-) diff --git a/package.json b/package.json index 69f7b0f21d..79935c5dce 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "publishdev": "lerna run publishdev", "publishnpm": "yarn build && lerna publish --force-publish", "clean": "lerna clean", - "dev": "node ./scripts/symlinkDev.js && lerna run --parallel --stream dev:builder", + "dev": "node ./scripts/symlinkDev.js && lerna run --parallel dev:builder", "test": "lerna run test", "lint": "eslint packages", "lint:fix": "eslint --fix packages", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 1325a3ad32..7cf1a9a47c 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -41,6 +41,7 @@ "d3-selection": "^1.4.2", "fast-sort": "^2.2.0", "fusioncharts": "^3.15.1-sr.1", + "lodash.debounce": "^4.0.8", "svelte-flatpickr": "^2.4.0", "svelte-fusioncharts": "^1.0.0" } diff --git a/packages/standard-components/src/DataForm.svelte b/packages/standard-components/src/DataForm.svelte index 21d4623822..4709097fad 100644 --- a/packages/standard-components/src/DataForm.svelte +++ b/packages/standard-components/src/DataForm.svelte @@ -1,7 +1,8 @@ @@ -164,23 +113,28 @@ {#if title}

{title}

{/if} + {#each errorMessages as error} +

{error}

+ {/each}
{#each fields as field}
{#if schema[field].type === 'string' && schema[field].constraints.inclusion} - {#each schema[field].constraints.inclusion as opt} {/each} - {:else} - + {:else if schema[field].type === 'datetime'} + + {:else if schema[field].type === 'boolean'} + + {:else if schema[field].type === 'number'} + + {:else if schema[field].type === 'string'} + {/if}

@@ -302,4 +256,9 @@ background-position: right 17px top 1.5em, right 10px top 1.5em; background-size: 7px 7px, 7px 7px; } + + .error { + color: red; + font-weight: 500; + } diff --git a/packages/standard-components/src/DataFormWide.svelte b/packages/standard-components/src/DataFormWide.svelte index 56011df569..99c5867d67 100644 --- a/packages/standard-components/src/DataFormWide.svelte +++ b/packages/standard-components/src/DataFormWide.svelte @@ -1,7 +1,8 @@ @@ -164,23 +113,28 @@ {#if title}

{title}

{/if} + {#each errorMessages as error} +

{error}

+ {/each}
{#each fields as field}
{#if schema[field].type === 'string' && schema[field].constraints.inclusion} - {#each schema[field].constraints.inclusion as opt} {/each} - {:else} - + {:else if schema[field].type === 'datetime'} + + {:else if schema[field].type === 'boolean'} + + {:else if schema[field].type === 'number'} + + {:else if schema[field].type === 'string'} + {/if}

@@ -293,4 +247,9 @@ background-position: right 17px top 1.5em, right 10px top 1.5em; background-size: 7px 7px, 7px 7px; } + + .error { + color: red; + font-weight: 500; + } From 2abd6ed7b288bca15dda4507070c73cb6d2df313 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 10 Sep 2020 13:09:44 +0100 Subject: [PATCH 2/3] tidy up --- packages/standard-components/src/DataForm.svelte | 3 --- packages/standard-components/src/DataFormWide.svelte | 2 -- 2 files changed, 5 deletions(-) diff --git a/packages/standard-components/src/DataForm.svelte b/packages/standard-components/src/DataForm.svelte index 4709097fad..75dffb3301 100644 --- a/packages/standard-components/src/DataForm.svelte +++ b/packages/standard-components/src/DataForm.svelte @@ -41,14 +41,11 @@ ([field, message]) => `${field} ${message}` ) - $: console.log(record) - async function fetchModel() { const FETCH_MODEL_URL = `/api/models/${model}` const response = await _bb.api.get(FETCH_MODEL_URL) modelDef = await response.json() schema = modelDef.schema - // record = createBlankRecord() record = { modelId: model, } diff --git a/packages/standard-components/src/DataFormWide.svelte b/packages/standard-components/src/DataFormWide.svelte index 99c5867d67..fa14380634 100644 --- a/packages/standard-components/src/DataFormWide.svelte +++ b/packages/standard-components/src/DataFormWide.svelte @@ -41,14 +41,12 @@ ([field, message]) => `${field} ${message}` ) - $: console.log(record) async function fetchModel() { const FETCH_MODEL_URL = `/api/models/${model}` const response = await _bb.api.get(FETCH_MODEL_URL) modelDef = await response.json() schema = modelDef.schema - // record = createBlankRecord() record = { modelId: model, } From c4eda0f1e7ba43d245a38228b59c3f8f09dd90bf Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 10 Sep 2020 13:10:57 +0100 Subject: [PATCH 3/3] bind checked --- packages/standard-components/src/DataForm.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/standard-components/src/DataForm.svelte b/packages/standard-components/src/DataForm.svelte index 75dffb3301..ba5998e5c6 100644 --- a/packages/standard-components/src/DataForm.svelte +++ b/packages/standard-components/src/DataForm.svelte @@ -127,7 +127,7 @@ {:else if schema[field].type === 'datetime'} {:else if schema[field].type === 'boolean'} - + {:else if schema[field].type === 'number'} {:else if schema[field].type === 'string'}