Merge pull request #58 from sartography/feature/highlight_active_task
Feature/highlight active task
This commit is contained in:
commit
fbb1938bb8
|
@ -1,2 +1 @@
|
|||
"""Config."""
|
||||
# BPMN_SPEC_ABSOLUTE_DIR = "BPMN_SPECS_DEV"
|
||||
|
|
|
@ -679,6 +679,12 @@ paths:
|
|||
description: The unique id of an existing process instance.
|
||||
schema:
|
||||
type: integer
|
||||
- name: all_tasks
|
||||
in: query
|
||||
required: false
|
||||
description: If true, this wil return all tasks associated with the process instance and not just user tasks.
|
||||
schema:
|
||||
type: boolean
|
||||
get:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_task_list
|
||||
summary: returns the list of all user tasks associated with process instance
|
||||
|
|
|
@ -99,11 +99,15 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
|||
created_at_in_seconds: int = db.Column(db.Integer)
|
||||
status: str = db.Column(db.String(50))
|
||||
|
||||
data: dict | None = None
|
||||
bpmn_xml_file_contents: bytes | None = None
|
||||
|
||||
@property
|
||||
def serialized(self) -> dict[str, Any]:
|
||||
"""Return object data in serializeable format."""
|
||||
local_bpmn_xml_file_contents = ""
|
||||
if self.bpmn_xml_file_contents:
|
||||
local_bpmn_xml_file_contents = self.bpmn_xml_file_contents.decode("utf-8")
|
||||
|
||||
return {
|
||||
"id": self.id,
|
||||
"process_model_identifier": self.process_model_identifier,
|
||||
|
@ -113,7 +117,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
|||
"start_in_seconds": self.start_in_seconds,
|
||||
"end_in_seconds": self.end_in_seconds,
|
||||
"process_initiator_id": self.process_initiator_id,
|
||||
"data": self.data,
|
||||
"bpmn_xml_file_contents": local_bpmn_xml_file_contents,
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -139,8 +143,6 @@ class ProcessInstanceModelSchema(Schema):
|
|||
"process_model_identifier",
|
||||
"process_group_identifier",
|
||||
"process_initiator_id",
|
||||
# "process_initiator",
|
||||
"bpmn_json",
|
||||
"start_in_seconds",
|
||||
"end_in_seconds",
|
||||
"updated_at_in_seconds",
|
||||
|
|
|
@ -392,8 +392,13 @@ def process_instance_show(
|
|||
) -> flask.wrappers.Response:
|
||||
"""Create_process_instance."""
|
||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
process_instance.data = processor.get_data()
|
||||
process_model = get_process_model(process_model_id, process_group_id)
|
||||
|
||||
if process_model.primary_file_name:
|
||||
bpmn_xml_file_contents = SpecFileService.get_data(
|
||||
process_model, process_model.primary_file_name
|
||||
)
|
||||
process_instance.bpmn_xml_file_contents = bpmn_xml_file_contents
|
||||
|
||||
return make_response(jsonify(process_instance), 200)
|
||||
|
||||
|
@ -554,16 +559,24 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res
|
|||
return make_response(jsonify(response_json), 200)
|
||||
|
||||
|
||||
def process_instance_task_list(process_instance_id: int) -> flask.wrappers.Response:
|
||||
def process_instance_task_list(
|
||||
process_instance_id: int, all_tasks: bool = False
|
||||
) -> flask.wrappers.Response:
|
||||
"""Process_instance_task_list."""
|
||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
all_spiff_user_tasks = processor.get_all_user_tasks()
|
||||
|
||||
tasks = [
|
||||
ProcessInstanceService.spiff_task_to_api_task(spiff_task)
|
||||
for spiff_task in all_spiff_user_tasks
|
||||
]
|
||||
spiff_tasks = None
|
||||
if all_tasks:
|
||||
spiff_tasks = processor.bpmn_process_instance.get_tasks(TaskState.ANY_MASK)
|
||||
else:
|
||||
spiff_tasks = processor.get_all_user_tasks()
|
||||
|
||||
tasks = []
|
||||
for spiff_task in spiff_tasks:
|
||||
task = ProcessInstanceService.spiff_task_to_api_task(spiff_task)
|
||||
task.data = spiff_task.data
|
||||
tasks.append(task)
|
||||
|
||||
return make_response(jsonify(tasks), 200)
|
||||
|
||||
|
|
Loading…
Reference in New Issue