From 1a81a73ab17995eb3f0013d8b1e144b2c1030e88 Mon Sep 17 00:00:00 2001 From: jbirddog <100367399+jbirddog@users.noreply.github.com> Date: Wed, 10 May 2023 10:58:01 -0400 Subject: [PATCH 1/2] Fix the empty form issue, round 2 (#248) --- spiffworkflow-frontend/src/routes/TaskShow.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index 9ab9ebf96..7a9c8fec1 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -176,8 +176,10 @@ export default function TaskShow() { if (disabled) { return; } - if (!formObject) { + const dataToSubmit = formObject?.formData; + if (!dataToSubmit) { navigate(`/tasks`); + return; } let queryParams = ''; if (submitType === FormSubmitType.Draft) { @@ -185,7 +187,6 @@ export default function TaskShow() { } setDisabled(true); removeError(); - const dataToSubmit = formObject.formData; delete dataToSubmit.isManualTask; HttpService.makeCallToBackend({ path: `/tasks/${params.process_instance_id}/${params.task_id}${queryParams}`, From f49c4d879fe930a61ce3df27809190979918131b Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 10 May 2023 11:20:34 -0400 Subject: [PATCH 2/2] added update all spiff tasks method from reset branch to main w/ burnettk --- .../services/task_service.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py index 1cea59092..9d67ec0c8 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py @@ -20,6 +20,7 @@ from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel from spiffworkflow_backend.models.bpmn_process import BpmnProcessNotFoundError from spiffworkflow_backend.models.bpmn_process_definition import BpmnProcessDefinitionModel from spiffworkflow_backend.models.db import db +from spiffworkflow_backend.models.human_task import HumanTaskModel from spiffworkflow_backend.models.json_data import JsonDataDict from spiffworkflow_backend.models.json_data import JsonDataModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel @@ -452,6 +453,28 @@ class TaskService: self.update_task_model(task_model, spiff_task) self.task_models[task_model.guid] = task_model + def update_all_tasks_from_spiff_tasks( + self, spiff_tasks: list[SpiffTask], deleted_spiff_tasks: list[SpiffTask], start_time: float + ) -> None: + # Remove all the deleted/pruned tasks from the database. + deleted_task_ids = list(map(lambda t: str(t.id), deleted_spiff_tasks)) + tasks_to_clear = TaskModel.query.filter(TaskModel.guid.in_(deleted_task_ids)).all() # type: ignore + human_tasks_to_clear = HumanTaskModel.query.filter( + HumanTaskModel.task_id.in_(deleted_task_ids) # type: ignore + ).all() + for task in tasks_to_clear + human_tasks_to_clear: + db.session.delete(task) + + # Note: Can't restrict this to definite, because some things are updated and are now CANCELLED + # and other things may have been COMPLETED and are now MAYBE + spiff_tasks_updated = {} + for spiff_task in spiff_tasks: + if spiff_task.last_state_change > start_time: + spiff_tasks_updated[str(spiff_task.id)] = spiff_task + for _id, spiff_task in spiff_tasks_updated.items(): + self.update_task_model_with_spiff_task(spiff_task) + self.save_objects_to_database() + @classmethod def remove_spiff_task_from_parent(cls, spiff_task: SpiffTask, task_models: dict[str, TaskModel]) -> None: """Removes the given spiff task from its parent and then updates the task_models dict with the changes."""