Files
glastree/resources/views/documenti/_folder_tree.blade.php
T

44 lines
2.3 KiB
PHP
Raw Normal View History

2026-05-28 09:34:28 +02:00
@props(['cartelle', 'currentFolderId' => null, 'level' => 0, 'canWrite' => false, 'canDelete' => false])
@foreach($cartelle as $cartella)
@php
$isActive = $currentFolderId && (int) $currentFolderId === (int) $cartella->id;
$hasChildren = $cartella->children->count() > 0;
@endphp
<div class="list-group-item d-flex align-items-center py-1 px-2 {{ $isActive ? 'active' : '' }}"
style="padding-left: {{ 20 + $level * 20 }}px !important;">
<a href="/documenti?folder_id={{ $cartella->id }}"
class="d-flex align-items-center text-decoration-none flex-grow-1 {{ $isActive ? 'text-white' : '' }}"
style="min-width: 0;">
<i class="fas fa-folder {{ $isActive ? 'text-white' : 'text-warning' }} mr-2"></i>
<span class="small text-truncate">{{ $cartella->nome }}</span>
</a>
@if($canWrite || $canDelete)
<div class="folder-actions ml-1 flex-shrink-0">
@if($canWrite)
<button type="button" class="btn btn-xs btn-link p-0 mr-1" onclick='event.stopPropagation(); renameFolder({{ $cartella->id }}, {{ json_encode($cartella->nome) }})' title="Rinomina">
<i class="fas fa-pen {{ $isActive ? 'text-white' : 'text-muted' }}"></i>
</button>
<button type="button" class="btn btn-xs btn-link p-0 mr-1" onclick='event.stopPropagation(); moveFolder({{ $cartella->id }}, {{ json_encode($cartella->nome) }})' title="Sposta">
<i class="fas fa-folder-open {{ $isActive ? 'text-white' : 'text-info' }}"></i>
</button>
@endif
@if($canDelete)
<button type="button" class="btn btn-xs btn-link p-0" onclick='event.stopPropagation(); deleteFolder({{ $cartella->id }}, {{ json_encode($cartella->nome) }})' title="Elimina">
<i class="fas fa-times {{ $isActive ? 'text-white' : 'text-danger' }}"></i>
</button>
@endif
</div>
@endif
</div>
@if($hasChildren)
@include('documenti._folder_tree', [
'cartelle' => $cartella->children,
'currentFolderId' => $currentFolderId,
'level' => $level + 1,
'canWrite' => $canWrite,
'canDelete' => $canDelete,
])
@endif
@endforeach