feat(issues): incidencias enriquecidas (tareas/comentarios/fotos/verificación) + tabla Rappasoft + logo
Web: - IssueTask + IssueComment (modelos, migraciones, soft-deletes, campos de sync). Issue gana tasks()/comments() y accessor de % de avance derivado de tareas. - IssueDetail (página): checklist con asignado/fecha límite/progreso, hilo de comentarios con foto por comentario, galería de fotos de la incidencia y flujo de verificación open→in_review→resolved/closed (+reabrir) con notas. - Creación/edición en páginas propias (IssueForm), sin modal; al guardar redirige al detalle. Rutas projects.issues.create/edit/show. - Listado con tabla Rappasoft (IssueTable): filtros por estado/prioridad, búsqueda, barra de progreso y acciones por fila gateadas por permisos; IssueManager queda como contenedor (cabecera + stats) que embebe la tabla. - Seguridad: pertenencia al proyecto + permisos por acción (view/create/edit/delete issues, upload/delete media) en todos los componentes. API móvil (offline): - /sync: issue_task.create/update y issue_comment.create (idempotente, LWW). - /media: parent_entity issue_task / issue_comment. - bundle + tombstones incluyen issue_tasks / issue_comments. - openapi.yaml + MOBILE_SYNC_PROTOCOL.md actualizados. Tests: MobileApiTest 23 passing (+5); IssuesTablePageTest (3) smoke de la tabla. Branding: logo RTE International — MAI Group (public/images/logo-rte.png) en login y navegación; application-logo pasa de SVG por defecto a <img>. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Feature;
|
||||
use App\Models\Inspection;
|
||||
use App\Models\Issue;
|
||||
use App\Models\IssueComment;
|
||||
use App\Models\IssueTask;
|
||||
use App\Models\Phase;
|
||||
use App\Models\ProgressUpdate;
|
||||
use App\Models\Project;
|
||||
@@ -63,6 +65,9 @@ class SyncController extends Controller
|
||||
'inspection.create' => $this->inspectionCreate($user, $uuid, $op),
|
||||
'issue.create' => $this->issueCreate($user, $uuid, $op),
|
||||
'issue.update' => $this->issueUpdate($user, $uuid, $op),
|
||||
'issue_task.create' => $this->issueTaskCreate($user, $uuid, $op),
|
||||
'issue_task.update' => $this->issueTaskUpdate($user, $uuid, $op),
|
||||
'issue_comment.create' => $this->issueCommentCreate($user, $uuid, $op),
|
||||
'feature.update' => $this->featureUpdate($user, $uuid, $op),
|
||||
default => $this->error($uuid, 'unsupported entity/op: ' . $op['entity'] . '.' . $op['op']),
|
||||
};
|
||||
@@ -245,6 +250,116 @@ class SyncController extends Controller
|
||||
return $this->applied($uuid, $issue->id);
|
||||
}
|
||||
|
||||
// ── issue_task.create / issue_task.update ──────────────────────────────────────
|
||||
|
||||
private function issueTaskCreate(User $user, string $uuid, array $op): array
|
||||
{
|
||||
if ($existing = IssueTask::where('uuid', $uuid)->first()) {
|
||||
return $this->duplicate($uuid, $existing->id);
|
||||
}
|
||||
|
||||
$v = Validator::make($op['data'], [
|
||||
'issue_id' => ['required', 'integer', 'exists:issues,id'],
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'assigned_to' => ['nullable', 'integer', 'exists:users,id'],
|
||||
'due_date' => ['nullable', 'date'],
|
||||
'is_done' => ['nullable', 'boolean'],
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
return $this->error($uuid, 'validation: ' . $v->errors()->first());
|
||||
}
|
||||
$d = $v->validated();
|
||||
|
||||
$issue = Issue::with('project')->findOrFail($d['issue_id']);
|
||||
if (! $this->canAccess($user, $issue->project) || ! $user->can('edit issues')) {
|
||||
return $this->error($uuid, 'forbidden');
|
||||
}
|
||||
|
||||
$done = $d['is_done'] ?? false;
|
||||
$task = IssueTask::create([
|
||||
'uuid' => $uuid,
|
||||
'issue_id' => $issue->id,
|
||||
'title' => $d['title'],
|
||||
'assigned_to' => $d['assigned_to'] ?? null,
|
||||
'due_date' => $d['due_date'] ?? null,
|
||||
'is_done' => $done,
|
||||
'done_at' => $done ? now() : null,
|
||||
'done_by' => $done ? $user->id : null,
|
||||
'order' => ((int) $issue->tasks()->max('order')) + 1,
|
||||
'client_updated_at' => $op['client_updated_at'] ?? null,
|
||||
]);
|
||||
|
||||
return $this->applied($uuid, $task->id);
|
||||
}
|
||||
|
||||
private function issueTaskUpdate(User $user, string $uuid, array $op): array
|
||||
{
|
||||
$v = Validator::make($op['data'], [
|
||||
'id' => ['required', 'integer', 'exists:issue_tasks,id'],
|
||||
'title' => ['nullable', 'string', 'max:255'],
|
||||
'assigned_to' => ['nullable', 'integer', 'exists:users,id'],
|
||||
'due_date' => ['nullable', 'date'],
|
||||
'is_done' => ['nullable', 'boolean'],
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
return $this->error($uuid, 'validation: ' . $v->errors()->first());
|
||||
}
|
||||
$d = $v->validated();
|
||||
|
||||
$task = IssueTask::with('issue.project')->findOrFail($d['id']);
|
||||
if (! $this->canAccess($user, $task->issue?->project) || ! $user->can('edit issues')) {
|
||||
return $this->error($uuid, 'forbidden');
|
||||
}
|
||||
|
||||
if ($conflict = $this->conflict($uuid, $task, $op)) {
|
||||
return $conflict;
|
||||
}
|
||||
|
||||
if (array_key_exists('is_done', $d)) {
|
||||
$task->is_done = (bool) $d['is_done'];
|
||||
$task->done_at = $d['is_done'] ? ($task->done_at ?? now()) : null;
|
||||
$task->done_by = $d['is_done'] ? ($task->done_by ?? $user->id) : null;
|
||||
}
|
||||
$task->fill(collect($d)->only('title', 'assigned_to', 'due_date')->toArray());
|
||||
$task->client_updated_at = $op['client_updated_at'] ?? null;
|
||||
$task->save();
|
||||
|
||||
return $this->applied($uuid, $task->id);
|
||||
}
|
||||
|
||||
// ── issue_comment.create ────────────────────────────────────────────────────────
|
||||
|
||||
private function issueCommentCreate(User $user, string $uuid, array $op): array
|
||||
{
|
||||
if ($existing = IssueComment::where('uuid', $uuid)->first()) {
|
||||
return $this->duplicate($uuid, $existing->id);
|
||||
}
|
||||
|
||||
$v = Validator::make($op['data'], [
|
||||
'issue_id' => ['required', 'integer', 'exists:issues,id'],
|
||||
'body' => ['required', 'string', 'max:5000'],
|
||||
]);
|
||||
if ($v->fails()) {
|
||||
return $this->error($uuid, 'validation: ' . $v->errors()->first());
|
||||
}
|
||||
$d = $v->validated();
|
||||
|
||||
$issue = Issue::with('project')->findOrFail($d['issue_id']);
|
||||
if (! $this->canAccess($user, $issue->project) || ! $user->can('view issues')) {
|
||||
return $this->error($uuid, 'forbidden');
|
||||
}
|
||||
|
||||
$comment = IssueComment::create([
|
||||
'uuid' => $uuid,
|
||||
'issue_id' => $issue->id,
|
||||
'user_id' => $user->id,
|
||||
'body' => $d['body'],
|
||||
'client_updated_at' => $op['client_updated_at'] ?? null,
|
||||
]);
|
||||
|
||||
return $this->applied($uuid, $comment->id);
|
||||
}
|
||||
|
||||
// ── feature.update ────────────────────────────────────────────────────────────
|
||||
|
||||
private function featureUpdate(User $user, string $uuid, array $op): array
|
||||
|
||||
Reference in New Issue
Block a user