8c774d075d
- Notificaciones (DB): asignación de incidencia (IssueAssigned), asignación de tarea (IssueTaskAssigned), comentario (IssueCommented) y cambio de estado (IssueStatusChanged) a reporter+asignado excluyendo al actor. - Plantillas de checklist: tabla issue_checklist_templates + modelo, gestor CRUD (IssueChecklistManager, ruta projects.issues.checklists) y "Aplicar plantilla" en el detalle (alta masiva de tareas). - Alertas de vencimiento: columna overdue_notified_at + scope overdue, comando issues:notify-overdue (programado a diario) que avisa al asignado una sola vez; badge "vencidas" en la tabla y resaltado por tarea en el detalle. - Reporte desde el mapa: botón "Incidencia" en el panel del feature seleccionado → formulario con feature pre-vinculado (IssueForm lee ?feature=). Tests: IssuesEnhancementsTest (7). Suite 57 passing (solo 2 pre-existentes sqlite). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
110 lines
3.0 KiB
PHP
110 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\IssueChecklistTemplate;
|
|
use App\Models\Project;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Component;
|
|
|
|
#[Layout('layouts.app')]
|
|
class IssueChecklistManager extends Component
|
|
{
|
|
public Project $project;
|
|
public $templates = [];
|
|
|
|
public bool $showForm = false;
|
|
public $editingId = null;
|
|
public string $name = '';
|
|
public array $items = [''];
|
|
|
|
public function mount(Project $project)
|
|
{
|
|
$this->project = $project;
|
|
abort_unless($this->canAccessProject() && Auth::user()->can('edit issues'), 403);
|
|
$this->loadTemplates();
|
|
}
|
|
|
|
private function canAccessProject(): bool
|
|
{
|
|
$user = Auth::user();
|
|
return $user->can('manage all')
|
|
|| $this->project->users()->where('user_id', $user->id)->exists();
|
|
}
|
|
|
|
public function loadTemplates(): void
|
|
{
|
|
$this->templates = IssueChecklistTemplate::where('project_id', $this->project->id)
|
|
->orderBy('name')->get();
|
|
}
|
|
|
|
public function newTemplate(): void
|
|
{
|
|
$this->reset(['editingId', 'name']);
|
|
$this->items = [''];
|
|
$this->resetErrorBag();
|
|
$this->showForm = true;
|
|
}
|
|
|
|
public function edit($id): void
|
|
{
|
|
$t = IssueChecklistTemplate::where('project_id', $this->project->id)->findOrFail($id);
|
|
$this->editingId = $t->id;
|
|
$this->name = $t->name;
|
|
$this->items = array_values($t->items ?: ['']) ?: [''];
|
|
$this->resetErrorBag();
|
|
$this->showForm = true;
|
|
}
|
|
|
|
public function addItemLine(): void
|
|
{
|
|
$this->items[] = '';
|
|
}
|
|
|
|
public function removeItemLine(int $i): void
|
|
{
|
|
unset($this->items[$i]);
|
|
$this->items = array_values($this->items);
|
|
if (empty($this->items)) {
|
|
$this->items = [''];
|
|
}
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$this->validate([
|
|
'name' => 'required|string|max:255',
|
|
'items' => 'required|array',
|
|
'items.*' => 'nullable|string|max:255',
|
|
]);
|
|
|
|
$items = array_values(array_filter(array_map('trim', $this->items), fn ($v) => $v !== ''));
|
|
if (empty($items)) {
|
|
$this->addError('items', 'Añade al menos una tarea.');
|
|
return;
|
|
}
|
|
|
|
IssueChecklistTemplate::updateOrCreate(
|
|
['id' => $this->editingId, 'project_id' => $this->project->id],
|
|
['name' => $this->name, 'items' => $items, 'project_id' => $this->project->id],
|
|
);
|
|
|
|
$this->showForm = false;
|
|
$this->loadTemplates();
|
|
$this->dispatch('notify', 'Plantilla guardada');
|
|
}
|
|
|
|
public function delete($id): void
|
|
{
|
|
IssueChecklistTemplate::where('project_id', $this->project->id)->findOrFail($id)->delete();
|
|
$this->loadTemplates();
|
|
$this->dispatch('notify', 'Plantilla eliminada');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.issues.issue-checklist-manager');
|
|
}
|
|
}
|