From 1a7c6d41a8307b30cf36ef32ad37654f80e07818 Mon Sep 17 00:00:00 2001 From: kaji Date: Tue, 25 Nov 2025 15:56:23 +0900 Subject: [PATCH] Enable to select your own tasks and all tasks from Tasks --- app/controllers/tasks_controller.rb | 3 +++ app/views/tasks/index.html.erb | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 16ed55a2..84b7176d 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -30,12 +30,15 @@ def index @q = Task.joins(:state).ransack({combinator: 'and', groupings: search_check(params[:q][:content_or_assigner_screen_name_or_description_or_project_name_cont])}) @q.sorts = sort_check(params[:q][:s]) end + + @show_all = params[:all] == 'true' tasks_query = @q.result if params[:only_todo] == '1' tasks_query = tasks_query.merge(Task.active) end + tasks_query = tasks_query.joins(:user).where(users: {screen_name: current_user&.screen_name}) unless @show_all @tasks = tasks_query.page(params[:page]).per(50).includes(:user, :state) end diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index f80d0a93..7ecd5db3 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -43,11 +43,24 @@ <% end %> <% end %> -<%= render @tasks %> +<% current_q_params = request.query_parameters.except(:controller, :action, :page) %> + -
-
- <%= raw(paginate @tasks) %> +
+
+ <%= render @tasks %> +
+ +