Skip to content

Commit

Permalink
Make Case menu link in relationship tab conditional
Browse files Browse the repository at this point in the history
Only add the link when CiviCase is enabled

Fixes: https://lab.civicrm.org/dev/core/-/issues/4957
  • Loading branch information
ejegg committed Feb 2, 2024
1 parent bd42074 commit fd1c70c
Showing 1 changed file with 65 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,76 @@
['far_contact_id', '=', 'RelationshipCache_Contact_far_contact_id_01.id'],
],
];
$links = [
[
'entity' => 'Relationship',
'action' => 'view',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-external-link',
'text' => ts('View Relationship'),
'style' => 'default',
'path' => '',
'task' => '',
'condition' => [],
],
[
'entity' => 'Relationship',
'action' => 'update',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-pencil',
'text' => ts('Update Relationship'),
'style' => 'default',
'path' => '',
'task' => '',
'condition' => [],
],
[
'task' => 'disable',
'entity' => 'Relationship',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-toggle-off',
'text' => ts('Disable Relationship'),
'style' => 'default',
'path' => '',
'action' => '',
'condition' => [
'is_active',
'=',
TRUE,
],
],
[
'entity' => 'Relationship',
'action' => 'delete',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-trash',
'text' => ts('Delete Relationship'),
'style' => 'danger',
'path' => '',
'task' => '',
'condition' => [],
],
];
if ($civiCaseEnabled) {
$joins[] = [
'Case AS RelationshipCache_Case_case_id_01',
'LEFT',
['case_id', '=', 'RelationshipCache_Case_case_id_01.id'],
];
$links[] = [
'entity' => 'Case',
'action' => 'view',
'join' => 'RelationshipCache_Case_case_id_01',
'target' => '',
'icon' => 'fa-folder-open',
'text' => ts('Manage Case'),
'style' => 'default',
'condition' => [],
];
}

return [
Expand Down Expand Up @@ -185,70 +249,7 @@
'style' => 'default',
'size' => 'btn-xs',
'icon' => 'fa-bars',
'links' => [
[
'entity' => 'Relationship',
'action' => 'view',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-external-link',
'text' => ts('View Relationship'),
'style' => 'default',
'path' => '',
'task' => '',
'condition' => [],
],
[
'entity' => 'Relationship',
'action' => 'update',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-pencil',
'text' => ts('Update Relationship'),
'style' => 'default',
'path' => '',
'task' => '',
'condition' => [],
],
[
'task' => 'disable',
'entity' => 'Relationship',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-toggle-off',
'text' => ts('Disable Relationship'),
'style' => 'default',
'path' => '',
'action' => '',
'condition' => [
'is_active',
'=',
TRUE,
],
],
[
'entity' => 'Relationship',
'action' => 'delete',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-trash',
'text' => ts('Delete Relationship'),
'style' => 'danger',
'path' => '',
'task' => '',
'condition' => [],
],
[
'entity' => 'Case',
'action' => 'view',
'join' => 'RelationshipCache_Case_case_id_01',
'target' => '',
'icon' => 'fa-folder-open',
'text' => ts('Manage Case'),
'style' => 'default',
'condition' => [],
],
],
'links' => $links,
'type' => 'menu',
'alignment' => 'text-right',
],
Expand Down

0 comments on commit fd1c70c

Please sign in to comment.