diff --git a/resources/views/components/organizations/⚡dashboard.blade.php b/resources/views/components/organizations/⚡dashboard.blade.php index da6dc4a..025fabd 100644 --- a/resources/views/components/organizations/⚡dashboard.blade.php +++ b/resources/views/components/organizations/⚡dashboard.blade.php @@ -1,6 +1,8 @@ showTodoForm = ! $this->showTodoForm; + } + + public function addTodo(): void + { + $validated = $this->validate([ + 'newTodoTitle' => 'required|string|max:255', + 'newTodoCategory' => 'required|in:'.implode(',', array_keys(Todo::CATEGORIES)), + 'newTodoCriticality' => 'required|in:'.implode(',', array_keys(Todo::CRITICALITIES)), + 'newTodoDueDate' => 'nullable|date', + 'newTodoAssignedTo' => 'nullable|exists:users,id', + ]); + + $this->organization->todos()->create([ + 'title' => $validated['newTodoTitle'], + 'category' => $validated['newTodoCategory'], + 'criticality' => $validated['newTodoCriticality'], + 'due_date' => $validated['newTodoDueDate'], + 'assigned_to' => $validated['newTodoAssignedTo'], + 'created_by' => auth()->id(), + ]); + + $this->reset(['newTodoTitle', 'newTodoCategory', 'newTodoCriticality', 'newTodoDueDate', 'newTodoAssignedTo', 'showTodoForm']); + } + public function previousActivityPage(): void { $this->activityPage = max(1, $this->activityPage - 1); @@ -155,6 +191,7 @@ new class extends Component 'recentActivity' => $recentActivity, 'activityPageCount' => $activityPageCount, 'openTodos' => $openTodos, + 'assignableUsers' => User::role(['Administrateur', 'Technicien'])->orderBy('name')->get(), 'logEntries' => $this->organization->logEntries()->with('creator')->limit(20)->get(), 'categories' => \App\Models\OrganizationLogEntry::CATEGORIES, ]; @@ -251,12 +288,12 @@ new class extends Component @if ($activityPageCount > 1)
Page {{ $activityPage }} / {{ $activityPageCount }}
@@ -268,11 +305,55 @@ new class extends Component

Tâches ouvertes

- - Voir toutes les tâches → - +
+ + + Voir toutes les tâches → + +
+ @if ($showTodoForm) +
+
+ + @error('newTodoTitle')

{{ $message }}

@enderror +
+
+ + + + +
+
+ +
+
+ @endif +
@error('newLogNote')

{{ $message }}

@enderror @@ -345,7 +426,7 @@ new class extends Component