261022_05_ENH: 리스트 초기화 범위 세분화 및 설문별 상태이력 초기화 추가
This commit is contained in:
@@ -44,8 +44,8 @@ import {
|
|||||||
type ListFilterTarget,
|
type ListFilterTarget,
|
||||||
type listHeader,
|
type listHeader,
|
||||||
type ListSearchUiState,
|
type ListSearchUiState,
|
||||||
ListResetMode,
|
type ListResetRequest,
|
||||||
type ListResetScope,
|
type ListResetSelection,
|
||||||
type ListUploadRequest,
|
type ListUploadRequest,
|
||||||
} from '@/types/list'
|
} from '@/types/list'
|
||||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||||
@@ -264,11 +264,12 @@ const ListManagePage = () => {
|
|||||||
showDialog('messageSendDialog')
|
showDialog('messageSendDialog')
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleResetConfirm = async (payload: { target: ListFilterTarget; scope: ListResetScope }) => {
|
const handleResetConfirm = async (payload: { target: ListFilterTarget; selection: ListResetSelection }) => {
|
||||||
await submitJob.mutateAsync({ jobType: 'LIST_RESET', path: 'reset', body: {
|
const body: ListResetRequest = {
|
||||||
resetMode: payload.scope === 'result-and-history' ? ListResetMode.HIST : ListResetMode.ALL,
|
...payload.selection,
|
||||||
listFilter: buildTargetFilter(payload.target),
|
listFilter: buildTargetFilter(payload.target),
|
||||||
} })
|
}
|
||||||
|
await submitJob.mutateAsync({ jobType: 'LIST_RESET', path: 'reset', body })
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUploadConfirm = async (file: File, request: ListUploadRequest) => {
|
const handleUploadConfirm = async (file: File, request: ListUploadRequest) => {
|
||||||
@@ -375,7 +376,9 @@ const ListManagePage = () => {
|
|||||||
{isInternal && (
|
{isInternal && (
|
||||||
<>
|
<>
|
||||||
<ListResetDialog
|
<ListResetDialog
|
||||||
|
key={prjctIdx}
|
||||||
prjctIdx={prjctIdx}
|
prjctIdx={prjctIdx}
|
||||||
|
surveys={projectInfoQuery.data?.surveys}
|
||||||
selectedSids={selectedSidSet}
|
selectedSids={selectedSidSet}
|
||||||
filterSummary={filterSummary}
|
filterSummary={filterSummary}
|
||||||
onConfirm={handleResetConfirm}
|
onConfirm={handleResetConfirm}
|
||||||
|
|||||||
@@ -3,26 +3,44 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { KriDialog } from '@/components/common/KriDialog'
|
import { KriDialog } from '@/components/common/KriDialog'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { Label } from '@/components/ui/label'
|
import { Label } from '@/components/ui/label'
|
||||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
|
||||||
import { useDialog } from '@/hooks/useDialog'
|
import { useDialog } from '@/hooks/useDialog'
|
||||||
import { ListJobGatePanel, useListJobGate } from '@/components/list/ListJobGate'
|
import { ListJobGatePanel, useListJobGate } from '@/components/list/ListJobGate'
|
||||||
import type { DialogId } from '@/store/jotai/dialog'
|
import type { DialogId } from '@/store/jotai/dialog'
|
||||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||||
import type { ListFilterTarget, ListResetScope } from '@/types/list'
|
import type { ListFilterTarget, ListResetSelection } from '@/types/list'
|
||||||
|
import type { ProjectSurvey } from '@/types/project'
|
||||||
|
|
||||||
export type ListResetDialogProps = {
|
export type ListResetDialogProps = {
|
||||||
prjctIdx: number
|
prjctIdx: number
|
||||||
|
/** 프로젝트에 연동된 설문 목록. undefined면 아직 불러오지 못한 상태로 보고 초기화를 막는다. */
|
||||||
|
surveys?: ProjectSurvey[]
|
||||||
dialogId?: DialogId
|
dialogId?: DialogId
|
||||||
open?: boolean
|
open?: boolean
|
||||||
onOpenChange?: (open: boolean) => void
|
onOpenChange?: (open: boolean) => void
|
||||||
selectedSids: string[]
|
selectedSids: string[]
|
||||||
filterSummary?: string[]
|
filterSummary?: string[]
|
||||||
onConfirm: (payload: { target: ListFilterTarget; scope: ListResetScope }) => void | Promise<void>
|
onConfirm: (payload: { target: ListFilterTarget; selection: ListResetSelection }) => void | Promise<void>
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResetSurveyOption = { prjctSurveyIdx: number; surveyName: string }
|
||||||
|
|
||||||
|
const toResetSurveyOptions = (surveys: ProjectSurvey[]): ResetSurveyOption[] => {
|
||||||
|
const seen = new Set<number>()
|
||||||
|
return [...surveys]
|
||||||
|
.sort((a, b) => a.surveyOrder - b.surveyOrder)
|
||||||
|
.flatMap((survey) => {
|
||||||
|
const id = survey.prjctSurveyIdx
|
||||||
|
if (id == null || seen.has(id)) return []
|
||||||
|
seen.add(id)
|
||||||
|
return [{ prjctSurveyIdx: id, surveyName: survey.surveyName }]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListResetDialog = ({
|
const ListResetDialog = ({
|
||||||
prjctIdx,
|
prjctIdx,
|
||||||
|
surveys,
|
||||||
dialogId = 'listResetDialog',
|
dialogId = 'listResetDialog',
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
@@ -32,12 +50,39 @@ const ListResetDialog = ({
|
|||||||
}: ListResetDialogProps) => {
|
}: ListResetDialogProps) => {
|
||||||
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
||||||
const [target, setTarget] = useState<ListFilterTarget>('selected')
|
const [target, setTarget] = useState<ListFilterTarget>('selected')
|
||||||
const [scope, setScope] = useState<ListResetScope>('result-and-history')
|
const [resetList, setResetList] = useState(false)
|
||||||
|
const [resetContactHistory, setResetContactHistory] = useState(false)
|
||||||
|
const [resetInterviewHistory, setResetInterviewHistory] = useState(false)
|
||||||
|
const [selectedSurveyIds, setSelectedSurveyIds] = useState<number[]>([])
|
||||||
const [submitting, setSubmitting] = useState(false)
|
const [submitting, setSubmitting] = useState(false)
|
||||||
|
|
||||||
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
||||||
const gate = useListJobGate({ prjctIdx, jobType: 'LIST_RESET', active: resolvedOpen })
|
const gate = useListJobGate({ prjctIdx, jobType: 'LIST_RESET', active: resolvedOpen })
|
||||||
|
|
||||||
|
const surveysReady = surveys !== undefined
|
||||||
|
const surveyOptions = toResetSurveyOptions(surveys ?? [])
|
||||||
|
const allSurveyIds = surveyOptions.map((survey) => survey.prjctSurveyIdx)
|
||||||
|
// 설문 목록이 다시 조회되어 빠진 설문이 있으면 요청에서 제외한다.
|
||||||
|
const checkedSurveyIds = allSurveyIds.filter((id) => selectedSurveyIds.includes(id))
|
||||||
|
const hasSelection = resetList || resetContactHistory || resetInterviewHistory || checkedSurveyIds.length > 0
|
||||||
|
|
||||||
|
// 리스트 초기화는 모든 이력을 포함해야 하므로 이력을 전부 선택하고 잠근다.
|
||||||
|
// 해제 시에는 잠금 중 화면에 보이던 전체 선택 상태를 그대로 유지한다(잠금 중 로드된 설문 포함).
|
||||||
|
const handleResetListChange = (checked: boolean) => {
|
||||||
|
setResetList(checked)
|
||||||
|
setResetContactHistory(true)
|
||||||
|
setResetInterviewHistory(true)
|
||||||
|
setSelectedSurveyIds(allSurveyIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSurveyChange = (id: number, checked: boolean) => {
|
||||||
|
setSelectedSurveyIds((prev) => (checked ? [...prev.filter((v) => v !== id), id] : prev.filter((v) => v !== id)))
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildSelection = (): ListResetSelection => resetList
|
||||||
|
? { resetList: true, resetContactHistory: true, resetInterviewHistory: true, resetSurveyIds: allSurveyIds }
|
||||||
|
: { resetList: false, resetContactHistory, resetInterviewHistory, resetSurveyIds: checkedSurveyIds }
|
||||||
|
|
||||||
const handleOpenChange = (nextOpen: boolean) => {
|
const handleOpenChange = (nextOpen: boolean) => {
|
||||||
onOpenChange?.(nextOpen)
|
onOpenChange?.(nextOpen)
|
||||||
if (nextOpen) {
|
if (nextOpen) {
|
||||||
@@ -47,14 +92,33 @@ const ListResetDialog = ({
|
|||||||
hideDialog(dialogId)
|
hideDialog(dialogId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// '새 작업'(완료 확인)을 누르면 이전 작업의 대상·범위를 이어 쓰지 않도록 초기값으로 되돌린다.
|
||||||
|
const gatePanel = {
|
||||||
|
...gate,
|
||||||
|
acknowledge: () => {
|
||||||
|
gate.acknowledge()
|
||||||
|
setTarget('selected')
|
||||||
|
setResetList(false)
|
||||||
|
setResetContactHistory(false)
|
||||||
|
setResetInterviewHistory(false)
|
||||||
|
setSelectedSurveyIds([])
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// 전체 대상은 선택 시점에도 한 번 확인한다. 취소하면 기존 대상을 유지한다.
|
||||||
|
const handleTargetChange = (next: ListFilterTarget) => {
|
||||||
|
if (next === 'all' && target !== 'all' && !confirm('전체 대상을 선택하면 프로젝트의 모든 리스트가 초기화 대상이 됩니다. 선택하시겠습니까?')) return
|
||||||
|
setTarget(next)
|
||||||
|
}
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
if (gate.submitBlocked || submitting) return
|
if (gate.submitBlocked || submitting || !surveysReady || !hasSelection) return
|
||||||
if (!validateApplyFilterTarget(target, { selectedCount: selectedSids.length, filterSummary })) return
|
if (!validateApplyFilterTarget(target, { selectedCount: selectedSids.length, filterSummary })) return
|
||||||
if (target === 'all' && !confirm('전체 리스트가 초기화 됩니다. 진행하시겠습니까?')) return
|
if (target === 'all' && !confirm('전체 리스트가 초기화 됩니다. 진행하시겠습니까?')) return
|
||||||
|
|
||||||
setSubmitting(true)
|
setSubmitting(true)
|
||||||
try {
|
try {
|
||||||
await onConfirm({ target, scope })
|
await onConfirm({ target, selection: buildSelection() })
|
||||||
} finally {
|
} finally {
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
}
|
}
|
||||||
@@ -73,20 +137,25 @@ const ListResetDialog = ({
|
|||||||
{gate.hasCurrentJob ? '닫기' : '취소'}
|
{gate.hasCurrentJob ? '닫기' : '취소'}
|
||||||
</Button>
|
</Button>
|
||||||
{!gate.hasCurrentJob && (
|
{!gate.hasCurrentJob && (
|
||||||
<Button type="button" variant="destructive" onClick={handleConfirm} disabled={submitting || gate.submitBlocked}>
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="destructive"
|
||||||
|
onClick={handleConfirm}
|
||||||
|
disabled={submitting || gate.submitBlocked || !surveysReady || !hasSelection}
|
||||||
|
>
|
||||||
초기화
|
초기화
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ListJobGatePanel gate={gate} acknowledgeLabel="새 작업" />
|
<ListJobGatePanel gate={gatePanel} acknowledgeLabel="새 작업" />
|
||||||
{!gate.hasCurrentJob && <>
|
{!gate.hasCurrentJob && <>
|
||||||
<div className="rounded-md border p-4 space-y-4">
|
<div className="rounded-md border p-4 space-y-4">
|
||||||
<p className="text-lg font-semibold text-red-600">초기화 대상</p>
|
<p className="text-lg font-semibold text-red-600">초기화 대상</p>
|
||||||
<ApplyFilterOption
|
<ApplyFilterOption
|
||||||
value={target}
|
value={target}
|
||||||
onValueChange={(v) => setTarget(v)}
|
onValueChange={handleTargetChange}
|
||||||
idPrefix="list-reset-target"
|
idPrefix="list-reset-target"
|
||||||
selectedSids={selectedSids}
|
selectedSids={selectedSids}
|
||||||
filterSummary={filterSummary}
|
filterSummary={filterSummary}
|
||||||
@@ -95,16 +164,63 @@ const ListResetDialog = ({
|
|||||||
|
|
||||||
<div className="rounded-md border p-4 space-y-4">
|
<div className="rounded-md border p-4 space-y-4">
|
||||||
<p className="text-lg font-semibold text-red-600">초기화 범위</p>
|
<p className="text-lg font-semibold text-red-600">초기화 범위</p>
|
||||||
<RadioGroup value={scope} onValueChange={(v) => setScope(v as ListResetScope)} className="space-y-2">
|
<div className="space-y-3">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex flex-wrap items-center gap-x-6 gap-y-2">
|
||||||
<RadioGroupItem value="result-and-history" id="list-reset-scope-result-history" />
|
<div className="flex items-center gap-2">
|
||||||
<Label className="text-base" htmlFor="list-reset-scope-result-history">결과 + 이력 삭제</Label>
|
<Checkbox
|
||||||
|
id="list-reset-scope-list"
|
||||||
|
checked={resetList}
|
||||||
|
onCheckedChange={(checked) => handleResetListChange(checked === true)}
|
||||||
|
/>
|
||||||
|
<Label className="text-base" htmlFor="list-reset-scope-list">리스트</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
id="list-reset-scope-contact"
|
||||||
|
checked={resetList || resetContactHistory}
|
||||||
|
disabled={resetList}
|
||||||
|
onCheckedChange={(checked) => setResetContactHistory(checked === true)}
|
||||||
|
/>
|
||||||
|
<Label className="text-base" htmlFor="list-reset-scope-contact">컨택이력</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
id="list-reset-scope-interview"
|
||||||
|
checked={resetList || resetInterviewHistory}
|
||||||
|
disabled={resetList}
|
||||||
|
onCheckedChange={(checked) => setResetInterviewHistory(checked === true)}
|
||||||
|
/>
|
||||||
|
<Label className="text-base" htmlFor="list-reset-scope-interview">면접이력</Label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
{(!surveysReady || surveyOptions.length > 0) && (
|
||||||
<RadioGroupItem value="list-only" id="list-reset-scope-list-only" />
|
<div className="space-y-2">
|
||||||
<Label className="text-base" htmlFor="list-reset-scope-list-only">결과 + 이력 + 리스트 삭제</Label>
|
<p className="text-sm font-medium text-muted-foreground">설문 상태이력</p>
|
||||||
</div>
|
{!surveysReady && <p className="text-sm text-muted-foreground">설문 목록을 불러오는 중입니다.</p>}
|
||||||
</RadioGroup>
|
<div className="flex flex-wrap items-center gap-x-6 gap-y-2">
|
||||||
|
{surveyOptions.map((survey) => {
|
||||||
|
const id = `list-reset-scope-survey-${survey.prjctSurveyIdx}`
|
||||||
|
return (
|
||||||
|
<div key={survey.prjctSurveyIdx} className="flex items-center gap-2">
|
||||||
|
<Checkbox
|
||||||
|
id={id}
|
||||||
|
checked={resetList || checkedSurveyIds.includes(survey.prjctSurveyIdx)}
|
||||||
|
disabled={resetList}
|
||||||
|
onCheckedChange={(checked) => handleSurveyChange(survey.prjctSurveyIdx, checked === true)}
|
||||||
|
/>
|
||||||
|
<Label className="text-base" htmlFor={id}>{survey.surveyName}</Label>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<ul className="list-disc space-y-1 pl-5 text-sm text-muted-foreground">
|
||||||
|
<li>선택한 이력은 해당 유형의 이력과 최신 상태가 함께 초기화되며, 선택하지 않은 이력은 유지됩니다.</li>
|
||||||
|
<li>리스트를 선택하면 리스트와 모든 이력이 함께 초기화됩니다.</li>
|
||||||
|
<li>설문 상태이력 초기화는 외부 설문 시스템의 실제 응답 데이터를 삭제하지 않습니다.</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</>}
|
</>}
|
||||||
</KriDialog>
|
</KriDialog>
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ export function useListJobGate({ prjctIdx, jobType, active, requestLabel, pollWh
|
|||||||
const status: ListJobGateStatus = !active ? 'idle'
|
const status: ListJobGateStatus = !active ? 'idle'
|
||||||
: isAvailabilityUnsupported(availability.error) ? 'unsupported'
|
: isAvailabilityUnsupported(availability.error) ? 'unsupported'
|
||||||
: availability.isError ? 'error'
|
: availability.isError ? 'error'
|
||||||
: !availability.data || (!pollWhileIdle && availability.isFetching && availability.data.allowed) ? 'checking'
|
// 재조회 중에는 직전 결과를 유지한다. 같은 쿼리를 페이지가 주기적으로 재조회하므로 isFetching을 '확인 중'으로
|
||||||
|
// 보면 그때마다 다이얼로그가 깜빡인다. 접수 직전에는 useSubmitListJob이 다시 확인한다.
|
||||||
|
: !availability.data ? 'checking'
|
||||||
: availability.data.allowed ? 'allowed' : 'blocked'
|
: availability.data.allowed ? 'allowed' : 'blocked'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ export enum ListUploadMode {
|
|||||||
ADD_AND_CHANGE = 1,
|
ADD_AND_CHANGE = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ListResetMode {
|
|
||||||
ALL = 0,
|
|
||||||
HIST = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ListEventHistoryBase {
|
export enum ListEventHistoryBase {
|
||||||
ALL = 1,
|
ALL = 1,
|
||||||
LATEST = 2,
|
LATEST = 2,
|
||||||
@@ -90,7 +85,12 @@ export type ListDownloadPayload = {
|
|||||||
historyOrder?: ListEventHistoryOrder;
|
historyOrder?: ListEventHistoryOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListResetScope = 'result-and-history' | 'list-only';
|
export type ListResetSelection = {
|
||||||
|
resetList: boolean;
|
||||||
|
resetContactHistory: boolean;
|
||||||
|
resetInterviewHistory: boolean;
|
||||||
|
resetSurveyIds: number[];
|
||||||
|
};
|
||||||
|
|
||||||
export type ListFilterCondition = {
|
export type ListFilterCondition = {
|
||||||
operator: ListFilterOperator;
|
operator: ListFilterOperator;
|
||||||
@@ -353,8 +353,7 @@ export type ProjectFieldworkAssignSummary = {
|
|||||||
assignees: FieldworkAssignSummaryItem[];
|
assignees: FieldworkAssignSummaryItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListResetRequest = {
|
export type ListResetRequest = ListResetSelection & {
|
||||||
resetMode: ListResetMode;
|
|
||||||
listFilter: ListFilter;
|
listFilter: ListFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user