Unverified Commit 784dd9c4 authored by colemanw's avatar colemanw Committed by GitHub

Merge pull request #12236 from agileware/CIVICRM-874

CiviCase, added reference of activities from different timelines.
parents eabff8a8 093f1cfd
......@@ -242,6 +242,8 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
// set activity sets
if (isset($xml->ActivitySets)) {
$definition['activitySets'] = array();
$definition['timelineActivityTypes'] = array();
foreach ($xml->ActivitySets->ActivitySet as $activitySetXML) {
// parse basic properties
$activitySet = array();
......@@ -257,7 +259,11 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
if (isset($activitySetXML->ActivityTypes)) {
$activitySet['activityTypes'] = array();
foreach ($activitySetXML->ActivityTypes->ActivityType as $activityTypeXML) {
$activitySet['activityTypes'][] = json_decode(json_encode($activityTypeXML), TRUE);
$activityType = json_decode(json_encode($activityTypeXML), TRUE);
$activitySet['activityTypes'][] = $activityType;
if ($activitySetXML->timeline) {
$definition['timelineActivityTypes'][] = $activityType;
}
}
}
$definition['activitySets'][] = $activitySet;
......
......@@ -261,6 +261,8 @@
$scope.caseType.definition.caseRoles = $scope.caseType.definition.caseRoles || [];
$scope.caseType.definition.statuses = $scope.caseType.definition.statuses || [];
$scope.caseType.definition.timelineActivityTypes = $scope.caseType.definition.timelineActivityTypes || [];
$scope.selectedStatuses = {};
_.each(apiCalls.caseStatuses.values, function (status) {
$scope.selectedStatuses[status.name] = !$scope.caseType.definition.statuses.length || $scope.caseType.definition.statuses.indexOf(status.name) > -1;
......@@ -288,14 +290,27 @@
}
function addActivityToSet(activitySet, activityTypeName) {
activitySet.activityTypes.push({
name: activityTypeName,
label: $scope.activityTypes[activityTypeName].label,
status: 'Scheduled',
reference_activity: 'Open Case',
reference_offset: '1',
reference_select: 'newest'
});
var activity = {
name: activityTypeName,
label: $scope.activityTypes[activityTypeName].label,
status: 'Scheduled',
reference_activity: 'Open Case',
reference_offset: '1',
reference_select: 'newest'
};
activitySet.activityTypes.push(activity);
if(typeof activitySet.timeline !== "undefined" && activitySet.timeline == "1") {
$scope.caseType.definition.timelineActivityTypes.push(activity);
}
}
function resetTimelineActivityTypes() {
$scope.caseType.definition.timelineActivityTypes = [];
angular.forEach($scope.caseType.definition.activitySets, function(activitySet) {
angular.forEach(activitySet.activityTypes, function(activityType) {
$scope.caseType.definition.timelineActivityTypes.push(activityType);
});
});
}
function createActivity(name, callback) {
......@@ -363,6 +378,7 @@
var idx = _.indexOf(array, item);
if (idx != -1) {
array.splice(idx, 1);
resetTimelineActivityTypes();
}
};
......@@ -462,6 +478,7 @@
if (!$scope.isForkable()) {
CRM.alert(ts('The CiviCase XML file for this case-type prohibits editing the definition.'));
}
});
crmCaseType.controller('CaseTypeListCtrl', function($scope, crmApi, caseTypes) {
......
......@@ -39,7 +39,7 @@ Required vars: activitySet
ui-jq="select2"
ui-options="{dropdownAutoWidth : true}"
ng-model="activity.reference_activity"
ng-options="activityType.name as activityType.label for activityType in activitySet.activityTypes"
ng-options="activityType.name as activityType.label for activityType in caseType.definition.timelineActivityTypes"
>
<option value="">-- Case Start --</option>
</select>
......
......@@ -23,6 +23,7 @@ class CRM_Case_BAO_CaseTypeTest extends CiviUnitTestCase {
'activitySets' => array(),
'activityTypes' => array(),
'caseRoles' => array(),
'timelineActivityTypes' => array(),
)),
'xml' => file_get_contents(__DIR__ . '/xml/empty-lists.xml'),
);
......@@ -42,6 +43,9 @@ class CRM_Case_BAO_CaseTypeTest extends CiviUnitTestCase {
),
),
),
'timelineActivityTypes' => array(
array('name' => 'Open Case', 'status' => 'Completed'),
),
'caseRoles' => array(
array('name' => 'First role', 'creator' => 1, 'manager' => 1),
),
......@@ -80,6 +84,15 @@ class CRM_Case_BAO_CaseTypeTest extends CiviUnitTestCase {
),
),
),
'timelineActivityTypes' => array(
array('name' => 'Open Case', 'status' => 'Completed'),
array(
'name' => 'Meeting',
'reference_activity' => 'Open Case',
'reference_offset' => 1,
'reference_select' => 'newest',
),
),
'caseRoles' => array(
array('name' => 'First role', 'creator' => 1, 'manager' => 1),
array('name' => 'Second role'),
......
......@@ -54,6 +54,9 @@ class api_v3_CaseTypeTest extends CiviCaseTestCase {
),
),
),
'timelineActivityTypes' => array(
array('name' => 'Open Case', 'status' => 'Completed'),
),
'caseRoles' => array(
array('name' => 'First role', 'creator' => 1, 'manager' => 1),
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment