diff options
Diffstat (limited to 'lib/docu-list-rule/combo-box-settings/table')
8 files changed, 70 insertions, 9 deletions
diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx index 049e2c1a..a0535b43 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx @@ -27,7 +27,7 @@ import { } from "@/components/ui/form" import { Input } from "@/components/ui/input" -import { createComboBoxOption } from "../service" +import { createComboBoxOption } from "@/lib/docu-list-rule/combo-box-settings/service" const createOptionSchema = z.object({ code: z.string().min(1, "코드는 필수입니다."), diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet.tsx index b62b258e..22806ae8 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet.tsx @@ -14,7 +14,7 @@ import { getColumns } from "@/lib/docu-list-rule/combo-box-settings/table/combo- import { ComboBoxOptionsEditSheet } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet" import { DeleteComboBoxOptionsDialog } from "@/lib/docu-list-rule/combo-box-settings/table/delete-combo-box-options-dialog" import { ComboBoxOptionsTableToolbarActions } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-toolbar" -import { codeGroups } from "@/db/schema" +import { codeGroups } from "@/db/schema/docu-list-rule" type ComboBoxOption = { id: number codeGroupId: number diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx index 4ac539d0..e4504d8c 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx @@ -25,7 +25,7 @@ import { } from "@/components/ui/form" import { Input } from "@/components/ui/input" -import { updateComboBoxOption } from "../service" +import { updateComboBoxOption } from "@/lib/docu-list-rule/combo-box-settings/service" const updateOptionSchema = z.object({ code: z.string().min(1, "코드는 필수입니다."), diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-columns.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-columns.tsx index 0e46c0ed..17754331 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-columns.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-columns.tsx @@ -28,6 +28,9 @@ interface ComboBoxOption { isActive?: boolean createdAt: Date updatedAt: Date + projectId: number + projectCode: string | null + projectName: string | null } interface GetColumnsProps { @@ -111,6 +114,19 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<ComboBo // ---------------------------------------------------------------- const dataColumns: ColumnDef<ComboBoxOption>[] = [ { + accessorKey: "projectCode", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="프로젝트 코드" /> + ), + meta: { + excelHeader: "프로젝트 코드", + type: "text", + }, + cell: ({ row }) => row.getValue("projectCode") ?? "", + minSize: 120 + }, + { accessorKey: "code", enableResizing: true, header: ({ column }) => ( @@ -124,6 +140,19 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<ComboBo minSize: 80 }, { + accessorKey: "description", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="description" /> + ), + meta: { + excelHeader: "description", + type: "text", + }, + cell: ({ row }) => row.getValue("description") ?? "", + minSize: 80 + }, + { accessorKey: "remark", enableResizing: true, header: ({ column }) => ( diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-toolbar.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-toolbar.tsx index 7318efb8..3bb3c95f 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-toolbar.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-table-toolbar.tsx @@ -3,8 +3,8 @@ import * as React from "react" import { type Table } from "@tanstack/react-table" -import { ComboBoxOptionsAddDialog } from "./combo-box-options-add-dialog" -import { DeleteComboBoxOptionsDialog } from "./delete-combo-box-options-dialog" +import { ComboBoxOptionsAddDialog } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog" +import { DeleteComboBoxOptionsDialog } from "@/lib/docu-list-rule/combo-box-settings/table/delete-combo-box-options-dialog" interface ComboBoxOption { id: number diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns.tsx index efce54b4..d41fe5ec 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns.tsx @@ -92,6 +92,19 @@ export function getColumns({ onDetail }: GetColumnsProps): ColumnDef<typeof code // ---------------------------------------------------------------- const dataColumns: ColumnDef<typeof codeGroups.$inferSelect>[] = [ { + accessorKey: "projectCode", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="프로젝트 코드" /> + ), + meta: { + excelHeader: "프로젝트 코드", + type: "text", + }, + cell: ({ row }) => row.getValue("projectCode") ?? "", + minSize: 120 + }, + { accessorKey: "groupId", enableResizing: true, header: ({ column }) => ( diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx index 42ce1a19..8e469149 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table.tsx @@ -5,8 +5,8 @@ import { useDataTable } from "@/hooks/use-data-table" import { DataTable } from "@/components/data-table/data-table" import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar" import type { DataTableAdvancedFilterField } from "@/types/table" -import { getColumns } from "./combo-box-settings-table-columns" -import { ComboBoxOptionsDetailSheet } from "./combo-box-options-detail-sheet" +import { getColumns } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-settings-table-columns" +import { ComboBoxOptionsDetailSheet } from "@/lib/docu-list-rule/combo-box-settings/table/combo-box-options-detail-sheet" import { codeGroups } from "@/db/schema/docu-list-rule" interface ComboBoxSettingsTableProps { @@ -61,11 +61,30 @@ export function ComboBoxSettingsTable({ promises }: ComboBoxSettingsTableProps) }, ], }, - getRowId: (originalRow) => String(originalRow.groupId), + getRowId: (originalRow) => String(originalRow.id), shallow: false, clearOnDefault: true, }) + // 컴포넌트 마운트 후 그룹핑 설정 + React.useEffect(() => { + if (rawData[0]?.data && table.getState().grouping.length === 0) { + table.setGrouping(["projectCode"]) + } + }, [table, rawData]) + + // 정렬 시 펼쳐진 상태 유지 + React.useEffect(() => { + const currentExpanded = table.getState().expanded + if (Object.keys(currentExpanded).length > 0) { + // 약간의 지연 후 현재 펼쳐진 상태를 다시 설정 + const timer = setTimeout(() => { + table.setExpanded(currentExpanded) + }, 100) + return () => clearTimeout(timer) + } + }, [table.getState().sorting, table]) + return ( <> <DataTable table={table}> diff --git a/lib/docu-list-rule/combo-box-settings/table/delete-combo-box-options-dialog.tsx b/lib/docu-list-rule/combo-box-settings/table/delete-combo-box-options-dialog.tsx index e3d8bd23..4d9e2455 100644 --- a/lib/docu-list-rule/combo-box-settings/table/delete-combo-box-options-dialog.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/delete-combo-box-options-dialog.tsx @@ -27,7 +27,7 @@ import { DrawerTrigger, } from "@/components/ui/drawer" -import { deleteComboBoxOption } from "../service" +import { deleteComboBoxOption } from "@/lib/docu-list-rule/combo-box-settings/service" interface ComboBoxOption { id: number |
