From f7f726129215f28dc97884271fee330272bb1a92 Mon Sep 17 00:00:00 2001 From: Bryan Santos Date: Thu, 28 Apr 2022 11:38:12 -0700 Subject: [PATCH 1/3] added state updates when the user hits save while updating column --- .../components/views/ERTables/TableFieldNode.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/components/views/ERTables/TableFieldNode.tsx b/frontend/components/views/ERTables/TableFieldNode.tsx index 89d6bf06..5b787707 100644 --- a/frontend/components/views/ERTables/TableFieldNode.tsx +++ b/frontend/components/views/ERTables/TableFieldNode.tsx @@ -162,6 +162,8 @@ function TableField({ data }: TableFieldProps) { ) as HTMLSelectElement; if (column_name !== columnNameInput.value) { alterColumnsObj.new_column_name = columnNameInput.value; + schemaStateCopy.tableList[i].columns[j].column_name = + columnNameInput.value; schemaStateCopy.tableList[i].columns[j].new_column_name = columnNameInput.value; if (constraint_type === 'PRIMARY KEY') alterColumnsObj.rename_constraint = `pk_${alterTablesObj.table_name}${column_name}`; @@ -174,6 +176,7 @@ function TableField({ data }: TableFieldProps) { `allow-null-chkbox-${tableColumn}` ) as HTMLInputElement; const isNullableString: 'YES' | 'NO' = isNullable.checked ? 'YES' : 'NO'; + schemaStateCopy.tableList[i].columns[j].is_nullable = isNullableString; alterColumnsObj.is_nullable = isNull !== isNullableString ? isNullableString : null; @@ -230,6 +233,8 @@ function TableField({ data }: TableFieldProps) { constraint_type === 'PRIMARY KEY' && pkCheckBox.checked === false ) { + // modify state to remove constraint + schemaStateCopy.tableList[i].columns[j].constraint_type = null; // add the PK constraint name to the drop constraint array alterColumnsObj.drop_constraint.push( `PK_${data.tableName + column_name}` @@ -239,6 +244,8 @@ function TableField({ data }: TableFieldProps) { constraint_type !== 'PRIMARY KEY' && pkCheckBox.checked === true ) { + // modify state to remove constraint + schemaStateCopy.tableList[i].columns[j].constraint_type = 'PRIMARY KEY'; // create a copy in case multiple constraints are added const addConstraintObjCopy: AddConstraintObjType = { ...addConstraintObj }; // name the constraint PK_ @@ -259,6 +266,8 @@ function TableField({ data }: TableFieldProps) { constraint_type === 'FOREIGN KEY' && fkCheckBox.checked === false ) { + // modify state to remove constraint + schemaStateCopy.tableList[i].columns[j].constraint_type = null; // add the fk constraint name to the drop constraint array alterColumnsObj.drop_constraint.push( `FK_${data.tableName + column_name}` @@ -267,6 +276,8 @@ function TableField({ data }: TableFieldProps) { constraint_type !== 'FOREIGN KEY' && fkCheckBox.checked === true ) { + // modify state to add constraint + schemaStateCopy.tableList[i].columns[j].constraint_type = 'FOREIGN KEY'; const addConstraintObjCopy = { ...addConstraintObj }; // name the constraint FK_ addConstraintObjCopy.constraint_name = `fk_${data.tableName + column_name @@ -292,12 +303,16 @@ function TableField({ data }: TableFieldProps) { // handle unique constraint const uniqueCheckBox = document.getElementById(`unique-chkbox-${tableColumn}`) as HTMLInputElement; if (constraint_type === 'UNIQUE' && uniqueCheckBox.checked === false) { + // modify state to remove constraint + schemaStateCopy.tableList[i].columns[j].constraint_type = null; // add the unique constraint name to the drop constraint array alterColumnsObj.drop_constraint.push( `unique_${data.tableName + column_name}` ); } else if (constraint_type !== 'UNIQUE' && uniqueCheckBox.checked === true) { + // modify state to add constraint + schemaStateCopy.tableList[i].columns[j].constraint_type = 'UNIQUE'; // create a copy in case multiple constraints are added const addConstraintObjCopy: AddConstraintObjType = { ...addConstraintObj }; // name the constraint PK_ From 51767df3e502e5ce393f5636afd7edb9171a53be Mon Sep 17 00:00:00 2001 From: Bryan Santos Date: Thu, 28 Apr 2022 11:40:42 -0700 Subject: [PATCH 2/3] changed readme version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0412f62..b6307539 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/oslabs-beta/SeeQR) -![Release: 7.0.1](https://img.shields.io/badge/Release-7.0.0-red) +![Release: 7.0.1](https://img.shields.io/badge/Release-7.0.1-red) ![License: MIT](https://img.shields.io/badge/License-MIT-orange.svg) ![Contributions Welcome](https://img.shields.io/badge/Contributions-welcome-blue.svg) [![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Ftheseeqr)](https://twitter.com/theseeqr) From 01b21cad45c5b75a7446e19232dbd26484b82d3b Mon Sep 17 00:00:00 2001 From: Bryan Santos Date: Thu, 28 Apr 2022 11:41:41 -0700 Subject: [PATCH 3/3] changed version in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5069b5d8..16bda3ca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "seeqr", "productName": "SeeQR App", - "version": "7.0.0", + "version": "7.0.1", "description": "SQL Toolbox - Model Implementer, Execution Plan Visualizer and Query Comparison Tool", "main": "./tsCompiled/backend/main.js", "babel": {