diff --git a/app/models/task.rb b/app/models/task.rb index 4602a95..467273b 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -10,6 +10,8 @@ class Task < ApplicationRecord has_rich_text :description + broadcasts_to ->(task) { [task.project, :tasks] }, template: 'tasks/_table_row' + def to_param return full_number if association(:project).loaded? diff --git a/app/views/tasks/_table_row.html.slim b/app/views/tasks/_table_row.html.slim new file mode 100644 index 0000000..076f972 --- /dev/null +++ b/app/views/tasks/_table_row.html.slim @@ -0,0 +1,8 @@ +- cache task do + tr id="task_#{task.id}" + td= link_to task.full_number, task_path(task) + td + = task_status_selector task, selector_class: 'small', id: "task_status_selector_#{task.id}", with_form: true + td= task.title + td + = link_to 'Edit', edit_task_path(task) diff --git a/app/views/tasks/index.html.slim b/app/views/tasks/index.html.slim index 4875a90..02e43aa 100644 --- a/app/views/tasks/index.html.slim +++ b/app/views/tasks/index.html.slim @@ -1,20 +1,12 @@ h1= tasks_index_title -.row +section.row = link_to 'New', new_task_path(project: current_project&.code) -- if @tasks.exists? - table.tasks-table - thead - tbody - - @tasks.each do |task| - - cache task do - tr - td= link_to task.full_number, task_path(task) - td - = task_status_selector task, with_form: true - td= task.title - td - = link_to 'Edit', edit_task_path(task) -- else - p No tasks +table.tasks-table + thead + tbody#tasks + = render partial: 'table_row', collection: @tasks, as: :task + +- if current_project + = turbo_stream_from current_project, :tasks