fix: attribute editors fixes
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { useMemo } from "react";
|
||||
import { MRT_ColumnDef } from "mantine-react-table";
|
||||
import { AttributeSchema } from "../../../../../../../client";
|
||||
import { Box, Center, Checkbox, rem, Text, Tooltip } from "@mantine/core";
|
||||
import { IconInfoCircle } from "@tabler/icons-react";
|
||||
import defaultValueToStr from "../../../utils/defaultValueToStr.ts";
|
||||
import { Box, Center, Checkbox } from "@mantine/core";
|
||||
import { IconCheck, IconX } from "@tabler/icons-react";
|
||||
import { formatDate, formatDateTime } from "../../../../../../../types/utils.ts";
|
||||
|
||||
|
||||
type Props = {
|
||||
@@ -13,36 +13,6 @@ type Props = {
|
||||
const useAttributesTableColumns = ({ selectedAttributes }: Props) => {
|
||||
return useMemo<MRT_ColumnDef<AttributeSchema>[]>(
|
||||
() => [
|
||||
{
|
||||
header: "Название",
|
||||
accessorKey: "label",
|
||||
size: 25,
|
||||
},
|
||||
{
|
||||
header: "Тип",
|
||||
accessorKey: "type.name",
|
||||
size: 25,
|
||||
},
|
||||
{
|
||||
header: " ",
|
||||
Cell: ({ row }) => {
|
||||
const description = row.original.description ? `Описание: ${row.original.description}` : "";
|
||||
const info = (
|
||||
<Box>
|
||||
<Text>Может быть пустым: {row.original.isNullable ? "да" : "нет"}</Text>
|
||||
<Text>{defaultValueToStr(row.original.defaultValue, row.original.type.type)}</Text>
|
||||
<Text>Синхронизировано в группе: {row.original.isApplicableToGroup ? "да" : "нет"}</Text>
|
||||
<Text>{description}</Text>
|
||||
</Box>
|
||||
);
|
||||
return (
|
||||
<Tooltip label={info} multiline w={rem(300)}>
|
||||
<IconInfoCircle />
|
||||
</Tooltip>
|
||||
);
|
||||
},
|
||||
size: 5,
|
||||
},
|
||||
{
|
||||
header: " ",
|
||||
Cell: ({ row }) => (
|
||||
@@ -61,6 +31,84 @@ const useAttributesTableColumns = ({ selectedAttributes }: Props) => {
|
||||
),
|
||||
size: 5,
|
||||
},
|
||||
{
|
||||
header: "Название",
|
||||
accessorKey: "label",
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
header: "Тип",
|
||||
accessorKey: "type.name",
|
||||
size: 120,
|
||||
},
|
||||
// {
|
||||
// header: " ",
|
||||
// Cell: ({ row }) => {
|
||||
// const description = row.original.description ? `Описание: ${row.original.description}` : "";
|
||||
// const info = (
|
||||
// <Box>
|
||||
// <Text>Может быть пустым: {row.original.isNullable ? "да" : "нет"}</Text>
|
||||
// <Text>{defaultValueToStr(row.original.defaultValue, row.original.type.type)}</Text>
|
||||
// <Text>Синхронизировано в группе: {row.original.isApplicableToGroup ? "да" : "нет"}</Text>
|
||||
// <Text>{description}</Text>
|
||||
// </Box>
|
||||
// );
|
||||
// return (
|
||||
// <Tooltip label={info} multiline w={rem(300)}>
|
||||
// <IconInfoCircle />
|
||||
// </Tooltip>
|
||||
// );
|
||||
// },
|
||||
// size: 5,
|
||||
// },
|
||||
{
|
||||
header: "Значение по умолчанию",
|
||||
accessorKey: "defaultValue",
|
||||
Cell: ({ cell, row }) => {
|
||||
const value = cell.getValue();
|
||||
if (value === null) return <>-</>;
|
||||
|
||||
const type = row.original.type.type;
|
||||
if (type === "datetime") {
|
||||
return formatDateTime(value as string);
|
||||
}
|
||||
if (type === "date") {
|
||||
return formatDate(value as string);
|
||||
}
|
||||
if (type === "bool") {
|
||||
return value ? <IconCheck /> : <IconX />;
|
||||
}
|
||||
|
||||
return <>{value}</>;
|
||||
},
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
header: "Синхронизировано в группе",
|
||||
accessorKey: "isApplicableToGroup",
|
||||
Cell: ({ cell }) => cell.getValue() ? (
|
||||
<IconCheck />
|
||||
) : (
|
||||
<IconX />
|
||||
),
|
||||
size: 120,
|
||||
},
|
||||
{
|
||||
header: "Может быть пустым",
|
||||
accessorKey: "isNullable",
|
||||
Cell: ({ cell }) => cell.getValue() ? (
|
||||
<IconCheck />
|
||||
) : (
|
||||
<IconX />
|
||||
),
|
||||
size: 120,
|
||||
},
|
||||
{
|
||||
header: "Описаниие",
|
||||
accessorKey: "description",
|
||||
Cell: ({ row }) => <Box>{row.original.description}</Box>,
|
||||
size: 250,
|
||||
},
|
||||
],
|
||||
[selectedAttributes],
|
||||
);
|
||||
|
||||
@@ -11,11 +11,6 @@ type Props = {
|
||||
const useModulesTableColumns = ({ selectedModules }: Props) => {
|
||||
return useMemo<MRT_ColumnDef<ModuleSchema>[]>(
|
||||
() => [
|
||||
{
|
||||
header: "Название",
|
||||
accessorKey: "label",
|
||||
size: 25,
|
||||
},
|
||||
{
|
||||
header: " ",
|
||||
Cell: ({ row }) => (
|
||||
@@ -32,7 +27,12 @@ const useModulesTableColumns = ({ selectedModules }: Props) => {
|
||||
/>
|
||||
</Center>
|
||||
),
|
||||
size: 5,
|
||||
size: 1,
|
||||
},
|
||||
{
|
||||
header: "Название",
|
||||
accessorKey: "label",
|
||||
size: 10000,
|
||||
},
|
||||
],
|
||||
[selectedModules],
|
||||
|
||||
Reference in New Issue
Block a user