@extends('layouts.dashboard') @section('title', 'Proj Mgr - Task List Templates') @section('content') @php $priorityOrder = ['urgent' => 0, 'high' => 1, 'medium' => 2, 'low' => 3]; // Tree for "Add Existing Tasks" picker: Project -> Task List -> Tasks $treeData = []; foreach ($projects as $proj) { $projNode = ['id' => $proj->id, 'name' => $proj->name, 'lists' => []]; $sortedLists = $proj->taskLists->sortBy('name'); foreach ($sortedLists as $list) { $listNode = ['id' => $list->id, 'name' => $list->name, 'tasks' => []]; $sortedTasks = $list->tasks->sortBy([ fn($t) => $priorityOrder[$t->priority ?? 'medium'] ?? 2, fn($t) => strtolower($t->title ?? ''), ]); foreach ($sortedTasks as $task) { $listNode['tasks'][] = [ 'id' => $task->id, 'title' => $task->title ?? '', 'description' => $task->description ?? '', 'priority' => $task->priority ?? 'medium', 'estimated_hours' => $task->estimated_hours ?? '', 'task_type' => $task->task_type ?? 'general', 'status' => $task->task_status ?? 'pending', 'projectName' => $proj->name, 'listName' => $list->name, ]; } if (!empty($listNode['tasks'])) { $projNode['lists'][] = $listNode; } } if (!empty($projNode['lists'])) { $treeData[] = $projNode; } } usort($treeData, fn($a, $b) => strcasecmp($a['name'], $b['name'])); @endphp
Back

Task List Templates

@php $colorOptions = [ ['value' => 'bg-blue-100', 'label' => 'Blue'], ['value' => 'bg-green-100', 'label' => 'Green'], ['value' => 'bg-yellow-100', 'label' => 'Yellow'], ['value' => 'bg-red-100', 'label' => 'Red'], ['value' => 'bg-purple-100', 'label' => 'Purple'], ['value' => 'bg-indigo-100', 'label' => 'Indigo'], ['value' => 'bg-pink-100', 'label' => 'Pink'], ['value' => 'bg-gray-100', 'label' => 'Gray'], ]; @endphp
@foreach($colorOptions as $color) @endforeach
Add Tasks to Template ( selected)
Selected
task(s) selected

No tasks yet. Click Add Existing Tasks to pick tasks for this template.

@if($templates->count() === 0)

No Task List Templates Yet

Create templates to quickly scaffold task lists with predefined tasks and structure.

@else
@foreach($templates as $template) @php $templateTasks = $template->tasks ?? []; $taskCount = count($templateTasks); $priBadge = fn($p) => match($p ?? 'medium') { 'urgent' => 'bg-red-100 text-red-800 border-red-200', 'high' => 'bg-orange-100 text-orange-800 border-orange-200', 'medium' => 'bg-yellow-100 text-yellow-800 border-yellow-200', default => 'bg-green-100 text-green-800 border-green-200', }; @endphp
{{ $template->name }} {{ $taskCount }} {{ Str::plural('task', $taskCount) }}
@if($template->description)

{{ $template->description }}

@endif
@csrf @method('DELETE')
@if($taskCount > 0)
@foreach($templateTasks as $tTask) @php $typeEmoji = match($tTask['task_type'] ?? 'general') { 'equipmentId' => '🔧', 'customerName' => '👤', default => '📝', }; @endphp
{{ $typeEmoji }} {{ $tTask['title'] }} {{ ucfirst($tTask['priority'] ?? 'medium') }} @if(!empty($tTask['estimated_hours'])) {{ $tTask['estimated_hours'] }}h @endif
@endforeach
@endif
@endforeach
@endif
@endsection