Files
sam-manage/resources/views/menus/index.blade.php
hskwon 2a9b697baf UI 개선: 테넌트 선택 헤더 이동 및 역할 권한 관리 개선
- 테넌트 선택을 각 페이지에서 헤더로 통합 이동
- 페이지 제목 이모지 제거 및 상단 여백(mt-6) 축소
- 역할 권한 관리 페이지 레이아웃을 다른 페이지와 통일
- 메뉴명 스타일 개선 (depth 들여쓰기, └ 기호 적용)
- 상위 메뉴 컬럼 제거로 테이블 간소화
- RolePermissionService에 depth 계산 로직 추가
- pagination.js를 body 끝으로 이동하여 로딩 오류 해결
- 역할 선택 UI를 셀렉트박스에서 버튼 형태로 변경
- 역할 버튼 hover 효과 개선 (선택된 버튼 가독성 향상)

변경된 파일:
- resources/views/partials/header.blade.php: 테넌트 선택 UI 추가
- resources/views/dashboard|menus|users|departments|permissions|roles/index.blade.php: tenant-selector 제거, 여백 축소
- resources/views/layouts/app.blade.php: pagination.js 위치 변경
- app/Services/RolePermissionService.php: depth 계산 로직 추가
- resources/views/role-permissions/: 역할 권한 관리 페이지 개선
- routes/web.php, routes/api.php: 역할 권한 관리 라우트 추가
2025-11-25 15:21:48 +09:00

192 lines
6.8 KiB
PHP

@extends('layouts.app')
@section('title', '메뉴 관리')
@section('content')
<!-- 페이지 헤더 -->
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-800">메뉴 관리</h1>
<a href="{{ route('menus.create') }}" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition">
+ 메뉴
</a>
</div>
<!-- 필터 영역 -->
<div class="bg-white rounded-lg shadow-sm p-4 mb-6">
<form id="filterForm" class="flex gap-4">
<!-- 검색 -->
<div class="flex-1">
<input type="text"
name="search"
placeholder="메뉴명, URL로 검색..."
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<!-- 활성 상태 필터 -->
<div class="w-48">
<select name="is_active" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="">전체 상태</option>
<option value="1">활성</option>
<option value="0">비활성</option>
</select>
</div>
<!-- 검색 버튼 -->
<button type="submit" class="bg-gray-600 hover:bg-gray-700 text-white px-6 py-2 rounded-lg transition">
검색
</button>
</form>
</div>
<!-- 테이블 영역 (HTMX로 로드) -->
<div id="menu-table"
hx-get="/api/admin/menus"
hx-trigger="load, filterSubmit from:body"
hx-include="#filterForm"
hx-headers='{"X-CSRF-TOKEN": "{{ csrf_token() }}"}'
class="bg-white rounded-lg shadow-sm overflow-hidden">
<!-- 로딩 스피너 -->
<div class="flex justify-center items-center p-12">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
</div>
</div>
@endsection
@push('scripts')
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
<script>
// 폼 제출 시 HTMX 이벤트 트리거
document.getElementById('filterForm').addEventListener('submit', function(e) {
e.preventDefault();
htmx.trigger('#menu-table', 'filterSubmit');
});
// HTMX 응답 처리
document.body.addEventListener('htmx:afterSwap', function(event) {
if (event.detail.target.id === 'menu-table') {
const response = JSON.parse(event.detail.xhr.response);
if (response.html) {
event.detail.target.innerHTML = response.html;
}
}
});
// 삭제 확인
window.confirmDelete = function(id, name) {
if (confirm(`"${name}" 메뉴를 삭제하시겠습니까?`)) {
htmx.ajax('DELETE', `/api/admin/menus/${id}`, {
target: '#menu-table',
swap: 'none',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
});
}
};
// 복원 확인
window.confirmRestore = function(id, name) {
if (confirm(`"${name}" 메뉴를 복원하시겠습니까?`)) {
htmx.ajax('POST', `/api/admin/menus/${id}/restore`, {
target: '#menu-table',
swap: 'none',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
});
}
};
// 영구삭제 확인
window.confirmForceDelete = function(id, name) {
if (confirm(`⚠️ 경고: "${name}" 메뉴를 영구 삭제하시겠습니까?\n\n이 작업은 되돌릴 수 없습니다!`)) {
htmx.ajax('DELETE', `/api/admin/menus/${id}/force`, {
target: '#menu-table',
swap: 'none',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
});
}
};
// 활성 토글
window.toggleActive = function(id) {
htmx.ajax('POST', `/api/admin/menus/${id}/toggle-active`, {
target: '#menu-table',
swap: 'none',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
});
};
// 숨김 토글
window.toggleHidden = function(id) {
htmx.ajax('POST', `/api/admin/menus/${id}/toggle-hidden`, {
target: '#menu-table',
swap: 'none',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}).then(() => {
htmx.trigger('#menu-table', 'filterSubmit');
});
};
// 자식 메뉴 접기/펼치기
window.toggleChildren = function(menuId) {
const button = document.querySelector(`.toggle-btn[data-menu-id="${menuId}"]`);
const svg = button.querySelector('svg');
const isCollapsed = svg.classList.contains('rotate-[-90deg]');
if (isCollapsed) {
// 펼치기
svg.classList.remove('rotate-[-90deg]');
showChildren(menuId);
} else {
// 접기
svg.classList.add('rotate-[-90deg]');
hideChildren(menuId);
}
};
// 재귀적으로 자식 메뉴 숨기기
function hideChildren(parentId) {
const children = document.querySelectorAll(`tr.menu-row[data-parent-id="${parentId}"]`);
children.forEach(child => {
child.style.display = 'none';
const childId = child.getAttribute('data-menu-id');
// 하위의 하위도 숨기기
hideChildren(childId);
});
}
// 재귀적으로 직계 자식만 표시
function showChildren(parentId) {
const children = document.querySelectorAll(`tr.menu-row[data-parent-id="${parentId}"]`);
children.forEach(child => {
child.style.display = '';
// 하위 메뉴는 해당 메뉴가 펼쳐져 있을 때만 표시
const childId = child.getAttribute('data-menu-id');
const childButton = child.querySelector(`.toggle-btn[data-menu-id="${childId}"]`);
if (childButton) {
const childSvg = childButton.querySelector('svg');
// 자식이 접혀있으면 그 하위는 보여주지 않음
if (!childSvg.classList.contains('rotate-[-90deg]')) {
showChildren(childId);
}
}
});
}
</script>
@endpush