From e5b882e51303f5377cd509cd95cb54f11e31eeff Mon Sep 17 00:00:00 2001 From: Achin Goyal Date: Fri, 21 Jan 2022 13:54:21 +0530 Subject: [PATCH 1/3] Primary key addition and title description changes --- package.json | 6 ++ src/components/Schema.tsx | 2 +- src/components/SchemaField.tsx | 164 +++++++++++++++------------------ src/helpers.ts | 45 ++++++++- src/styles/schema.css | 7 +- 5 files changed, 128 insertions(+), 96 deletions(-) diff --git a/package.json b/package.json index 4e15bf3..f2bfc57 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,16 @@ "update": "ncu -u" }, "dependencies": { + "@fortawesome/fontawesome-free": "5.15.4", + "@fortawesome/fontawesome-svg-core": "1.2.36", + "@fortawesome/free-regular-svg-icons": "5.15.4", + "@fortawesome/free-solid-svg-icons": "5.15.4", + "@fortawesome/react-fontawesome": "0.1.16", "@types/lodash": "^4.14.168", "@types/marked": "^2.0.1", "@types/uuid": "^8.3.0", "classnames": "^2.3.1", + "font-awesome-icons": "1.6.0", "jsonschema": "^1.4.0", "jszip": "^3.6.0", "lodash": "^4.17.21", diff --git a/src/components/Schema.tsx b/src/components/Schema.tsx index 9f0f09b..43f1c78 100644 --- a/src/components/Schema.tsx +++ b/src/components/Schema.tsx @@ -81,7 +81,7 @@ export function Schema(props: ISchemaProps) { const column = find(columns, (column) => column.id === id) if (column) { column.field[name] = value - setColumns([...columns]) + setColumns([...columns]) } } diff --git a/src/components/SchemaField.tsx b/src/components/SchemaField.tsx index 4213a5a..49ac855 100644 --- a/src/components/SchemaField.tsx +++ b/src/components/SchemaField.tsx @@ -1,7 +1,8 @@ -import React, { useState } from 'react' +import React from 'react' import { IDict } from '../common' import * as helpers from '../helpers' - +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faTimesCircle } from '@fortawesome/free-solid-svg-icons'; export interface ISchemaFieldProps { column: IDict metadata: IDict @@ -12,13 +13,13 @@ export interface ISchemaFieldProps { export function SchemaField(props: ISchemaFieldProps) { const types = helpers.getFieldTypes() const formats = helpers.getFieldFormats(props.column.field.type) - const [isDetails, setIsDetails] = useState(false) + return (
{/* General */}
{/* Name */} -
+
@@ -33,8 +34,38 @@ export function SchemaField(props: ISchemaFieldProps) {
+ {/* Title */} +
+
+
+
Title
+
+ props.updateField(props.column.id, 'title', ev.target.value)} + /> +
+
+ + {/* Description */} +
+
+
+
Description
+
+ props.updateField(props.column.id, 'description', ev.target.value)} + /> +
+
+ {/* Type */} -
+
Type
@@ -55,7 +86,7 @@ export function SchemaField(props: ISchemaFieldProps) {
{/* Format */} -
+
Format
@@ -70,18 +101,22 @@ export function SchemaField(props: ISchemaFieldProps) {
- {/* Controls */} -
- {/* Details */} - + {/* PrimaryKey */} +
+
+
+
Primary Key
+
+ { + props.updateField(props.column.id, 'primaryKey', ev.currentTarget.checked) + }} + /> +
+
+
{/* Remove */} + { + ev.preventDefault() + props.removeField(props.column.id) + }} + icon={faTimesCircle} + className="fa-icon" + /> + {/* */} +
- - {/* Details */} - {isDetails && ( -
-
-
-
- {/* Extra fields */} -
- {/* Title */} -
- - - props.updateField(props.column.id, 'title', ev.target.value) - } - /> -
- - {/* Description */} -
- -