diff --git a/ang/civicase/case/details/linked-cases-tab/directives/case-details-linked-cases-tab.directive.js b/ang/civicase/case/details/linked-cases-tab/directives/case-details-linked-cases-tab.directive.js
index d63962be6..dcd95ce07 100644
--- a/ang/civicase/case/details/linked-cases-tab/directives/case-details-linked-cases-tab.directive.js
+++ b/ang/civicase/case/details/linked-cases-tab/directives/case-details-linked-cases-tab.directive.js
@@ -17,12 +17,14 @@
*
* @param {object} $scope the scope object.
* @param {object} LinkCasesCaseAction the link case action service.
+ * @param {object} NewLinkCasesCaseAction the new link case action service.
* @param {Function} civicaseCrmUrl crm url service.
* @param {Function} civicaseCrmLoadForm service to load civicrm forms
*/
function civicaseCaseDetailsLinkedCasesTabController ($scope,
- LinkCasesCaseAction, civicaseCrmUrl, civicaseCrmLoadForm) {
+ LinkCasesCaseAction, NewLinkCasesCaseAction, civicaseCrmUrl, civicaseCrmLoadForm) {
$scope.linkCase = linkCase;
+ $scope.newLinkCase = newLinkCase;
/**
* Opens a modal that allows the user to link the case stored in the scope with
@@ -39,5 +41,20 @@
});
});
}
+
+ /**
+ * Opens a modal that allows the user to open a new case and link it at the same time.
+ *
+ * The case details are refreshed after linking the cases.
+ */
+ function newLinkCase () {
+ NewLinkCasesCaseAction.doAction([$scope.item])
+ .then(function (openCaseForm) {
+ civicaseCrmLoadForm(civicaseCrmUrl(openCaseForm.path, openCaseForm.query))
+ .on('crmFormSuccess crmPopupFormSuccess', function () {
+ $scope.refresh();
+ });
+ });
+ }
}
})(angular);
diff --git a/civicase.php b/civicase.php
index 9ef585afc..dac480857 100644
--- a/civicase.php
+++ b/civicase.php
@@ -279,6 +279,7 @@ function civicase_civicrm_post($op, $objectName, $objectId, &$objectRef) {
new CRM_Civicase_Hook_Post_PopulateCaseCategoryForCaseType(),
new CRM_Civicase_Hook_Post_CaseCategoryCustomGroupSaver(),
new CRM_Civicase_Hook_Post_UpdateCaseTypeListForCaseCategoryCustomGroup(),
+ new CRM_Civicase_Hook_Post_LinkCase(),
];
foreach ($hooks as $hook) {