메뉴 영구삭제 기능 개선

- 메뉴 영구삭제 시 연관 권한도 함께 삭제
- 삭제 정보를 archived_records에 저장 (복구용)
  - 메뉴 데이터, 권한 목록, 역할-권한 연결 정보 보관
- batch_id를 순수 UUID로 변경 (컬럼 크기 제한 해결)
- 영구삭제 시 에러 메시지 토스트로 표시 (하위 메뉴 존재 등)
- 글로벌 메뉴 영구삭제 시 참조 테넌트 메뉴 연결 해제
This commit is contained in:
2025-12-09 23:11:17 +09:00
parent f92b9335fc
commit 36daf862b1
3 changed files with 40 additions and 16 deletions

View File

@@ -322,10 +322,10 @@ public function forceDeleteMenu(int $id): array
->toArray();
// 아카이브 레코드 생성
$batchId = 'menu_delete_'.Str::uuid();
$batchId = (string) Str::uuid();
$archivedRecord = ArchivedRecord::create([
'batch_id' => $batchId,
'batch_description' => "메뉴 삭제: {$menu->name} (ID: {$menu->id})",
'batch_description' => "메뉴 영구 삭제: {$menu->name} (ID: {$menu->id})",
'record_type' => 'menu',
'tenant_id' => $menu->tenant_id,
'original_id' => $menu->id,
@@ -720,10 +720,10 @@ public function forceDeleteGlobalMenu(int $id): array
->toArray();
// 아카이브 레코드 생성
$batchId = 'global_menu_delete_'.Str::uuid();
$batchId = (string) Str::uuid();
$archivedRecord = ArchivedRecord::create([
'batch_id' => $batchId,
'batch_description' => "글로벌 메뉴 삭제: {$menu->name} (ID: {$menu->id})",
'batch_description' => "글로벌 메뉴 영구 삭제: {$menu->name} (ID: {$menu->id})",
'record_type' => 'global_menu',
'tenant_id' => null,
'original_id' => $menu->id,

View File

@@ -210,14 +210,26 @@ function saveGlobalMenuOrder(items) {
// 영구삭제 확인
window.confirmForceDelete = function(id, name) {
showPermanentDeleteConfirm(name, () => {
htmx.ajax('DELETE', `/api/admin/global-menus/${id}/force`, {
target: '#menu-table',
swap: 'none',
fetch(`/api/admin/global-menus/${id}/force`, {
method: 'DELETE',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
})
.then(response => response.json().then(data => ({ ok: response.ok, data })))
.then(({ ok, data }) => {
if (ok && data.success) {
showToast(data.message || '글로벌 메뉴가 영구 삭제되었습니다.', 'success');
htmx.trigger('#menu-table', 'filterSubmit');
} else {
showToast(data.message || '삭제에 실패했습니다.', 'error');
}
})
.catch(error => {
showToast('삭제 중 오류가 발생했습니다.', 'error');
console.error('Force delete error:', error);
});
});
};

View File

@@ -593,14 +593,26 @@ function saveMenuOrder(items) {
// 영구삭제 확인
window.confirmForceDelete = function(id, name) {
showPermanentDeleteConfirm(name, () => {
htmx.ajax('DELETE', `/api/admin/menus/${id}/force`, {
target: '#menu-table',
swap: 'none',
fetch(`/api/admin/menus/${id}/force`, {
method: 'DELETE',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
})
.then(response => response.json().then(data => ({ ok: response.ok, data })))
.then(({ ok, data }) => {
if (ok && data.success) {
showToast(data.message || '메뉴가 영구 삭제되었습니다.', 'success');
htmx.trigger('#menu-table', 'filterSubmit');
} else {
showToast(data.message || '삭제에 실패했습니다.', 'error');
}
})
.catch(error => {
showToast('삭제 중 오류가 발생했습니다.', 'error');
console.error('Force delete error:', error);
});
});
};