From 4e0b13ad0288c47dc9f04d8bfe9734f6483787fe Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Mon, 23 Oct 2023 11:05:41 -0500 Subject: [PATCH 1/2] upped revision to 0.20.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e3768cc..3b5af65 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ jar - 0.19.0-SNAPSHOT + 0.20.0-SNAPSHOT UTF-8 UTF-8 From 45f247785ce8dcabd61f90627e3d0b08fdc9e129 Mon Sep 17 00:00:00 2001 From: Tim Chamberlain Date: Thu, 26 Oct 2023 12:23:30 -0500 Subject: [PATCH 2/2] fixed bug where datetimes were cleared when posting, resulting in empty form fields for next submit --- src/qqq/components/forms/EntityForm.tsx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/qqq/components/forms/EntityForm.tsx b/src/qqq/components/forms/EntityForm.tsx index 179655e..cf98258 100644 --- a/src/qqq/components/forms/EntityForm.tsx +++ b/src/qqq/components/forms/EntityForm.tsx @@ -426,6 +426,11 @@ function EntityForm(props: Props): JSX.Element actions.setSubmitting(true); await (async () => { + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // we will be manipulating the values sent to the backend, so clone values so they remained unchanged for the form widgets // + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + const valuesToPost = JSON.parse(JSON.stringify(values)); + for(let fieldName of tableMetaData.fields.keys()) { const fieldMetaData = tableMetaData.fields.get(fieldName); @@ -438,17 +443,17 @@ function EntityForm(props: Props): JSX.Element // changing from, say, 12:15:30 to just 12:15:00... this seems to get around that, for cases when the // // user didn't change the value in the field (but if the user did change the value, then we will submit it) // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - if(fieldMetaData.type === QFieldType.DATE_TIME && values[fieldName]) + if(fieldMetaData.type === QFieldType.DATE_TIME && valuesToPost[fieldName]) { - console.log(`DateTime ${fieldName}: Initial value: [${initialValues[fieldName]}] -> [${values[fieldName]}]`) - if (initialValues[fieldName] == values[fieldName]) + console.log(`DateTime ${fieldName}: Initial value: [${initialValues[fieldName]}] -> [${valuesToPost[fieldName]}]`) + if (initialValues[fieldName] == valuesToPost[fieldName]) { console.log(" - Is the same, so, deleting from the post"); - delete (values[fieldName]); + delete (valuesToPost[fieldName]); } else { - values[fieldName] = ValueUtils.frontendLocalZoneDateTimeStringToUTCStringForBackend(values[fieldName]); + valuesToPost[fieldName] = ValueUtils.frontendLocalZoneDateTimeStringToUTCStringForBackend(valuesToPost[fieldName]); } } @@ -461,10 +466,10 @@ function EntityForm(props: Props): JSX.Element //////////////////////////////////////////////////////////////////////////////////////////////////////////////// if(fieldMetaData.type === QFieldType.BLOB) { - if(typeof values[fieldName] === "string") + if(typeof valuesToPost[fieldName] === "string") { console.log(`${fieldName} value was a string, so, we're deleting it from the values array, to not submit it to the backend, to not change it.`); - delete(values[fieldName]); + delete(valuesToPost[fieldName]); } } } @@ -473,7 +478,7 @@ function EntityForm(props: Props): JSX.Element { // todo - audit that it's a dupe await qController - .update(tableName, props.id, values) + .update(tableName, props.id, valuesToPost) .then((record) => { if (props.isModal) @@ -506,7 +511,7 @@ function EntityForm(props: Props): JSX.Element else { await qController - .create(tableName, values) + .create(tableName, valuesToPost) .then((record) => { if (props.isModal)