From 4752b2dedc2223cee2c4c2b8f8c9ecae4495bd79 Mon Sep 17 00:00:00 2001 From: tlartem Date: Sun, 27 Jul 2025 07:47:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD=20=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CategoryFieldsSelector.tsx | 71 +-- src/page/TemplatesOverviewPage.tsx | 434 ++++++++++-------- 2 files changed, 282 insertions(+), 223 deletions(-) diff --git a/src/component/TemplateManager/CategoryFieldsSelector.tsx b/src/component/TemplateManager/CategoryFieldsSelector.tsx index ca9c2f2..aa57fa8 100644 --- a/src/component/TemplateManager/CategoryFieldsSelector.tsx +++ b/src/component/TemplateManager/CategoryFieldsSelector.tsx @@ -14,12 +14,14 @@ interface CategoryFieldsSelectorProps { selectedValues: AttributeValue[] onValuesChange: (values: AttributeValue[]) => void disabled?: boolean + compact?: boolean // Новый проп для компактного отображения } export const CategoryFieldsSelector: React.FC = ({ selectedValues, onValuesChange, disabled = false, + compact = false, // По умолчанию обычный режим }) => { const { attributes, @@ -56,7 +58,10 @@ export const CategoryFieldsSelector: React.FC = ({ return (
-
) } + const renderAttributeSection = ( + attributesList: Attribute[], + title: string, + titleColor: string = '' + ) => { + if (attributesList.length === 0) return null + + return ( +
+
+ +
+
+ {attributesList.map(renderAttribute)} +
+
+ ) + } + if (isLoading) { return (
@@ -93,34 +126,16 @@ export const CategoryFieldsSelector: React.FC = ({ } return ( -
+
{/* Обязательные атрибуты */} - {requiredAttributes.length > 0 && ( -
-
- -
-
- {requiredAttributes.map(renderAttribute)} -
-
+ {renderAttributeSection( + requiredAttributes, + 'Обязательные атрибуты', + 'text-red-600' )} {/* Необязательные атрибуты */} - {optionalAttributes.length > 0 && ( -
-
- -
-
- {optionalAttributes.map(renderAttribute)} -
-
- )} + {renderAttributeSection(optionalAttributes, 'Дополнительные атрибуты')} {attributes.length === 0 && (
diff --git a/src/page/TemplatesOverviewPage.tsx b/src/page/TemplatesOverviewPage.tsx index b1b8ab6..bffda4c 100644 --- a/src/page/TemplatesOverviewPage.tsx +++ b/src/page/TemplatesOverviewPage.tsx @@ -4,12 +4,12 @@ import { TemplateFilters, } from '@/component/TemplateManager/TemplateFilterSidebar' import { Button } from '@/component/ui/button' +import { Card, CardContent, CardHeader, CardTitle } from '@/component/ui/card' import { Dialog, DialogClose, DialogContent, DialogDescription, - DialogFooter, DialogHeader, DialogTitle, DialogTrigger, @@ -32,7 +32,18 @@ import { useTemplateContext } from '@/entitiy/template/model/TemplateContext' import { Template, TemplateAttributeDetail } from '@/type/template' import TemplateCard from '@/widget/template/ui/TemplateCard' import clsx from 'clsx' -import { CheckSquare, Plus, Square, Trash2 } from 'lucide-react' +import { + CheckSquare, + Copy, + Edit3, + FileText, + Plus, + Settings2, + Square, + Tag, + Trash2, + Type, +} from 'lucide-react' import { useCallback, useMemo, useState } from 'react' interface AttributeValue { @@ -65,6 +76,172 @@ const fromCategoryAttributeValues = ( })) } +// Компактный селектор атрибутов +interface CompactCategoryFieldsSelectorProps { + selectedValues: CategoryAttributeValue[] + onValuesChange: (values: CategoryAttributeValue[]) => void + isLoading?: boolean +} + +const CompactCategoryFieldsSelector: React.FC< + CompactCategoryFieldsSelectorProps +> = ({ selectedValues, onValuesChange, isLoading = false }) => { + if (isLoading) { + return ( +
+ Загрузка атрибутов... +
+ ) + } + + return ( +
+ +
+ ) +} + +// Общий компонент формы шаблона +interface TemplateFormProps { + title: string + description: string + icon: React.ReactNode + iconColor: string + name: string + onNameChange: (value: string) => void + templateDescription: string + onDescriptionChange: (value: string) => void + attributeValues: AttributeValue[] + onAttributeValuesChange: (values: AttributeValue[]) => void + attributesLoading: boolean + onSubmit: () => void + onCancel: () => void + submitText: string + submitIcon: React.ReactNode + isSubmitDisabled: boolean + nameLabel?: string + descriptionLabel?: string +} + +const TemplateForm: React.FC = ({ + title, + description, + icon, + iconColor, + name, + onNameChange, + templateDescription, + onDescriptionChange, + attributeValues, + onAttributeValuesChange, + attributesLoading, + onSubmit, + onCancel, + submitText, + submitIcon, + isSubmitDisabled, + nameLabel = 'Название шаблона', + descriptionLabel = 'Описание', +}) => { + return ( + <> + + + {icon} + {title} + + {description} + + +
+ {/* Основные настройки */} + + +
+ + Основная информация +
+
+ +
+ + onNameChange(e.target.value)} + className="h-9" + /> +
+ +
+ +