Implement ID-based routing and folder auto-generation from titles
Major features:
- Switch from slug-based to ID-based routing (/documents/123)
- Enable title editing with automatic slug/path regeneration
- Auto-generate folder structure from title slashes (e.g., Laravel/Livewire/Components)
- Persist sidebar folder open/close state using localStorage
- Remove slug unique constraint (ID routing makes it unnecessary)
- Implement recursive tree view with multi-level folder support
Architecture changes:
- DocumentService: Add generatePathAndSlug() for title-based path generation
- Routes: Change from {document:slug} to {document} for ID binding
- SidebarTree: Extract recursive rendering to partials/tree-item.blade.php
- Database: Remove unique constraint from documents.slug column
UI improvements:
- Display only last path component in sidebar (Components vs Laravel/Livewire/Components)
- Folder state persists across page navigation via localStorage
- Title field accepts slashes for folder organization
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
31
src/resources/views/livewire/sidebar-tree.blade.php
Normal file
31
src/resources/views/livewire/sidebar-tree.blade.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="p-4" x-data="sidebarState()" x-init="initExpandedFolders()">
|
||||
<div class="mb-4">
|
||||
<h2 class="text-sm font-semibold text-gray-700 uppercase tracking-wider">
|
||||
Documents
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
@if(empty($tree))
|
||||
<div class="text-sm text-gray-500 italic">
|
||||
No documents found
|
||||
</div>
|
||||
@else
|
||||
<div class="space-y-1">
|
||||
@include('partials.tree-item', ['tree' => $tree, 'path' => ''])
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@auth
|
||||
<div class="mt-6 pt-6 border-t border-gray-200">
|
||||
<a
|
||||
href="{{ route('documents.create') }}"
|
||||
class="flex items-center justify-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-md hover:bg-indigo-700"
|
||||
>
|
||||
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
|
||||
</svg>
|
||||
New Document
|
||||
</a>
|
||||
</div>
|
||||
@endauth
|
||||
</div>
|
||||
Reference in New Issue
Block a user