From 36daf862b1290f3cd50cf5a0972153a2cc71f86d Mon Sep 17 00:00:00 2001 From: hskwon Date: Tue, 9 Dec 2025 23:11:17 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EC=98=81=EA=B5=AC?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 메뉴 영구삭제 시 연관 권한도 함께 삭제 - 삭제 정보를 archived_records에 저장 (복구용) - 메뉴 데이터, 권한 목록, 역할-권한 연결 정보 보관 - batch_id를 순수 UUID로 변경 (컬럼 크기 제한 해결) - 영구삭제 시 에러 메시지 토스트로 표시 (하위 메뉴 존재 등) - 글로벌 메뉴 영구삭제 시 참조 테넌트 메뉴 연결 해제 --- app/Services/MenuService.php | 8 +++---- resources/views/menus/global-index.blade.php | 24 +++++++++++++++----- resources/views/menus/index.blade.php | 24 +++++++++++++++----- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/app/Services/MenuService.php b/app/Services/MenuService.php index 3868399c..3746bb44 100644 --- a/app/Services/MenuService.php +++ b/app/Services/MenuService.php @@ -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, diff --git a/resources/views/menus/global-index.blade.php b/resources/views/menus/global-index.blade.php index fec76682..570ec817 100644 --- a/resources/views/menus/global-index.blade.php +++ b/resources/views/menus/global-index.blade.php @@ -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); }); }); }; diff --git a/resources/views/menus/index.blade.php b/resources/views/menus/index.blade.php index 260f2e62..93afb9c3 100644 --- a/resources/views/menus/index.blade.php +++ b/resources/views/menus/index.blade.php @@ -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); }); }); };