Updated flows tree
Deploy Frontend / build-and-deploy (push) Failing after 1m1s
Details
Deploy Frontend / build-and-deploy (push) Failing after 1m1s
Details
This commit is contained in:
parent
2531e830b8
commit
acbd65aa4f
|
|
@ -9,6 +9,7 @@ export interface HierarchiesListParams {
|
||||||
department_id?: number
|
department_id?: number
|
||||||
topic_category_id?: number
|
topic_category_id?: number
|
||||||
topic_id?: number
|
topic_id?: number
|
||||||
|
target_system?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateHierarchyRequest {
|
export interface CreateHierarchyRequest {
|
||||||
|
|
@ -18,6 +19,7 @@ export interface CreateHierarchyRequest {
|
||||||
topic_category_id?: number | null
|
topic_category_id?: number | null
|
||||||
topic_id?: number | null
|
topic_id?: number | null
|
||||||
priority?: number
|
priority?: number
|
||||||
|
target_system?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateHierarchyRequest {
|
export interface UpdateHierarchyRequest {
|
||||||
|
|
@ -28,6 +30,7 @@ export interface UpdateHierarchyRequest {
|
||||||
topic_category_id?: number | null
|
topic_category_id?: number | null
|
||||||
topic_id?: number | null
|
topic_id?: number | null
|
||||||
priority?: number
|
priority?: number
|
||||||
|
target_system?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const hierarchiesApi = {
|
export const hierarchiesApi = {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { useQueries } from '@tanstack/react-query'
|
||||||
|
import { useCategories } from '@/features/categories/hooks/useCategories'
|
||||||
|
import { useFlowNodesTree, FLOW_NODES_QUERY_KEY } from '@/features/flowNodes/hooks/useFlowNodes'
|
||||||
|
import { flowNodesApi } from '@/api/flowNodes'
|
||||||
|
import type { ApprovalFlowNode, ApiResponse } from '@/types/api'
|
||||||
|
|
||||||
|
export interface SystemOption {
|
||||||
|
value: string
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractSystemOptions(nodes: ApprovalFlowNode[] | null | undefined): SystemOption[] {
|
||||||
|
if (!nodes) return []
|
||||||
|
const seen = new Map<string, string>()
|
||||||
|
for (const n of nodes) {
|
||||||
|
if (n.is_multi_select && n.multi_select_key === 'systems' && n.multi_select_value) {
|
||||||
|
if (!seen.has(n.multi_select_value)) {
|
||||||
|
seen.set(n.multi_select_value, n.label || n.multi_select_value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Array.from(seen.entries()).map(([value, label]) => ({ value, label }))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCategorySystemOptions(categoryId: number | null) {
|
||||||
|
const { data, isLoading } = useFlowNodesTree(categoryId)
|
||||||
|
const options = extractSystemOptions(data?.data)
|
||||||
|
return { options, isLoading: categoryId ? isLoading : false }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAllSystemOptions(enabled: boolean = true) {
|
||||||
|
const { data: categories } = useCategories({ limit: 1000 })
|
||||||
|
const categoryIds = (categories?.data ?? [])
|
||||||
|
.map((c) => c.id)
|
||||||
|
.filter((id): id is number => !!id)
|
||||||
|
|
||||||
|
const results = useQueries({
|
||||||
|
queries: categoryIds.map((id) => ({
|
||||||
|
queryKey: [FLOW_NODES_QUERY_KEY, id],
|
||||||
|
queryFn: async () => {
|
||||||
|
const response = await flowNodesApi.getTree(id)
|
||||||
|
return response.data as ApiResponse<ApprovalFlowNode[]>
|
||||||
|
},
|
||||||
|
enabled,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
|
||||||
|
const isLoading = enabled && results.some((r) => r.isLoading)
|
||||||
|
|
||||||
|
const merged = new Map<string, string>()
|
||||||
|
for (const r of results) {
|
||||||
|
const nodes = (r.data as ApiResponse<ApprovalFlowNode[]> | undefined)?.data
|
||||||
|
for (const opt of extractSystemOptions(nodes)) {
|
||||||
|
if (!merged.has(opt.value)) merged.set(opt.value, opt.label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = Array.from(merged.entries()).map(([value, label]) => ({ value, label }))
|
||||||
|
return { options, isLoading }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ALL_SYSTEMS_VALUE = 'all'
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// ChainVisualization.tsx
|
||||||
|
import { useState } from 'react'
|
||||||
import {
|
import {
|
||||||
Paper,
|
Paper,
|
||||||
Group,
|
Group,
|
||||||
|
|
@ -9,20 +11,22 @@ import {
|
||||||
Box,
|
Box,
|
||||||
Divider,
|
Divider,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
Select,
|
||||||
} from '@mantine/core'
|
} from '@mantine/core'
|
||||||
import {
|
import {
|
||||||
IconChevronRight,
|
IconChevronRight,
|
||||||
IconPencil,
|
IconPencil,
|
||||||
IconTrash,
|
IconTrash,
|
||||||
IconUser,
|
|
||||||
IconWorld,
|
IconWorld,
|
||||||
IconCategory,
|
IconCategory,
|
||||||
IconFileText,
|
IconFileText,
|
||||||
IconCopy,
|
IconCopy,
|
||||||
IconPlus,
|
IconPlus,
|
||||||
|
IconServer,
|
||||||
} from '@tabler/icons-react'
|
} from '@tabler/icons-react'
|
||||||
import type { ChainGroup } from '@/features/hierarchies/utils'
|
import type { ChainGroup } from '@/features/hierarchies/utils'
|
||||||
import { SCOPE_COLORS, SCOPE_LABELS } from '@/features/hierarchies/utils'
|
import { SCOPE_COLORS, SCOPE_LABELS } from '@/features/hierarchies/utils'
|
||||||
|
import { useCategorySystemOptions, ALL_SYSTEMS_VALUE } from '@/features/hierarchies/hooks/useSystemOptions'
|
||||||
|
|
||||||
interface ChainVisualizationProps {
|
interface ChainVisualizationProps {
|
||||||
group: ChainGroup
|
group: ChainGroup
|
||||||
|
|
@ -30,6 +34,7 @@ interface ChainVisualizationProps {
|
||||||
onDeleteStep: (hierarchyId: number) => void
|
onDeleteStep: (hierarchyId: number) => void
|
||||||
onAddStep: (group: ChainGroup) => void
|
onAddStep: (group: ChainGroup) => void
|
||||||
onDuplicateChain: (group: ChainGroup) => void
|
onDuplicateChain: (group: ChainGroup) => void
|
||||||
|
onBulkUpdateSystem?: (group: ChainGroup, targetSystem: string | null) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const ScopeIcon = ({ type }: { type: string }) => {
|
const ScopeIcon = ({ type }: { type: string }) => {
|
||||||
|
|
@ -51,7 +56,28 @@ export default function ChainVisualization({
|
||||||
onDeleteStep,
|
onDeleteStep,
|
||||||
onAddStep,
|
onAddStep,
|
||||||
onDuplicateChain,
|
onDuplicateChain,
|
||||||
|
onBulkUpdateSystem,
|
||||||
}: ChainVisualizationProps) {
|
}: ChainVisualizationProps) {
|
||||||
|
// Получаем доступные системы для категории (или темы)
|
||||||
|
const categoryId = group.scopeType === 'category' ? group.scopeObjectId : null
|
||||||
|
const { options: systemOptions } = useCategorySystemOptions(categoryId)
|
||||||
|
|
||||||
|
// Текущая система цепочки (если у всех шагов одинаковая система, иначе 'all')
|
||||||
|
const currentChainSystem = group.steps.every(
|
||||||
|
(s) => s.target_system === group.steps[0]?.target_system
|
||||||
|
)
|
||||||
|
? group.steps[0]?.target_system || ALL_SYSTEMS_VALUE
|
||||||
|
: ALL_SYSTEMS_VALUE
|
||||||
|
|
||||||
|
// Формируем опции для Select
|
||||||
|
const selectData = [
|
||||||
|
{ value: ALL_SYSTEMS_VALUE, label: 'Система: Все' },
|
||||||
|
...systemOptions.map((opt) => ({
|
||||||
|
value: opt.value,
|
||||||
|
label: `Система: ${opt.label}`,
|
||||||
|
})),
|
||||||
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
withBorder
|
withBorder
|
||||||
|
|
@ -88,6 +114,23 @@ export default function ChainVisualization({
|
||||||
>
|
>
|
||||||
{SCOPE_LABELS[group.scopeType]}: {group.scopeObjectName}
|
{SCOPE_LABELS[group.scopeType]}: {group.scopeObjectName}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
|
||||||
|
{/* Выпадающий список систем отображается ТОЛЬКО если у темы/категории есть заданные systems */}
|
||||||
|
{systemOptions.length > 0 && (
|
||||||
|
<Select
|
||||||
|
size="xs"
|
||||||
|
leftSection={<IconServer size={14} />}
|
||||||
|
data={selectData}
|
||||||
|
value={currentChainSystem}
|
||||||
|
onChange={(val) => {
|
||||||
|
const newSystem = val === ALL_SYSTEMS_VALUE ? null : val
|
||||||
|
if (onBulkUpdateSystem) {
|
||||||
|
onBulkUpdateSystem(group, newSystem)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{ width: 180 }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
|
|
@ -151,7 +194,6 @@ export default function ChainVisualization({
|
||||||
{/* Шаги согласования */}
|
{/* Шаги согласования */}
|
||||||
{group.steps.map((step, index) => (
|
{group.steps.map((step, index) => (
|
||||||
<Group key={step.id} gap={0} wrap="nowrap" align="stretch">
|
<Group key={step.id} gap={0} wrap="nowrap" align="stretch">
|
||||||
{/* Разделитель со стрелкой */}
|
|
||||||
<Stack
|
<Stack
|
||||||
gap={2}
|
gap={2}
|
||||||
align="center"
|
align="center"
|
||||||
|
|
@ -160,12 +202,7 @@ export default function ChainVisualization({
|
||||||
style={{ minWidth: 60 }}
|
style={{ minWidth: 60 }}
|
||||||
>
|
>
|
||||||
<IconChevronRight size={20} color="var(--mantine-color-gray-5)" />
|
<IconChevronRight size={20} color="var(--mantine-color-gray-5)" />
|
||||||
<Badge
|
<Badge size="xs" variant="light" color="gray" tt="none">
|
||||||
size="xs"
|
|
||||||
variant="light"
|
|
||||||
color="gray"
|
|
||||||
tt="none"
|
|
||||||
>
|
|
||||||
{index + 1}
|
{index + 1}
|
||||||
</Badge>
|
</Badge>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
@ -184,12 +221,10 @@ export default function ChainVisualization({
|
||||||
}}
|
}}
|
||||||
onClick={() => onEditStep(step.id!)}
|
onClick={() => onEditStep(step.id!)}
|
||||||
onMouseEnter={(e) => {
|
onMouseEnter={(e) => {
|
||||||
e.currentTarget.style.borderColor =
|
e.currentTarget.style.borderColor = 'var(--mantine-color-blue-5)'
|
||||||
'var(--mantine-color-blue-5)'
|
|
||||||
}}
|
}}
|
||||||
onMouseLeave={(e) => {
|
onMouseLeave={(e) => {
|
||||||
e.currentTarget.style.borderColor =
|
e.currentTarget.style.borderColor = 'var(--mantine-color-gray-3)'
|
||||||
'var(--mantine-color-gray-3)'
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack gap="xs" align="center">
|
<Stack gap="xs" align="center">
|
||||||
|
|
@ -203,22 +238,12 @@ export default function ChainVisualization({
|
||||||
>
|
>
|
||||||
Шаг {index + 1}
|
Шаг {index + 1}
|
||||||
</Text>
|
</Text>
|
||||||
<Badge
|
<Badge size="xs" variant="light" color="gray" tt="none">
|
||||||
size="xs"
|
|
||||||
variant="light"
|
|
||||||
color="gray"
|
|
||||||
tt="none"
|
|
||||||
>
|
|
||||||
#{step.priority}
|
#{step.priority}
|
||||||
</Badge>
|
</Badge>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Avatar
|
<Avatar size="md" radius="xl" color="blue" variant="filled">
|
||||||
size="md"
|
|
||||||
radius="xl"
|
|
||||||
color="blue"
|
|
||||||
variant="filled"
|
|
||||||
>
|
|
||||||
{step.approver?.full_name?.charAt(0).toUpperCase() || '?'}
|
{step.approver?.full_name?.charAt(0).toUpperCase() || '?'}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
|
|
||||||
|
|
@ -226,11 +251,15 @@ export default function ChainVisualization({
|
||||||
{step.approver?.full_name || '—'}
|
{step.approver?.full_name || '—'}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Divider
|
{/* Бейдж конкретной целевой системы для шага (если выбрано) */}
|
||||||
style={{ width: '100%', margin: '4px 0' }}
|
{step.target_system && (
|
||||||
/>
|
<Badge size="xs" color="cyan" variant="light">
|
||||||
|
Система: {step.target_system}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Divider style={{ width: '100%', margin: '4px 0' }} />
|
||||||
|
|
||||||
{/* Кнопки действий */}
|
|
||||||
<Group gap="xs" justify="center">
|
<Group gap="xs" justify="center">
|
||||||
<Tooltip label="Редактировать" withArrow>
|
<Tooltip label="Редактировать" withArrow>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ export default function HierarchyEditModal({
|
||||||
topic_category_id: null as number | null,
|
topic_category_id: null as number | null,
|
||||||
topic_id: null as number | null,
|
topic_id: null as number | null,
|
||||||
priority: 0,
|
priority: 0,
|
||||||
|
target_system: null as string | null
|
||||||
},
|
},
|
||||||
validate: {
|
validate: {
|
||||||
subordinate_id: (v) => (v === null ? 'Выберите подчинённого' : null),
|
subordinate_id: (v) => (v === null ? 'Выберите подчинённого' : null),
|
||||||
|
|
@ -119,17 +120,10 @@ export default function HierarchyEditModal({
|
||||||
scope_type: scopeType,
|
scope_type: scopeType,
|
||||||
topic_category_id: resolvedCategoryId,
|
topic_category_id: resolvedCategoryId,
|
||||||
topic_id: hierarchy.topic_id || null,
|
topic_id: hierarchy.topic_id || null,
|
||||||
|
target_system: hierarchy.target_system || null,
|
||||||
priority: hierarchy.priority ?? 0,
|
priority: hierarchy.priority ?? 0,
|
||||||
})
|
})
|
||||||
} else if (presetGroup) {
|
} else if (presetGroup) {
|
||||||
// 🩹 ФИКС (баг №5): раньше topic_category_id подставлялся ТОЛЬКО
|
|
||||||
// когда scopeType === 'category' — для scopeType === 'topic' поле
|
|
||||||
// оставалось пустым. А сам Select "Категория" при этом заблокирован
|
|
||||||
// (disabled={isEditMode || !!presetGroup} — ниже), так что
|
|
||||||
// пользователь физически не мог ни увидеть категорию, ни выбрать
|
|
||||||
// её сам: обязательное, но недоступное для правки поле. Отсюда
|
|
||||||
// и "не могу добавить нового согласующего" — форма просто не
|
|
||||||
// проходила валидацию, а причина была не видна.
|
|
||||||
let resolvedCategoryId: number | null = null
|
let resolvedCategoryId: number | null = null
|
||||||
if (presetGroup.scopeType === 'category') {
|
if (presetGroup.scopeType === 'category') {
|
||||||
resolvedCategoryId = presetGroup.scopeObjectId
|
resolvedCategoryId = presetGroup.scopeObjectId
|
||||||
|
|
@ -189,6 +183,7 @@ export default function HierarchyEditModal({
|
||||||
approver_id: values.approver_id!,
|
approver_id: values.approver_id!,
|
||||||
department_id: values.department_id!,
|
department_id: values.department_id!,
|
||||||
priority: values.priority,
|
priority: values.priority,
|
||||||
|
target_system: values.target_system || null,
|
||||||
topic_category_id: values.scope_type === 'global' ? null :
|
topic_category_id: values.scope_type === 'global' ? null :
|
||||||
values.scope_type === 'category' ? values.topic_category_id : null,
|
values.scope_type === 'category' ? values.topic_category_id : null,
|
||||||
topic_id: values.scope_type === 'topic' ? values.topic_id : null,
|
topic_id: values.scope_type === 'topic' ? values.topic_id : null,
|
||||||
|
|
@ -361,6 +356,19 @@ export default function HierarchyEditModal({
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<Select
|
||||||
|
label="Целевая система шага (Target System)"
|
||||||
|
placeholder="Все системы (по умолчанию)"
|
||||||
|
data={[
|
||||||
|
{ value: '', label: 'Все системы' },
|
||||||
|
...systemOptions.map((s) => ({ value: s.value, label: s.label })),
|
||||||
|
]}
|
||||||
|
value={form.values.target_system || ''}
|
||||||
|
onChange={(v) => form.setFieldValue('target_system', v || null)}
|
||||||
|
clearable
|
||||||
|
description="Укажите систему, если данный шаг согласующего применяется только к определенной системе"
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Priority */}
|
{/* Priority */}
|
||||||
<NumberInput
|
<NumberInput
|
||||||
label="Порядок шага (priority)"
|
label="Порядок шага (priority)"
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@ export interface UserHierarchy {
|
||||||
subordinate?: User
|
subordinate?: User
|
||||||
approver?: User
|
approver?: User
|
||||||
department?: Department
|
department?: Department
|
||||||
|
target_system?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApprovalTopicExecutor {
|
export interface ApprovalTopicExecutor {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue