diff --git a/src/client/models/AttributeSchema.ts b/src/client/models/AttributeSchema.ts index ed23235..c4312f9 100644 --- a/src/client/models/AttributeSchema.ts +++ b/src/client/models/AttributeSchema.ts @@ -8,6 +8,7 @@ export type AttributeSchema = { name: string; isApplicableToGroup: boolean; isShownOnDashboard: boolean; + isHighlightIfExpired: boolean; isNullable: boolean; defaultValue: (boolean | number | string | null); typeId: number; diff --git a/src/client/models/BaseAttributeSchema.ts b/src/client/models/BaseAttributeSchema.ts index fd2051c..6bd9b78 100644 --- a/src/client/models/BaseAttributeSchema.ts +++ b/src/client/models/BaseAttributeSchema.ts @@ -7,6 +7,7 @@ export type BaseAttributeSchema = { name: string; isApplicableToGroup: boolean; isShownOnDashboard: boolean; + isHighlightIfExpired: boolean; isNullable: boolean; defaultValue: (boolean | number | string | null); typeId: number; diff --git a/src/components/Dnd/Cards/CardAttributesInSummaryItem/CardAttributesInSummaryItem.tsx b/src/components/Dnd/Cards/CardAttributesInSummaryItem/CardAttributesInSummaryItem.tsx index 66a0235..699cc48 100644 --- a/src/components/Dnd/Cards/CardAttributesInSummaryItem/CardAttributesInSummaryItem.tsx +++ b/src/components/Dnd/Cards/CardAttributesInSummaryItem/CardAttributesInSummaryItem.tsx @@ -32,9 +32,17 @@ const CardAttributesInSummaryItem = ({ cardSummary }: Props) => { const isHighlightNeeded = (cardAttr: CardAttributeSchema): boolean => { const type = cardAttr.attribute.type.type; - if (type !== "datetime") return false; + if (!cardAttr.attribute.isHighlightIfExpired) return false; + if (type !== "datetime" && type !== "date") return false; + const datetime = new Date(cardAttr.value as string); - return datetime < new Date(); + const curr = new Date(); + if (type === "datetime") { + return datetime < curr; + } + + curr.setHours(0, 0, 0, 0); + return datetime < curr; }; return ( diff --git a/src/pages/AdminPage/tabs/Attributes/Attributes.tsx b/src/pages/AdminPage/tabs/Attributes/Attributes.tsx index acbea49..adbca41 100644 --- a/src/pages/AdminPage/tabs/Attributes/Attributes.tsx +++ b/src/pages/AdminPage/tabs/Attributes/Attributes.tsx @@ -84,6 +84,12 @@ const Attributes = () => { enableRowVirtualization: true, mantineTableContainerProps: { style: { maxHeight: "86vh" } }, + displayColumnDefOptions: { + "mrt-row-actions": { + size: 100, + }, + }, + renderRowActions: ({ row }) => ( diff --git a/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx b/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx index e42d727..da10d95 100644 --- a/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx +++ b/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx @@ -1,5 +1,5 @@ import { useMemo } from "react"; -import { MRT_ColumnDef } from "mantine-react-table"; +import { MRT_Cell, MRT_ColumnDef } from "mantine-react-table"; import { AttributeSchema } from "../../../../../client"; import { IconCheck, IconX } from "@tabler/icons-react"; import { formatDate, formatDateTime } from "../../../../../types/utils.ts"; @@ -7,6 +7,12 @@ import { Box } from "@mantine/core"; const useAttributesTableColumns = () => { + const Cell = ({ cell }: { cell: MRT_Cell }) => cell.getValue() ? ( + + ) : ( + + ); + return useMemo[]>( () => [ { @@ -41,29 +47,22 @@ const useAttributesTableColumns = () => { { header: "Синхронизировано в группе", accessorKey: "isApplicableToGroup", - Cell: ({ cell }) => cell.getValue() ? ( - - ) : ( - - ), + Cell, }, { header: "Вывод на дашборде", accessorKey: "isShownOnDashboard", - Cell: ({ cell }) => cell.getValue() ? ( - - ) : ( - - ), + Cell, + }, + { + header: "Подсветка, если просрочен", + accessorKey: "isHighlightIfExpired", + Cell, }, { header: "Может быть пустым", accessorKey: "isNullable", - Cell: ({ cell }) => cell.getValue() ? ( - - ) : ( - - ), + Cell, }, { header: "Описаниие", diff --git a/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx b/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx index 1cd82aa..cfd3b5b 100644 --- a/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx +++ b/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx @@ -34,6 +34,7 @@ const AttributeModal = ({ type: undefined, isApplicableToGroup: false, isShownOnDashboard: false, + isHighlightIfExpired: false, isNullable: false, defaultValue: null, description: "", @@ -148,6 +149,12 @@ const AttributeModal = ({ label={"Значение выводится на дашборде"} {...form.getInputProps("isShownOnDashboard", { type: "checkbox" })} /> + {(form.values.type?.type === "datetime" || form.values.type?.type === "date") && ( + + )} {isNullableInputShown && (