feat(issues): notificaciones, plantillas de checklist, alertas de vencimiento y reporte desde el mapa

- 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>
This commit is contained in:
2026-06-18 12:51:41 +02:00
parent 3f240e5277
commit 8c774d075d
22 changed files with 818 additions and 15 deletions
+16
View File
@@ -4,6 +4,7 @@ namespace App\Livewire;
use App\Models\Issue;
use App\Models\Project;
use App\Notifications\IssueAssignedNotification;
use App\Notifications\IssueReportedNotification;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Layout;
@@ -28,6 +29,7 @@ class IssueForm extends Component
// Optional context (e.g. when reporting from a map feature)
public $featureId = null;
public $inspectionId = null;
public $featureName = null; // shown when the issue is pre-linked to a map element
public function mount(Project $project, ?Issue $issue = null)
{
@@ -50,6 +52,14 @@ class IssueForm extends Component
$this->resolutionNotes = $issue->resolution_notes ?? '';
$this->featureId = $issue->feature_id;
$this->inspectionId = $issue->inspection_id;
$this->featureName = $issue->feature?->name;
} elseif ($featureId = request()->integer('feature')) {
// Pre-link to a map element when reporting from the project map.
$feature = \App\Models\Feature::with('layer.phase')->find($featureId);
if ($feature && $feature->layer?->phase?->project_id === $project->id) {
$this->featureId = $feature->id;
$this->featureName = $feature->name;
}
}
}
@@ -92,12 +102,18 @@ class IssueForm extends Component
$payload['resolved_at'] = in_array($this->status, ['resolved', 'closed']) ? now() : null;
if ($this->issue) {
$previousAssignee = $this->issue->assigned_to;
// Don't overwrite an existing resolved date
if ($this->issue->resolved_at && in_array($this->status, ['resolved', 'closed'])) {
unset($payload['resolved_at']);
}
$this->issue->update($payload);
$issue = $this->issue;
// Notify a newly assigned user (when it changed and isn't the current actor).
if ($issue->assigned_to && $issue->assigned_to !== $previousAssignee && $issue->assigned_to !== Auth::id()) {
$issue->assignee?->notify(new IssueAssignedNotification($issue));
}
} else {
$issue = Issue::create(array_merge($payload, [
'project_id' => $this->project->id,