Next round of refactoring done
This commit is contained in:
parent
f3deae0842
commit
8c0c6a167c
@ -26,6 +26,7 @@
|
|||||||
"ExceptionJson": "Exception JSON",
|
"ExceptionJson": "Exception JSON",
|
||||||
"ExceptionLogs": "Exception Logs",
|
"ExceptionLogs": "Exception Logs",
|
||||||
"FailedToDisableAuthenticator": "Failed to disable authenticator:",
|
"FailedToDisableAuthenticator": "Failed to disable authenticator:",
|
||||||
|
"FieldType": "Field Type",
|
||||||
"Forms": "Forms",
|
"Forms": "Forms",
|
||||||
"FormTemplateManager": "Form Template Manager",
|
"FormTemplateManager": "Form Template Manager",
|
||||||
"Glossaries": "Glossaries",
|
"Glossaries": "Glossaries",
|
||||||
|
|||||||
@ -1,36 +1,63 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import Column from "../../../../components/common/columns";
|
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 authentication from "../../../frame/services/authenticationService";
|
||||||
import { CustomField } from "../services/customFieldsService";
|
import { CustomField } from "../services/customFieldsService";
|
||||||
|
|
||||||
class CustomFieldsTable extends React.Component<PublishedTableProps<CustomField>> {
|
const CustomFieldsTable: React.FC<PublishedTableProps<CustomField>> = (
|
||||||
columns : Column<CustomField>[] = [
|
props,
|
||||||
{ key: "name", label: "Name", order: "asc" },
|
) => {
|
||||||
{ key: "fieldType", label: "Field Type", order: "asc", searchable: false }
|
const { t } = useTranslation();
|
||||||
];
|
|
||||||
|
|
||||||
raiseSort = (sortColumn : Column<CustomField>) => {
|
const columns: Column<CustomField>[] = [
|
||||||
this.setState({sortColumn});
|
{ key: "name", label: t("Name"), order: "asc" },
|
||||||
if (this.props.onSort !== undefined)
|
{
|
||||||
this.props.onSort(sortColumn);
|
key: "fieldType",
|
||||||
}
|
label: t("FieldType"),
|
||||||
|
order: "asc",
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
handleAuditParams = (item: any) => {
|
const raiseSort = (sortColumn: Column<CustomField>) => {
|
||||||
return {
|
if (props.onSort !== undefined) props.onSort(sortColumn);
|
||||||
entityName : "e_suite.Database.Core.Tables.CustomFields.CustomField",
|
};
|
||||||
primaryKey : "{\"Id\":"+item.id+"}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
const handleAuditParams = (item: any) => {
|
||||||
const { data, sortColumn, onChangePage, onSearch, onDelete } = this.props;
|
return {
|
||||||
const editPath = authentication.hasAccess("EditField") ? "edit/{0}" : undefined;
|
entityName: "e_suite.Database.Core.Tables.CustomFields.CustomField",
|
||||||
const doDelete = authentication.hasAccess("DeleteField") ? onDelete : undefined;
|
primaryKey: '{"Id":' + item.id + "}",
|
||||||
const showAudit = authentication.hasAccess("ViewAuditLog") ? this.handleAuditParams : undefined;
|
};
|
||||||
|
};
|
||||||
|
|
||||||
return <Table data={data} keyName="id" columns={this.columns} sortColumn={sortColumn} editPath={editPath} onSort={this.raiseSort} onChangePage={onChangePage} onSearch={onSearch} onDelete={doDelete} onAuditParams={showAudit}/>;
|
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 (
|
||||||
|
<Table
|
||||||
|
data={data}
|
||||||
|
keyName="id"
|
||||||
|
columns={columns}
|
||||||
|
sortColumn={sortColumn}
|
||||||
|
editPath={editPath}
|
||||||
|
onSort={raiseSort}
|
||||||
|
onChangePage={onChangePage}
|
||||||
|
onSearch={onSearch}
|
||||||
|
onDelete={doDelete}
|
||||||
|
onAuditParams={showAudit}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default CustomFieldsTable;
|
export default CustomFieldsTable;
|
||||||
Loading…
Reference in New Issue
Block a user