diff --git a/src/client/models/AttributeSchema.ts b/src/client/models/AttributeSchema.ts index d1d1d25..ed23235 100644 --- a/src/client/models/AttributeSchema.ts +++ b/src/client/models/AttributeSchema.ts @@ -7,6 +7,7 @@ export type AttributeSchema = { label: string; name: string; isApplicableToGroup: boolean; + isShownOnDashboard: 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 62b68a7..fd2051c 100644 --- a/src/client/models/BaseAttributeSchema.ts +++ b/src/client/models/BaseAttributeSchema.ts @@ -6,6 +6,7 @@ export type BaseAttributeSchema = { label: string; name: string; isApplicableToGroup: boolean; + isShownOnDashboard: boolean; isNullable: boolean; defaultValue: (boolean | number | string | null); typeId: number; diff --git a/src/client/models/CardSummary.ts b/src/client/models/CardSummary.ts index 1615c16..6b06a49 100644 --- a/src/client/models/CardSummary.ts +++ b/src/client/models/CardSummary.ts @@ -4,6 +4,7 @@ /* eslint-disable */ import type { BaseMarketplaceSchema } from './BaseMarketplaceSchema'; import type { BoardSchema } from './BoardSchema'; +import type { CardAttributeSchema } from './CardAttributeSchema'; import type { CardBillRequestSchema } from './CardBillRequestSchema'; import type { CardGroupSchema } from './CardGroupSchema'; import type { CardTagSchema } from './CardTagSchema'; @@ -20,6 +21,7 @@ export type CardSummary = { baseMarketplace?: (BaseMarketplaceSchema | null); totalProducts: number; tags: Array; + attributes: Array; shipmentWarehouseId: (number | null); shipmentWarehouseName: (string | null); billRequest?: (CardBillRequestSchema | null); diff --git a/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx b/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx index 115e2c4..10e5632 100644 --- a/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx +++ b/src/components/Dnd/Cards/CardSummaryItem/CardSummaryItem.tsx @@ -1,5 +1,5 @@ import { FC } from "react"; -import { CardService, CardSummary } from "../../../../client"; +import { CardAttributeSchema, CardService, CardSummary } from "../../../../client"; import styles from "./CardSummaryItem.module.css"; import { ActionIcon, Badge, CopyButton, Flex, Image, Popover, rem, Text, ThemeIcon, Tooltip } from "@mantine/core"; @@ -12,6 +12,7 @@ import useCardSummaryState from "./useCardSummaryState.tsx"; import isModuleInProject, { Modules } from "../../../../modules/utils/isModuleInProject.ts"; import { useProjectsContext } from "../../../../contexts/ProjectsContext.tsx"; import CardTags from "../CardTags/CardTags.tsx"; +import { formatDate, formatDateTime } from "../../../../types/utils.ts"; type Props = { cardSummary: CardSummary; @@ -38,6 +39,40 @@ const CardSummaryItem: FC = ({ cardSummary, color }) => { const isLockedInsideGroup = () => { return cardSummary.group && !cardSummary.group.billRequest; }; + + const attributeValues = () => { + return ( + + {cardSummary.attributes + .filter(cardAttr => cardAttr.attribute.isShownOnDashboard && cardAttr.value !== null) + .map(cardAttr => ( + + {cardAttr.attribute.label}: {getAttrValueValue(cardAttr)} + + )) + } + + ); + }; + + const getAttrValueValue = (cardAttr: CardAttributeSchema) => { + const value = cardAttr.value; + if (value === null) return; + + const type = cardAttr.attribute.type.type; + if (type === "datetime") { + return formatDateTime(value as string); + } + if (type === "date") { + return formatDate(value as string); + } + if (type === "bool") { + return value ? "да" : "нет"; + } + + return value; + }; + return (
= ({ cardSummary, color }) => { )} + {attributeValues()} {!cardSummary.group?.id && ( - + )} diff --git a/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx b/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx index 33ed194..e42d727 100644 --- a/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx +++ b/src/pages/AdminPage/tabs/Attributes/hooks/attributesTableColumns.tsx @@ -47,6 +47,15 @@ const useAttributesTableColumns = () => { ), }, + { + header: "Вывод на дашборде", + accessorKey: "isShownOnDashboard", + Cell: ({ cell }) => cell.getValue() ? ( + + ) : ( + + ), + }, { header: "Может быть пустым", accessorKey: "isNullable", diff --git a/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx b/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx index 515cefe..1cd82aa 100644 --- a/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx +++ b/src/pages/AdminPage/tabs/Attributes/modals/AttributeModal.tsx @@ -33,6 +33,7 @@ const AttributeModal = ({ name: "", type: undefined, isApplicableToGroup: false, + isShownOnDashboard: false, isNullable: false, defaultValue: null, description: "", @@ -143,6 +144,10 @@ const AttributeModal = ({ label={"Значение синхронизировано в группе"} {...form.getInputProps("isApplicableToGroup", { type: "checkbox" })} /> + {isNullableInputShown && ( { accessorKey: "type.name", size: 120, }, - // { - // header: " ", - // Cell: ({ row }) => { - // const description = row.original.description ? `Описание: ${row.original.description}` : ""; - // const info = ( - // - // Может быть пустым: {row.original.isNullable ? "да" : "нет"} - // {defaultValueToStr(row.original.defaultValue, row.original.type.type)} - // Синхронизировано в группе: {row.original.isApplicableToGroup ? "да" : "нет"} - // {description} - // - // ); - // return ( - // - // - // - // ); - // }, - // size: 5, - // }, { header: "Значение по умолчанию", accessorKey: "defaultValue", @@ -93,6 +73,16 @@ const useAttributesTableColumns = ({ selectedAttributes }: Props) => { ), size: 120, }, + { + header: "Вывод на дашборде", + accessorKey: "isShownOnDashboard", + Cell: ({ cell }) => cell.getValue() ? ( + + ) : ( + + ), + size: 130, + }, { header: "Может быть пустым", accessorKey: "isNullable",