From 5bcbbe143c158cb7e102f4ef6efd39b391ad5804 Mon Sep 17 00:00:00 2001 From: CarliPinell Date: Mon, 31 Jul 2023 16:23:11 -0400 Subject: [PATCH] QA Observation fixed FOUR-9706 Full Set of Categories Updated in ProcessUpdated is Not Completed Shown --- ProcessMaker/Events/ProcessPublished.php | 14 +++++++++++--- .../Http/Controllers/Api/ProcessController.php | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ProcessMaker/Events/ProcessPublished.php b/ProcessMaker/Events/ProcessPublished.php index fcfc9bc2b8..0081f18663 100644 --- a/ProcessMaker/Events/ProcessPublished.php +++ b/ProcessMaker/Events/ProcessPublished.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Events\Dispatchable; use ProcessMaker\Contracts\SecurityLogEventInterface; +use ProcessMaker\Helpers\ArrayHelper; use ProcessMaker\Models\Process; use ProcessMaker\Models\ProcessCategory; use ProcessMaker\Traits\FormatSecurityLogChanges; @@ -23,6 +24,10 @@ class ProcessPublished implements SecurityLogEventInterface 'conditional_events', 'properties', ]; + public const REMOVE_KEYS_AUX = [ + 'tmp_process_category_id', + 'process_category_id', + ]; private Process $process; @@ -46,8 +51,11 @@ public function __construct(Process $data, array $changes, array $original) ? ProcessCategory::getNamesByIds($this->original['process_category_id']) : ''; unset($this->original['process_category_id']); $this->changes['process_category'] = isset($changes['process_category_id']) - ? ProcessCategory::getNamesByIds($this->changes['process_category_id']) : ''; - unset($this->changes['process_category_id']); + ? ProcessCategory::getNamesByIds($this->changes['tmp_process_category_id']) : ''; + $this->changes = array_diff_key($this->changes, array_flip($this::REMOVE_KEYS_AUX)); + if (empty($this->changes['process_category'])) { + unset($this->changes['process_category']); + } } /** @@ -65,7 +73,7 @@ public function getData(): array 'category' => $this->process->category ? $this->process->category->name : null, 'action' => $this->process->getAttribute('status'), 'last_modified' => $this->process->getAttribute('updated_at'), - ], $this->formatChanges($this->changes, $this->original)); + ], ArrayHelper::getArrayDifferencesWithFormat($this->changes, $this->original)); } /** diff --git a/ProcessMaker/Http/Controllers/Api/ProcessController.php b/ProcessMaker/Http/Controllers/Api/ProcessController.php index 470c3a5935..1f62843d13 100644 --- a/ProcessMaker/Http/Controllers/Api/ProcessController.php +++ b/ProcessMaker/Http/Controllers/Api/ProcessController.php @@ -389,6 +389,7 @@ public function update(Request $request, Process $process) ); } $changes = $process->getChanges(); + $changes['tmp_process_category_id'] = $request->input('process_category_id'); // Register the Event ProcessPublished::dispatch($process->refresh(), $changes, $original);