Files
muninn/resources/views/livewire/tasks/index.blade.php
T
m105andClaude Sonnet 5 a4ff6c0ccb Commit the Projects/Tasks/Ideas/TaskComments feature
This was already implemented, migrated, and running live, but had
never been committed. Bringing it into git: Project/Task/Idea/
TaskComment models, their JSON API (CRUD + status transitions,
task comments, idea<->project linking), Livewire UI pages, and the
nav/route wiring for them. All 42 of its own tests pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-06 20:41:57 +03:00

237 lines
12 KiB
PHP

<div>
<div class="flex justify-between items-center mb-4">
<div>
<h1 class="text-xl font-semibold">Tasks</h1>
<p class="text-sm text-gray-500">
{{ $totalTasks }} total |
{{ $todoTasks }} todo |
{{ $inProgressTasks }} in progress |
{{ $doneTasks }} done |
{{ $blockedTasks }} blocked |
{{ $waitingReviewTasks }} waiting review
</p>
@if($dueSoonTasks > 0 || $overdueTasks > 0)
<p class="text-sm text-gray-500">
@if($dueSoonTasks > 0)
<span class="text-orange-600">{{ $dueSoonTasks }} due soon</span>
@endif
@if($overdueTasks > 0)
<span class="text-red-600">{{ $overdueTasks }} overdue</span>
@endif
</p>
@endif
</div>
<div class="flex gap-2">
<button wire:click="create" class="bg-blue-600 text-white px-4 py-2 rounded">Add Task</button>
</div>
</div>
<div class="bg-white border border-gray-200 rounded p-4 mb-6">
<div class="flex gap-4 items-center flex-wrap">
<div class="flex-1 min-w-48">
<label class="block text-sm font-medium mb-1">Search</label>
<input type="text" wire:model.live="search" placeholder="Search tasks..."
class="w-full border rounded p-2">
</div>
<div>
<label class="block text-sm font-medium mb-1">Project</label>
<select wire:model.live="projectFilter" class="border rounded p-2">
<option value="">All Projects</option>
@foreach ($projects as $project)
<option value="{{ $project->id }}">{{ $project->name }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium mb-1">Status</label>
<select wire:model.live="statusFilter" class="border rounded p-2">
<option value="">All Statuses</option>
@foreach ($statuses as $status)
<option value="{{ $status }}">{{ ucfirst(str_replace('_', ' ', $status)) }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium mb-1">Priority</label>
<select wire:model.live="priorityFilter" class="border rounded p-2">
<option value="">All Priorities</option>
<option value="0">None (0)</option>
<option value="1">Low (1-3)</option>
<option value="4">Medium (4-6)</option>
<option value="7">High (7-8)</option>
<option value="9">Critical (9-10)</option>
</select>
</div>
<div class="flex items-end">
<button wire:click="clearFilters" class="text-sm text-gray-600 hover:text-gray-800">Clear</button>
</div>
</div>
</div>
<div class="bg-white border border-gray-200 rounded overflow-hidden">
<table class="w-full">
<thead class="bg-gray-50">
<tr class="text-left">
<th class="p-3">Task</th>
<th class="p-3">Project</th>
<th class="p-3">Status</th>
<th class="p-3">Priority</th>
<th class="p-3">Due</th>
<th class="p-3">Time</th>
<th class="p-3">Comments</th>
<th class="p-3 text-right">Actions</th>
</tr>
</thead>
<tbody>
@forelse ($tasks as $task)
<tr wire:key="task-{{ $task->id }}" class="border-b border-gray-100 hover:bg-gray-50">
<td class="p-3">
<div class="font-medium">{{ $task->title }}</div>
@if($task->description)
<div class="text-xs text-gray-500 truncate max-w-48">{{ $task->description }}</div>
@endif
</td>
<td class="p-3">
@if($task->project)
<span class="text-blue-600 hover:underline cursor-pointer"
wire:click="$set('projectFilter', {{ $task->project->id }})">
{{ $task->project->name }}
</span>
@else
<span class="text-gray-400">—</span>
@endif
</td>
<td class="p-3">
<select wire:model="status" wire:change="changeStatus({{ $task->id }}, $event.target.value)"
class="{{ $this->getStatusColor($task->status) }} rounded p-1 text-sm">
@foreach ($statuses as $status)
<option value="{{ $status }}" {{ $task->status === $status ? 'selected' : '' }}>
{{ ucfirst(str_replace('_', ' ', $status)) }}
</option>
@endforeach
</select>
</td>
<td class="p-3">
<span class="text-sm">
{{ $this->getPriorityLabel($task->priority) }}
@if($task->priority > 0)
({{ $task->priority }})
@endif
</span>
</td>
<td class="p-3">
@if($task->due_at)
<span class="@if($task->due_at < now() && $task->status !== 'done') text-red-600 @endif">
{{ $task->due_at->format('M d') }}
</span>
@else
<span class="text-gray-400">—</span>
@endif
</td>
<td class="p-3 text-sm">
@if($task->estimated_hours)
<span title="Estimated">{{ $task->estimated_hours }}h</span>
@endif
@if($task->actual_hours)
<span title="Actual" class="ml-1">{{ $task->actual_hours }}h</span>
@endif
@if(!$task->estimated_hours && !$task->actual_hours)
<span class="text-gray-400">—</span>
@endif
</td>
<td class="p-3 text-center">
<span class="bg-gray-100 text-gray-800 text-xs px-2 py-0.5 rounded">
{{ $this->getCommentsCount($task->id) }}
</span>
</td>
<td class="p-3 text-right space-x-1">
<button wire:click="edit({{ $task->id }})" class="text-blue-600 hover:text-blue-800 text-sm">Edit</button>
<button wire:click="delete({{ $task->id }})" wire:confirm="Delete this task?" class="text-red-600 hover:text-red-800 text-sm">Delete</button>
<a href="{{ route('task-comments.index', ['task_id' => $task->id]) }}"
class="text-purple-600 hover:text-purple-800 text-sm">Comments</a>
</td>
</tr>
@empty
<tr>
<td colspan="8" class="p-6 text-center text-gray-500">
No tasks found. Create your first task!
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if ($showForm)
<div class="fixed inset-0 bg-black/30 flex items-center justify-center z-50">
<div class="bg-white p-6 rounded w-full max-w-lg space-y-4 max-h-[90vh] overflow-y-auto">
<h2 class="text-lg font-semibold">{{ $editingId ? 'Edit Task' : 'Add Task' }}</h2>
<div>
<label class="block text-sm font-medium">Title</label>
<input type="text" wire:model="title" class="w-full border rounded p-2">
@error('title') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Description</label>
<textarea wire:model="description" rows="4" class="w-full border rounded p-2"></textarea>
@error('description') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Project</label>
<select wire:model="projectId" class="w-full border rounded p-2">
<option value="">No Project</option>
@foreach ($projects as $project)
<option value="{{ $project->id }}">{{ $project->name }}</option>
@endforeach
</select>
@error('projectId') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium">Status</label>
<select wire:model="status" class="w-full border rounded p-2">
@foreach ($statuses as $status)
<option value="{{ $status }}">{{ ucfirst(str_replace('_', ' ', $status)) }}</option>
@endforeach
</select>
@error('status') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Priority (0-10)</label>
<input type="number" wire:model="priority" min="0" max="10" class="w-full border rounded p-2">
@error('priority') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium">Due Date</label>
<input type="datetime-local" wire:model="dueAt" class="w-full border rounded p-2">
@error('dueAt') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Estimated Hours</label>
<input type="number" wire:model="estimatedHours" step="0.1" min="0" class="w-full border rounded p-2">
@error('estimatedHours') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
</div>
<div>
<label class="block text-sm font-medium">Actual Hours</label>
<input type="number" wire:model="actualHours" step="0.1" min="0" class="w-full border rounded p-2">
@error('actualHours') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div class="flex justify-end gap-2">
<button wire:click="$set('showForm', false)" class="px-4 py-2">Cancel</button>
<button wire:click="save" class="bg-blue-600 text-white px-4 py-2 rounded">Save</button>
</div>
</div>
</div>
@endif
</div>