Skip to content

Commit

Permalink
Merge pull request #640 from compucorp/RSE-1543-expose-case-category
Browse files Browse the repository at this point in the history
  • Loading branch information
tunbola authored Nov 25, 2020
2 parents 7d88f47 + fb2e79a commit 3c5a024
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
38 changes: 38 additions & 0 deletions CRM/Civicase/Hook/alterAngular/AngularChangeSet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use CRM_Civicase_ExtensionUtil as ExtensionUtil;
use Civi\Angular\ChangeSet;

/**
* Angular ChangeSet Helper Class.
*/
class CRM_Civicase_Hook_alterAngular_AngularChangeSet {

/**
* Returns ChangeSet for the case type category field.
*
* This ChangeSet is needed for the core Case Type create/Edit screen.
*
* @return \Civi\Angular\ChangeSet
* Angular ChangeSet.
*/
public static function getForCaseTypeCategoryField() {
$path = CRM_Core_Resources::singleton()
->getPath(ExtensionUtil::LONG_NAME, 'templates/CRM/Civicase/ChangeSet/CaseTypeCategory.html');
$caseTypeCategoryContent = file_get_contents($path);

return ChangeSet::create('case-type-category')
->alterHtml('~/crmCaseType/caseTypeDetails.html', function (phpQueryObject $doc) use ($caseTypeCategoryContent) {
$element = $doc->find("div[crm-ui-field*=name: 'caseTypeDetailForm.caseTypeName']");
if ($element->length) {
$element->after($caseTypeCategoryContent);
}
else {
$doc->find("[ng-form='caseTypeDetailForm']")->prepend(
'<p class="error">The case type name selector is invalid, The Instance field will not be available</p>'
);
}
});
}

}
10 changes: 10 additions & 0 deletions civicase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Civi\Angular\AngularLoader;
use Civi\Angular\Manager;

require_once 'civicase.civix.php';

Expand Down Expand Up @@ -644,6 +645,15 @@ function civicase_civicrm_summaryActions(&$actions, $contactID) {
}
}

/**
* Implements hook_civicrm_alterAngular().
*/
function civicase_civicrm_alterAngular(Manager $angular) {
if (CRM_Core_Permission::check([['administer CiviCase', 'administer CiviCRM']])) {
$angular->add(CRM_Civicase_Hook_alterAngular_AngularChangeSet::getForCaseTypeCategoryField());
}
}

/**
* Adds Case Type Category field to the Case Type entity DAO.
*
Expand Down
21 changes: 21 additions & 0 deletions templates/CRM/Civicase/ChangeSet/CaseTypeCategory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div crm-ui-field="{name: 'caseTypeDetailForm.caseTypeCategory', title: ts('Instance')}">
<input
name="caseTypeCategory"
crm-ui-id="caseType.case_type_category"
ng-model="caseType.case_type_category"
crm-entityref="{
entity: 'OptionValue',
api: {
params: {option_group_id: 'case_type_categories'}
},
select: {allowClear: true, multiple: false, placeholder: ts('Select Instance')},
}"
class="big crm-form-text"
/>
<a
href="/civicrm/admin/options/case_type_categories?reset=1"
class="crm-option-edit-link medium-popup crm-hover-button"
target="_blank" >
<i aria-hidden="true" title="Edit Instance" class="crm-i fa-wrench"></i>
</a>
</div>

0 comments on commit 3c5a024

Please sign in to comment.