BE: Set Status automatically for open/close/duplicate/move actions
When one of the open/close/duplicate/move actions happen, automatically set the status to the default status of the state (open/closed) or action (duplicated). Context here - #477863 (closed)
These action happen inside the UpdateService of the work item. We have ee/app/services/work_items/callbacks/status.rb
to set status and can use this callback to transition to another status based on state changes.
I think we can ignore move
for now.
The lifecycle of the work item type has default_open_status
, default_closed_status
and default_duplicated_status
.
We need to take the system defined lifecycle that is assigned to the work item type of the WI and find the status that is the default for the given action. We can then apply the status change.
Keep in mind that work items might not have current_status
yet, so we might want to use build_current_status
if it's not present.
app/services/concerns/work_items/widgetable_service.rb:24
so they are always executed. That way we could set an initial status in the after_initialize
method if none is set explicitly.