From 8c0c6a167c7a8157b85d8ba8dc5ab11219151554 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Fri, 30 Jan 2026 21:05:50 +0000 Subject: [PATCH] Next round of refactoring done --- public/locales/en/common.json | 1 + .../components/CustomFieldsTable.tsx | 81 ++++++++++++------- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 168acae..d3eef23 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -26,6 +26,7 @@ "ExceptionJson": "Exception JSON", "ExceptionLogs": "Exception Logs", "FailedToDisableAuthenticator": "Failed to disable authenticator:", + "FieldType": "Field Type", "Forms": "Forms", "FormTemplateManager": "Form Template Manager", "Glossaries": "Glossaries", diff --git a/src/modules/manager/customfields/components/CustomFieldsTable.tsx b/src/modules/manager/customfields/components/CustomFieldsTable.tsx index 34848cb..b0c9da0 100644 --- a/src/modules/manager/customfields/components/CustomFieldsTable.tsx +++ b/src/modules/manager/customfields/components/CustomFieldsTable.tsx @@ -1,36 +1,63 @@ import React from "react"; +import { useTranslation } from "react-i18next"; import Column from "../../../../components/common/columns"; -import Table, { PublishedTableProps } from "../../../../components/common/Table"; +import Table, { + PublishedTableProps, +} from "../../../../components/common/Table"; import authentication from "../../../frame/services/authenticationService"; import { CustomField } from "../services/customFieldsService"; -class CustomFieldsTable extends React.Component> { - columns : Column[] = [ - { key: "name", label: "Name", order: "asc" }, - { key: "fieldType", label: "Field Type", order: "asc", searchable: false } - ]; +const CustomFieldsTable: React.FC> = ( + props, +) => { + const { t } = useTranslation(); - raiseSort = (sortColumn : Column) => { - this.setState({sortColumn}); - if (this.props.onSort !== undefined) - this.props.onSort(sortColumn); - } + const columns: Column[] = [ + { key: "name", label: t("Name"), order: "asc" }, + { + key: "fieldType", + label: t("FieldType"), + order: "asc", + searchable: false, + }, + ]; - handleAuditParams = (item: any) => { - return { - entityName : "e_suite.Database.Core.Tables.CustomFields.CustomField", - primaryKey : "{\"Id\":"+item.id+"}" - } - } + const raiseSort = (sortColumn: Column) => { + if (props.onSort !== undefined) props.onSort(sortColumn); + }; - render() { - const { data, sortColumn, onChangePage, onSearch, onDelete } = this.props; - const editPath = authentication.hasAccess("EditField") ? "edit/{0}" : undefined; - const doDelete = authentication.hasAccess("DeleteField") ? onDelete : undefined; - const showAudit = authentication.hasAccess("ViewAuditLog") ? this.handleAuditParams : undefined; + const handleAuditParams = (item: any) => { + return { + entityName: "e_suite.Database.Core.Tables.CustomFields.CustomField", + primaryKey: '{"Id":' + item.id + "}", + }; + }; - return ; - } -} - -export default CustomFieldsTable; \ No newline at end of file + const { data, sortColumn, onChangePage, onSearch, onDelete } = props; + const editPath = authentication.hasAccess("EditField") + ? "edit/{0}" + : undefined; + const doDelete = authentication.hasAccess("DeleteField") + ? onDelete + : undefined; + const showAudit = authentication.hasAccess("ViewAuditLog") + ? handleAuditParams + : undefined; + + return ( +
+ ); +}; + +export default CustomFieldsTable;