From 7f6123a6e68cf02d7c7c23497adc96642408b49d Mon Sep 17 00:00:00 2001 From: KaungKaung Date: Fri, 30 Jan 2026 09:38:32 +0630 Subject: [PATCH] Show Done tasks and Fixed turbo frame and stream bug --- app/views/projects/show.html.erb | 26 +++++++++-------------- app/views/tasks/_task.html.erb | 21 +++++++++++------- app/views/tasks/complete.turbo_stream.erb | 9 +------- app/views/tasks/create.turbo_stream.erb | 6 +++--- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 123e6c2..908d09d 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -1,26 +1,20 @@

<%= @project.project_name %>

<%= @project.description %>

- +<%= turbo_frame_tag "tasks" do %> - +<% end %> - +<%= turbo_frame_tag "new_task" do %>

Add New Task

- <%= render partial: "tasks/form", locals: { project: @project, task: Task.new } %> -
\ No newline at end of file + <%= render "tasks/form", project: @project, task: Task.new %> +<% end %> diff --git a/app/views/tasks/_task.html.erb b/app/views/tasks/_task.html.erb index 750ef9e..7edd2e7 100644 --- a/app/views/tasks/_task.html.erb +++ b/app/views/tasks/_task.html.erb @@ -1,15 +1,20 @@ -
  • - <%= task.title %> (<%= task.status %>) - - <%= link_to "Destroy", project_task_path(task.project, task), - data: { turbo_method: :delete, turbo_confirm: "Are you sure?" } %> - +
  • +
    <%= task.title %>
    +
    <%= task.status.titleize %>
    +
    <% unless task.status == "done" %> <%= button_to "Complete", complete_project_task_path(task.project, task), method: :patch, - form: { data: { turbo_frame: dom_id(task) } } %> + data: { turbo_frame: dom_id(task) }, + class: "task-btn complete-btn" %> <% end %> -
  • + + <%= link_to "Destroy", + project_task_path(task.project, task), + data: { turbo_method: :delete, turbo_confirm: "Are you sure?" }, + class: "task-btn destroy-btn" %> + +
    \ No newline at end of file diff --git a/app/views/tasks/complete.turbo_stream.erb b/app/views/tasks/complete.turbo_stream.erb index 058bf2a..34efcab 100644 --- a/app/views/tasks/complete.turbo_stream.erb +++ b/app/views/tasks/complete.turbo_stream.erb @@ -1,10 +1,3 @@ <%= turbo_stream.replace dom_id(@task) do %> -
  • - <%= @task.title %> (<%= @task.status %>) - - <%= link_to "Destroy", project_task_path(@project, @task), data: { - turbo_method: :delete, - turbo_confirm: "Are you sure?" - } %> -
  • + <%= render @task %> <% end %> diff --git a/app/views/tasks/create.turbo_stream.erb b/app/views/tasks/create.turbo_stream.erb index f63494f..9ec72d4 100644 --- a/app/views/tasks/create.turbo_stream.erb +++ b/app/views/tasks/create.turbo_stream.erb @@ -1,7 +1,7 @@ -<%= turbo_stream.append "tasks_list" do %> - <%= render partial: "tasks/task", locals: { task: @task } %> +<%= turbo_stream.append "tasks" do %> + <%= render @task %> <% end %> <%= turbo_stream.replace "new_task" do %> - <%= render partial: "tasks/form", locals: { project: @project, task: Task.new } %> + <%= render "tasks/form", project: @project, task: Task.new %> <% end %>