mejoras en la gestión de proyectos y documentos: se añaden nuevos campos y validaciones para optimizar la organización y el seguimiento de los mismos.
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
2025-10-25 11:29:20 +02:00
parent 28c225687a
commit d8ae8c8894
29 changed files with 2054 additions and 856 deletions

View File

@@ -1,142 +1,309 @@
<div>
<!-- Header y Breadcrumbs -->
<div class="p-4 bg-white border-b">
<div class="flex items-center justify-between">
<div>
<nav class="flex space-x-2 text-sm">
<a wire:click="currentFolder = null" class="cursor-pointer text-gray-600 hover:text-blue-600">
Inicio
</a>
@foreach($this->breadcrumbs as $folder)
<span class="text-gray-400">/</span>
<a wire:click="selectFolder({{ $folder->id }})"
class="cursor-pointer text-gray-600 hover:text-blue-600">
{{ $folder->name }}
</a>
@endforeach
</nav>
<h1 class="mt-2 text-2xl font-bold">{{ $project->name }}</h1>
<div class="bg-white mb-6 flex content-start justify-between">
<!-- User Info Left -->
<div class="flex space-x-6 content-start">
<!-- Icono -->
<flux:icon.bolt class="w-24 h-24 shadow-lg object-cover border-1 border-gray-600"/>
<!-- Project Details -->
<div class="flex flex-col content-start">
<h1 class="text-2xl font-bold text-gray-700">
{{ $project->name }}
</h1>
<!-- Contact Info -->
<div class="mt-2 ">
<div class="flex items-center text-gray-600">
<p class="text-sm text-gray-700">
{{ $project->reference }}
</p>
</div>
@if($project->phone)
<div class="flex items-center text-gray-600">
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 24 24">
<path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/>
</svg>
<a href="tel:{{ $project->phone }}" class="hover:text-blue-600">
{{ $project->phone }}
</a>
</div>
@endif
</div>
</div>
<a href="{{ route('projects.edit', $project) }}"
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center justify-center">
<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="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/>
</svg>
Editar
</a>
</div>
<!-- Right Section -->
<div class="flex flex-col items-end space-y-4">
<!-- Navigation Toolbar -->
<div class="flex space-x-2">
<flux:button
href="{{ route('projects.index') }}"
icon:trailing="arrow-uturn-left"
variant="ghost"
>
</flux:button>
<flux:button
href="{{ route('projects.index') }}"
icon:trailing="chevron-left"
variant="ghost"
>
</flux:button>
<flux:button
href="{{ route('projects.index') }}"
icon:trailing="chevron-right"
variant="ghost"
>
</flux:button>
</div>
<!-- Status Badge -->
<span class="px-4 py-2 w-30 rounded-lg text-sm text-center font-semibold
{{ $project->is_active ? 'bg-green-600 text-white' : 'bg-red-100 text-red-800' }}">
{{ $project->is_active ? 'Activo' : 'Inactivo' }}
</span>
</div>
</div>
<div wire:loading wire:target="files" class="fixed top-0 right-0 p-4 bg-blue-100 text-blue-800">
Subiendo archivos...
</div>
<!-- Contenedor principal con layout de explorador -->
<div class="flex flex-col h-full">
<!-- Barra de herramientas -->
<div class="flex items-center justify-between p-4 bg-white border-b">
<div class="flex items-center space-x-4">
<!-- Botón Nueva Carpeta -->
<button wire:click="showCreateFolderModal" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" />
</svg>
<span class="text-sm">Nueva carpeta</span>
<!-- Contend: -->
<div x-data="{ activeTab: 'info' }" class="bg-white rounded-lg shadow-md border-1">
<!-- Tab Headers -->
<div class="border-b border-gray-200">
<nav class="flex space-x-8 px-6">
<button @click="activeTab = 'info'"
:class="activeTab === 'info' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
class="py-4 px-1 border-b-2 font-medium">
Project
</button>
<!-- Botón Subir Archivos (versión con button) -->
<div class="relative">
<button
wire:click="openUploadModal"
class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 16.5V9.75m0 0 3 3m-3-3-3 3M6.75 19.5a4.5 4.5 0 0 1-1.41-8.775 5.25 5.25 0 0 1 10.233-2.33 3 3 0 0 1 3.758 3.848A3.752 3.752 0 0 1 18 19.5H6.75Z" />
</svg>
<span class="text-sm">Subir archivos</span>
</button>
</div>
</div>
<button @click="activeTab = 'contacts'"
:class="activeTab === 'contacts' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
class="py-4 px-1 border-b-2 font-medium">
Contactos
</button>
<button @click="activeTab = 'documents'"
:class="activeTab === 'documents' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
class="py-4 px-1 border-b-2 font-medium">
Documentos
</button>
</nav>
</div>
<!-- Contenido principal (treeview + documentos) -->
<div class="flex flex-1 overflow-hidden">
<!-- Treeview de Carpetas -->
<div class="w-64 h-full overflow-y-auto border-r bg-white">
<div class="p-4">
<ul class="space-y-1">
@foreach($project->rootFolders as $folder)
<x-folder-item
:folder="$folder"
:currentFolder="$currentFolder"
:expandedFolders="$expandedFolders"
wire:key="folder-{{ $folder->id }}"
:itemsCount="$this->documents->count()"
/>
@endforeach
</ul>
<!-- Tab Content -->
<div class="p-6">
<!-- Info Tab -->
<div x-show="activeTab === 'info'">
<div class="flex flex-wrap gap-6">
<!-- Columna Izquierda - Información -->
<div class="w-full md:w-[calc(50%-12px)]">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<tbody class="bg-white divide-y divide-gray-200">
@foreach(['name' => 'Nombre', 'last_name' => 'Apellido', 'email' => 'Email', 'phone' => 'Teléfono', 'created_at' => 'Fecha Registro'] as $field => $label)
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{{ $label }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $project->$field ?? 'N/A' }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<!-- Columna Derecha - Descripción del Proyecto -->
<div class="w-full md:w-[calc(50%-12px)]"> <!-- 50% - gap/2 -->
<div class="bg-white p-6 rounded-lg shadow-sm">
<h3 class="whitespace-nowrap text-sm font-medium text-gray-900"">Descripción</h3>
<div class="py-2 prose max-w-none text-gray-500">
{!! $project->description ? $project->description : '<p class="text-gray-400">N/A</p>' !!}
</div>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="mt-6 flex justify-end space-x-4">
<a href="{{ route('projects.edit', $project) }}"
class="w-[150px] px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center justify-center">
<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="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/>
</svg>
Editar
</a>
{{-- Formulario de Edición --}}
<form method="POST" action="{{ route('projects.update', $project) }}">
@csrf
@method('PUT') <!-- Important! -->
<button type="submit"
class="w-[150px] px-4 py-2 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg flex items-center justify-center">
<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="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
</svg>
{{ $project->is_active ? 'Desactivar' : 'Activar' }}
</button>
</form>
{{-- Formulario de Eliminación --}}
<form method="POST" action="{{ route('projects.destroy', $project) }}">
@csrf
@method('DELETE') <!-- Important! -->
<button type="submit"
onclick="return confirm('¿Estás seguro de querer eliminar este usuario?')"
class="px-4 py-2 w-[150px] bg-red-600 hover:bg-red-700 text-white rounded-lg flex items-center justify-center">
<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="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
</svg>
Eliminar
</button>
</form>
</div>
</div>
<!-- Contact Tab -->
<div x-show="activeTab === 'contacts'" x-cloak>
</div>
<!-- Documentos -->
<div class="flex-1 overflow-auto bg-white">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50 sticky top-0">
<tr>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Nombre - javi</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Versiones</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Última Actualización</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Estado</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($this->documents as $document)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<a href="{{ route('documents.show', $document) }}"
target="_blank"
class="flex items-center hover:text-blue-600 transition-colors">
@php
$type = App\Helpers\FileHelper::getFileType($document->name);
$iconComponent = $iconComponent = "icons." . $type;
$iconClass = [
'pdf' => 'pdf text-red-500',
'word' => 'word text-blue-500',
'excel' => 'excel text-green-500',
// ... agregar todos los tipos
][$type] ?? 'document text-gray-400';
@endphp
<x-dynamic-component
component="{{ $iconComponent }}"
class="w-5 h-5 mr-2 {{ explode(' ', $iconClass)[1] }}"
/>
{{ $document->name }}
</a>
<!-- Permissions Tab -->
<div x-show="activeTab === 'documents'" x-cloak>
<!-- Contenedor principal con layout de explorador -->
<div class="flex flex-col h-full">
<!-- Barra de herramientas -->
<div class="flex items-center justify-between p-2 bg-white border-b">
<div class="flex items-center space-x-4">
<!-- Botón Nueva Carpeta -->
<button wire:click="showCreateFolderModal" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" />
</svg>
<span class="text-sm">Nueva carpeta</span>
</button>
<!-- Botón Subir Archivos (versión con button) -->
<div class="relative">
<button
wire:click="openUploadModal"
class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 16.5V9.75m0 0 3 3m-3-3-3 3M6.75 19.5a4.5 4.5 0 0 1-1.41-8.775 5.25 5.25 0 0 1 10.233-2.33 3 3 0 0 1 3.758 3.848A3.752 3.752 0 0 1 18 19.5H6.75Z" />
</svg>
<span class="text-sm">Subir archivos</span>
</button>
</div>
</div>
</div>
<!-- Contenido principal (treeview + documentos) -->
<div class="flex flex-1 overflow-hidden">
<!-- Treeview de Carpetas -->
<div class="w-64 h-full overflow-y-auto border bg-white">
<div class="">
<ul class="space-y-1">
@foreach($project->rootFolders as $folder)
<x-folder-item
:folder="$folder"
:currentFolder="$currentFolder"
:expandedFolders="$expandedFolders"
wire:key="folder-{{ $folder->id }}"
:itemsCount="$this->documents->count()"
/>
@endforeach
</ul>
</div>
</div>
<!-- Documentos -->
<div class="flex-1 overflow-auto bg-white">
<div class="p-2 bg-white border-b">
<div class="flex items-center justify-between">
<div>
<nav class="flex space-x-2 text-sm">
<a wire:click="currentFolder = null" class="flex cursor-pointer text-gray-600 hover:text-blue-600">
<flux:icon.home class="w-4 h-4"/> Inicio
</a>
@foreach($this->breadcrumbs as $folder)
<span class="text-gray-400">/</span>
<a wire:click="selectFolder({{ $folder->id }})"
class="cursor-pointer text-gray-600 hover:text-blue-600">
{{ $folder->name }}
</a>
@endforeach
</nav>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
{{ $document->versions_count }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
{{ $document->updated_at->diffForHumans() }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
<x-status-badge :status="$document->status" />
</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
No se encontraron documentos en esta carpeta
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50 sticky top-0">
<tr>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Nombre - javi</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Versiones</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Última Actualización</th>
<th class="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">Estado</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($this->documents as $document)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<a href="{{ route('documents.show', $document) }}"
target="_blank"
class="flex items-center hover:text-blue-600 transition-colors">
@php
$type = App\Helpers\FileHelper::getFileType($document->name);
$iconComponent = $iconComponent = "icons." . $type;
$iconClass = [
'pdf' => 'pdf text-red-500',
'word' => 'word text-blue-500',
'excel' => 'excel text-green-500',
// ... agregar todos los tipos
][$type] ?? 'document text-gray-400';
@endphp
<x-dynamic-component
component="{{ $iconComponent }}"
class="w-5 h-5 mr-2 {{ explode(' ', $iconClass)[1] }}"
/>
{{ $document->name }}
</a>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
{{ $document->versions_count }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
{{ $document->updated_at->diffForHumans() }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
<x-status-badge :status="$document->status" />
</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
No se encontraron documentos en esta carpeta
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>