261119_01_ENH: 리스트 필터 다이얼로그에 필터 초기화 버튼 추가
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { RotateCcw } from 'lucide-react'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
@@ -107,6 +108,18 @@ const ListFilterDialog = ({
|
||||
[rows, headerOptions],
|
||||
)
|
||||
|
||||
// 잠긴 헤더는 조회 조건에 쓰이지 않으므로 초기화 필요 여부 판단에서 제외한다.
|
||||
const isResettable = rows.some((row) => {
|
||||
if (isDisabledHeader(row.headerId)) return false
|
||||
const defaultOperator = getHeaderOption(row.headerId)?.defaultOperator ?? 'eq'
|
||||
return row.operator !== defaultOperator || row.textValue !== '' || row.multiValues.length > 0
|
||||
})
|
||||
|
||||
// 다이얼로그 내 입력만 기본값으로 되돌린다. 실제 반영은 "적용"을 눌러야 이뤄진다.
|
||||
const handleReset = () => {
|
||||
setRows(headerOptions.map((option) => createFilterRow(option.id, headerOptions)))
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setSubmitting(true)
|
||||
try {
|
||||
@@ -138,7 +151,20 @@ const ListFilterDialog = ({
|
||||
<div className="grid h-11 grid-cols-[1fr_140px_1.4fr] items-center border-b bg-muted px-4 text-sm font-semibold">
|
||||
<span>헤더</span>
|
||||
<span>비교 연산자</span>
|
||||
<span>값</span>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span>값</span>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 text-muted-foreground"
|
||||
onClick={handleReset}
|
||||
disabled={submitting || !isResettable}
|
||||
>
|
||||
<RotateCcw className="size-3.5" />
|
||||
초기화
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="max-h-170 overflow-auto">
|
||||
|
||||
Reference in New Issue
Block a user