diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cae4b05aeddff4d3520efefa99f0ef7a936786e..9e8e84d93e6f34dabe5064840a78d5f94720db53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Added filter to respect the ACL. So that a user only sees the contacts he is allowed to see. * Removed the title attribute from the outputs as those don't make sense. * Added fields with aggregation. +* Fixed issue with updating navigation after editing an output. # Version 1.0.7 diff --git a/Civi/DataProcessor/Output/UIOutputHelper.php b/Civi/DataProcessor/Output/UIOutputHelper.php index 4d1048ee7928edb364f0ec5edb37bc41b76fa2a1..7afed3554c538a1905300fe3decfd49a2693ee4f 100644 --- a/Civi/DataProcessor/Output/UIOutputHelper.php +++ b/Civi/DataProcessor/Output/UIOutputHelper.php @@ -46,9 +46,6 @@ class UIOutputHelper { $configuration = json_decode($dao->configuration, TRUE); $title = $dao->title; - if (isset($configuration['title'])) { - $title = $configuration['title']; - } $item = [ 'title' => $title, 'page_callback' => $outputClass->getCallbackForUi(), @@ -81,15 +78,18 @@ class UIOutputHelper { elseif (!isset($params['configuration']['navigation_parent_path'])) { self::removeOutputFromNavigation($output['configuration']); } - else { - // Merge the current output from the database with the updated values - $configuration = array_merge($output['configuration'], $params['configuration']); - $output = array_merge($output, $params); - $output['configuration'] = $configuration; - $dataProcessor = civicrm_api3('DataProcessor', 'getsingle', ['id' => $output['data_processor_id']]); - $configuration = self::createOrUpdateNavigationItem($output, $dataProcessor); - if ($configuration) { - $params['configuration'] = $configuration; + elseif (isset($params['configuration']['navigation_parent_path'])) { + if (!isset($output['configuration']['navigation_parent_path']) || $params['configuration']['navigation_parent_path'] != $output['configuration']['navigation_parent_path']) { + // Merge the current output from the database with the updated values + $configuration = array_merge($output['configuration'], $params['configuration']); + $configuration['navigation_parent_path'] = $params['configuration']['navigation_parent_path']; + $output = array_merge($output, $params); + $output['configuration'] = $configuration; + $dataProcessor = civicrm_api3('DataProcessor', 'getsingle', ['id' => $output['data_processor_id']]); + $configuration = self::createOrUpdateNavigationItem($output, $dataProcessor); + if ($configuration) { + $params['configuration'] = $configuration; + } } } } @@ -206,7 +206,7 @@ class UIOutputHelper { $navigationParams['label'] = isset($configuration['title']) ? $configuration['title'] : $dataProcessor['title']; $navigationParams['name'] = $dataProcessor['name']; - if (!isset($navigationParams['parent_id']) && isset($configuration['navigation_parent_path'])) { + if (isset($configuration['navigation_parent_path'])) { $navigationParams['parent_id'] = $navigation->getNavigationIdByPath($configuration['navigation_parent_path']); } $navigationParams['is_active'] = $dataProcessor['is_active']; @@ -228,4 +228,4 @@ class UIOutputHelper { return $configuration; } -} \ No newline at end of file +}