fix: 보고된 중간 점검일 삭제 방지(보고 이력 보존)
수정 시 보고가 접수된 점검일을 지우면 CASCADE 로 보고서까지 삭제되던 문제 방지: - 백엔드 syncCheckpoints: 보고가 있는 점검일은 삭제 대상에서 제외 - 프론트 수정 폼: 보고된 점검일은 '보고됨' 잠금 배지로 표시하고 삭제 버튼 비노출 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1383,7 +1383,12 @@ export class TaskService {
|
||||
c.workStatus = ws;
|
||||
changed.push(c);
|
||||
}
|
||||
return { itemId: c.id, text: c.text, category: c.category, workStatus: ws };
|
||||
return {
|
||||
itemId: c.id,
|
||||
text: c.text,
|
||||
category: c.category,
|
||||
workStatus: ws,
|
||||
};
|
||||
});
|
||||
if (changed.length) {
|
||||
await this.checklistRepo.save(changed);
|
||||
@@ -1429,8 +1434,19 @@ export class TaskService {
|
||||
const existingTimes = existing.map((c) => c.checkAt.getTime());
|
||||
const wantedTimes = [...new Set(dates.map((d) => new Date(d).getTime()))];
|
||||
|
||||
// 보고가 있는 점검일은 삭제하지 않는다 — 보고 이력(스냅샷) 보존
|
||||
// (점검일 삭제 시 checkpoint_reports 가 CASCADE 로 함께 사라지므로 명시적으로 보호)
|
||||
const reports = await this.reportRepo.find({
|
||||
where: { task: { id: task.id } },
|
||||
relations: ['checkpoint'],
|
||||
});
|
||||
const reportedIds = new Set(
|
||||
reports.map((r) => r.checkpoint?.id).filter((id): id is string => !!id),
|
||||
);
|
||||
|
||||
const toRemove = existing.filter(
|
||||
(c) => !wantedTimes.includes(c.checkAt.getTime()),
|
||||
(c) =>
|
||||
!wantedTimes.includes(c.checkAt.getTime()) && !reportedIds.has(c.id),
|
||||
);
|
||||
if (toRemove.length) {
|
||||
await this.checkpointRepo.remove(toRemove);
|
||||
|
||||
Reference in New Issue
Block a user