Task status selector in index

This commit is contained in:
2025-10-31 22:42:26 +02:00
parent 8bb22f8e04
commit 74c22b7b3d
11 changed files with 92 additions and 6 deletions
+15 -2
View File
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class TasksController < ApplicationController
before_action :fetch_task, only: %w[show edit update delete]
before_action :fetch_task, only: %w[show edit update delete change_status]
def index
self.current_project = fetch_project
@@ -11,7 +11,7 @@ class TasksController < ApplicationController
Task.all
end
@tasks = @tasks.includes(:project, :status)
@tasks = @tasks.includes(:status, project: :task_statuses)
end
def show; end
@@ -49,6 +49,19 @@ class TasksController < ApplicationController
redirect_to tasks_path(project: @task.project)
end
def change_status
@form = Tasks::ChangeStatus.new(params.expect(task: :status_id))
if @form.perform(@task)
respond_to do |format|
format.html { redirect_to task_path(@task) }
format.turbo_stream
end
else
head :unprocessable_entity
end
end
private
def fetch_project