Broadcasting status change
This commit is contained in:
@@ -9,6 +9,8 @@ module Tasks
|
|||||||
|
|
||||||
delegate :model_name, to: Task
|
delegate :model_name, to: Task
|
||||||
|
|
||||||
|
after_success :broadcast_status_changes
|
||||||
|
|
||||||
def perform(task)
|
def perform(task)
|
||||||
@task = task
|
@task = task
|
||||||
@id = task.id
|
@id = task.id
|
||||||
@@ -18,5 +20,19 @@ module Tasks
|
|||||||
@task.status_id = status_id
|
@task.status_id = status_id
|
||||||
save @task
|
save @task
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def broadcast_status_changes
|
||||||
|
view_model_with_form = Tasks::Statuses::SelectorViewModel.new(task, with_form: true)
|
||||||
|
view_model_no_form = Tasks::Statuses::SelectorViewModel.new(task, with_form: false)
|
||||||
|
|
||||||
|
task.broadcast_replace_to [task, :status, :with_form],
|
||||||
|
target: view_model_with_form.dom_id,
|
||||||
|
renderable: view_model_with_form
|
||||||
|
task.broadcast_replace_to [task, :status, :no_form],
|
||||||
|
target: view_model_no_form.dom_id,
|
||||||
|
renderable: view_model_no_form
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ div
|
|||||||
h1= @task.title
|
h1= @task.title
|
||||||
|
|
||||||
section.task-show-info
|
section.task-show-info
|
||||||
= task_status_selector @task, id: "task_status_selector_#{@task.id}", with_form: true
|
= task_status_selector @task, with_form: true
|
||||||
|
= turbo_stream_from @task, :status, :with_form
|
||||||
|
|
||||||
|
|
||||||
section= @task.description
|
section= @task.description
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user