@extends('layouts.app') @section('title', $project->name . ' — 文件庫') @push('styles') @endpush @section('content') @include('projects._nav') @php $allProjectDocs = $project->docs() ->where('type', $docType) ->where('file_type', '!=', 'folder') ->with('author') ->orderBy('updated_at', 'desc') ->get(['id','title','file_type','updated_at','user_id']) ->map(fn($d) => [ 'id' => $d->id, 'title' => $d->title, 'type' => $d->file_type, 'updated' => $d->updated_at ? $d->updated_at->format('Y-m-d') : '', 'url' => route("{$routePrefix}.show", [$project, $d]), 'owner' => $d->author?->name ?? '—', ])->values(); @endphp
{{-- ── Sidebar ──────────────────────────────────────────────────── --}}
{{-- +新增 button (Google Drive style) --}} @can('contributeDoc', $project)
@endcan {{-- My project folder + tree --}} 我的專案資料夾 @php function renderTree($folders, $parentId, $routePrefix, $project, $folderId, $depth = 0) { $kids = $folders->where('parent_id', $parentId)->values(); foreach ($kids as $f) { $active = $folderId == $f->id ? 'active' : ''; $pl = 22 + $depth * 14; echo ' $f->id]) . '"' . ' class="tree-item ' . $active . '"' . ' style="padding-left:' . $pl . 'px"' . ' data-folder-id="' . $f->id . '"' . ' ondragover="sidebarDragOver(event,this)"' . ' ondragleave="sidebarDragLeave(this)"' . ' ondrop="sidebarDrop(event,this)">' . '' . '' . e($f->title) . '' . ''; renderTree($folders, $f->id, $routePrefix, $project, $folderId, $depth + 1); } } renderTree($allFolders, null, $routePrefix, $project, $folderId); @endphp 近期存取 我的最愛
{{-- ── Main ────────────────────────────────────────────────────── --}}
拖拉檔案至此上傳
@if(session('success'))
{{ session('success') }}
@endif
{{-- Section title --}}
@if($currentFolder) 我的專案資料夾 @foreach($breadcrumb as $crumb) @if(!$loop->last) $crumb->id]) }}" style="color:var(--bs-secondary-color);font-size:.95rem;text-decoration:none;">{{ $crumb->title }} @else {{ $crumb->title }} @endif @endforeach @else 我的專案資料夾 @endif
{{-- Filter chips + view toggle --}}
{{-- ── Content ──────────────────────────────────────────────── --}} @if($items->isEmpty())
此資料夾是空的 @can('contributeDoc', $project)
點擊上方按鈕新增文件或資料夾 @endcan
@else @php $folders = $items->where('file_type', 'folder'); $files = $items->where('file_type', '!=', 'folder'); @endphp {{-- ===== GRID VIEW ===== --}} {{-- ===== LIST VIEW (Google Drive style) ===== --}}
{{-- Header --}}
名稱
位置
類型
擁有者
修改日期
@foreach($items as $item) @php $isFolder = $item->file_type === 'folder'; $isSheet = $item->file_type === 'spreadsheet'; $isFile2 = $item->file_type === 'file'; $isPres2 = $item->file_type === 'presentation'; $isMind2 = $item->file_type === 'mindmap'; $isDraw2 = $item->file_type === 'drawing'; $typeLabel = $isFolder ? '資料夾' : ($isFile2 ? '附件' : ($isSheet ? '試算表' : ($isPres2 ? '簡報' : ($isMind2 ? '心智圖' : ($isDraw2 ? '繪圖' : '文件'))))); $ownerLabel = $item->author?->name ?? '—'; $locationLabel = $currentFolder ? $currentFolder->title : '我的專案資料夾'; @endphp
{{-- Name --}}
@if($isFolder) @elseif($isFile2) @elseif($isSheet) @elseif($isPres2) @elseif($isMind2) @elseif($isDraw2) @else @endif
{{ $item->title }}
{{-- Location --}}
{{ $locationLabel }}
{{-- Type --}}
{{ $typeLabel }}
{{-- Owner --}}
{{ $ownerLabel }}
{{-- Date --}}
{{ $item->updated_at->format('Y-m-d') }}
{{-- Actions --}}
@if(!$isFolder && $isFile2) @php $isPlainText2 = in_array(strtolower(pathinfo($item->title, PATHINFO_EXTENSION)), ['txt','md'], true); @endphp @if($isPlainText2) 編輯 @else 預覽 @endif @endif @if(!$isFolder) {{ $isFile2 ? '下載' : '編輯' }} @endif @can('contributeDoc', $project)
@csrf @method('DELETE')
@endcan
@endforeach
@endif
{{-- #mainContent --}} {{-- Filtered view (favorites / recent) --}}

{{-- Column filter dropdown (shared, positioned fixed) --}}
{{-- New Folder Modal --}} @can('contributeDoc', $project) @endcan {{-- 右鍵選單 --}} {{-- 共用連結 modal(右鍵選單用,動態填內容) --}} @endsection {{-- Upload progress toast --}}
上傳中…
@push('scripts') @endpush