display the potential task owners or group in the interstitial info message w/ burnettk (#415)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
1ea765f770
commit
7fcd3030c3
|
@ -130,6 +130,8 @@ class Task:
|
|||
parent: str | None = None,
|
||||
event_definition: dict[str, Any] | None = None,
|
||||
error_message: str | None = None,
|
||||
assigned_user_group_identifier: str | None = None,
|
||||
potential_owner_usernames: str | None = None,
|
||||
):
|
||||
self.id = id
|
||||
self.name = name
|
||||
|
@ -155,6 +157,8 @@ class Task:
|
|||
self.process_model_display_name = process_model_display_name
|
||||
self.form_schema = form_schema
|
||||
self.form_ui_schema = form_ui_schema
|
||||
self.assigned_user_group_identifier = assigned_user_group_identifier
|
||||
self.potential_owner_usernames = potential_owner_usernames
|
||||
|
||||
self.multi_instance_type = multi_instance_type # Some tasks have a repeat behavior.
|
||||
self.multi_instance_count = multi_instance_count # This is the number of times the task could repeat.
|
||||
|
@ -200,6 +204,8 @@ class Task:
|
|||
"parent": self.parent,
|
||||
"event_definition": self.event_definition,
|
||||
"error_message": self.error_message,
|
||||
"assigned_user_group_identifier": self.assigned_user_group_identifier,
|
||||
"potential_owner_usernames": self.potential_owner_usernames,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -74,6 +74,7 @@ class ReactJsonSchemaSelectOption(TypedDict):
|
|||
enum: list[str]
|
||||
|
||||
|
||||
# this is currently not used by the Frontend
|
||||
def task_list_my_tasks(
|
||||
process_instance_id: int | None = None, page: int = 1, per_page: int = 100
|
||||
) -> flask.wrappers.Response:
|
||||
|
|
|
@ -15,6 +15,7 @@ from SpiffWorkflow.bpmn.specs.event_definitions import TimerEventDefinition # t
|
|||
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
||||
from spiffworkflow_backend import db
|
||||
from spiffworkflow_backend.exceptions.api_error import ApiError
|
||||
from spiffworkflow_backend.models.group import GroupModel
|
||||
from spiffworkflow_backend.models.human_task import HumanTaskModel
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceApi
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
|
@ -546,6 +547,20 @@ class ProcessInstanceService:
|
|||
except UserDoesNotHaveAccessToTaskError:
|
||||
can_complete = False
|
||||
|
||||
# if the current user cannot complete the task then find out who can
|
||||
assigned_user_group_identifier = None
|
||||
potential_owner_usernames = None
|
||||
if can_complete is False:
|
||||
human_task = HumanTaskModel.query.filter_by(task_id=task_guid).first()
|
||||
if human_task is not None:
|
||||
if human_task.lane_assignment_id is not None:
|
||||
group = GroupModel.query.filter_by(id=human_task.lane_assignment_id).first()
|
||||
if group is not None:
|
||||
assigned_user_group_identifier = group.identifier
|
||||
elif len(human_task.potential_owners) > 0:
|
||||
user_list = [u.email for u in human_task.potential_owners]
|
||||
potential_owner_usernames = ",".join(user_list)
|
||||
|
||||
parent_id = None
|
||||
if spiff_task.parent:
|
||||
parent_id = spiff_task.parent.id
|
||||
|
@ -576,6 +591,8 @@ class ProcessInstanceService:
|
|||
parent=parent_id,
|
||||
event_definition=serialized_task_spec.get("event_definition"),
|
||||
error_message=error_message,
|
||||
assigned_user_group_identifier=assigned_user_group_identifier,
|
||||
potential_owner_usernames=potential_owner_usernames,
|
||||
)
|
||||
|
||||
return task
|
||||
|
|
|
@ -179,9 +179,22 @@ export default function ProcessInterstitial({
|
|||
}
|
||||
|
||||
if (!myTask.can_complete && HUMAN_TASK_TYPES.includes(myTask.type)) {
|
||||
let message = 'This next task is assigned to a different person or team.';
|
||||
if (myTask.assigned_user_group_identifier) {
|
||||
message = `This next task is assigned to group: ${myTask.assigned_user_group_identifier}.`;
|
||||
} else if (myTask.potential_owner_usernames) {
|
||||
let potentialOwnerArray = myTask.potential_owner_usernames.split(',');
|
||||
if (potentialOwnerArray.length > 2) {
|
||||
potentialOwnerArray = potentialOwnerArray.slice(0, 2).concat(['...']);
|
||||
}
|
||||
message = `This next task is assigned to user(s): ${potentialOwnerArray.join(
|
||||
', '
|
||||
)}.`;
|
||||
}
|
||||
|
||||
return inlineMessage(
|
||||
'',
|
||||
`This next task is assigned to a different person or team. There is no action for you to take at this time.`
|
||||
`${message} There is no action for you to take at this time.`
|
||||
);
|
||||
}
|
||||
if (shouldRedirectToTask(myTask)) {
|
||||
|
|
Loading…
Reference in New Issue