Skip to content

Commit

Permalink
Merge pull request #36 from colemanw/caseInfo
Browse files Browse the repository at this point in the history
Add case info to activities on dashboard
  • Loading branch information
colemanw authored Sep 15, 2017
2 parents d2a51a6 + 2ad80d2 commit 6369aa3
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 23 deletions.
13 changes: 10 additions & 3 deletions ang/civicase/ActivityCard.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div civicase-activity-dot="activity"></div>
<h4 class="act-contacts-target" ng-if="activity.target_contact_name && activity.category.indexOf('communication') >= 0">
<strong>{{ ts('To') }}</strong>
<span civicase-activity-contacts="{activity: activity, type: 'target'}"></span>
<span civicase-activity-contacts="activity.target_contact_name"></span>
</h4>
<h4>
<span class="act-subject" ng-if="activity.subject">{{ activity.subject }}</span>
Expand All @@ -24,12 +24,19 @@ <h4>
<div class="act-contacts clearfix">
<div class="act-contacts-target" ng-if="activity.target_contact_name && activity.category.indexOf('communication') < 0">
<strong>{{ ts('With') }}</strong>
<span civicase-activity-contacts="{activity: activity, type: 'target'}"></span>
<span civicase-activity-contacts="activity.target_contact_name"></span>
</div>
<div class="act-contacts-assignee" ng-if="activity.assignee_contact_name">
<strong>{{ ts('Assigned to') }}</strong>
<span civicase-activity-contacts="{activity: activity, type: 'assignee'}"></span>
<span civicase-activity-contacts="activity.assignee_contact_name"></span>
</div>
</div>
<a class="act-case-info" ng-if="activity.case" ng-href="#/case/list?caseId={{ activity.case_id }}">
<span style="background-color: {{ activity.case.color }}" title="{{ activity.case.status }}">
{{ ts('Case: %1', {1: activity.case_id}) }}
</span>
<span>{{ activity.case.case_type }}</span>
<span civicase-activity-contacts="activity.case.client"></span>
</a>
</div>
</div>
9 changes: 4 additions & 5 deletions ang/civicase/ActivityFeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,10 @@
};
if (caseId) {
params.case_id = caseId;
}
else {
if (!$scope.displayOptions.include_case) {
params.case_id = {'IS NULL': 1};
}
} else if (!$scope.displayOptions.include_case) {
params.case_id = {'IS NULL': 1};
} else {
returnParams.return = returnParams.return.concat(['case_id.case_type_id', 'case_id.status_id', 'case_id.contacts']);
}
_.each($scope.filters, function(val, key) {
if (key[0] === '@') return; // Virtual params.
Expand Down
9 changes: 8 additions & 1 deletion ang/civicase/ActivityListItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</a>
<h4 class="act-contacts-target" ng-if="activity.target_contact_name && activity.category.indexOf('communication') >= 0">
<strong>{{ ts('To') }}</strong>
<span civicase-activity-contacts="{activity: activity, type: 'target'}"></span>
<span civicase-activity-contacts="activity.target_contact_name"></span>
</h4>
<h4>
<span class="act-subject" ng-if="activity.subject">{{ activity.subject }}</span>
Expand Down Expand Up @@ -66,5 +66,12 @@ <h4>
</span>
</div>
</div>
<a class="act-case-info" ng-if="activity.case" ng-href="#/case/list?caseId={{ activity.case_id }}">
<span style="background-color: {{ activity.case.color }}" title="{{ activity.case.status }}">
{{ ts('Case: %1', {1: activity.case_id}) }}
</span>
<span>{{ activity.case.case_type }}</span>
<span civicase-activity-contacts="activity.case.client"></span>
</a>
</div>
</div>
6 changes: 3 additions & 3 deletions ang/civicase/CaseListTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ <h4>
</td>
<td ng-show="!viewingCase">{{ item.subject }}</td>
<td ng-show="!viewingCase">
<span class="badge" style="background-color: {{ caseStatuses[item.status_id].color }}">
{{ item.status }}
</span>
<span class="badge" style="background-color: {{ item.color }}">
{{ item.status }}
</span>
</td>
<td ng-show="!viewingCase">{{ item.case_type }}</td>
<td ng-show="!viewingCase">{{ item.manager.display_name }}</td>
Expand Down
2 changes: 1 addition & 1 deletion ang/civicase/DashboardCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
is_current_revision: 1,
is_test: 0,
options: {limit: 10, sort: 'activity_date_time DESC'},
return: ['case_id', 'activity_type_id', 'subject', 'activity_date_time', 'status_id', 'target_contact_name', 'assignee_contact_name', 'is_overdue']
return: ['case_id', 'activity_type_id', 'subject', 'activity_date_time', 'status_id', 'target_contact_name', 'assignee_contact_name', 'is_overdue', 'case_id.case_type_id', 'case_id.status_id', 'case_id.contacts']
}, $scope.activityFilters);
// recent communication
apiCalls.push(['Activity', 'get', _.extend({
Expand Down
48 changes: 38 additions & 10 deletions ang/civicase/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
});

angular.module('civicase').factory('formatActivity', function() {
var activityTypes = CRM.civicase.activityTypes;
var activityStatuses = CRM.civicase.activityStatuses;
var activityTypes = CRM.civicase.activityTypes,
activityStatuses = CRM.civicase.activityStatuses,
caseTypes = CRM.civicase.caseTypes,
caseStatuses = CRM.civicase.caseStatuses;
return function (act, caseId) {
act.category = (activityTypes[act.activity_type_id].grouping ? activityTypes[act.activity_type_id].grouping.split(',') : []);
act.icon = activityTypes[act.activity_type_id].icon;
Expand All @@ -73,6 +75,28 @@
} else {
act.case_id = null;
}
if (act['case_id.case_type_id']) {
act.case = {};
_.each(act, function(val, key) {
if (key.indexOf('case_id.') === 0) {
act.case[key.replace('case_id.', '')] = val;
delete act[key];
}
});
act.case.client = [];
act.case.status = caseStatuses[act.case.status_id].label;
act.case.color = caseStatuses[act.case.status_id].color;
act.case.case_type = caseTypes[act.case.case_type_id].title;
_.each(act.case.contacts, function(contact) {
if (!contact.relationship_type_id) {
act.case.client.push(contact);
}
if (contact.manager) {
act.case.manager = contact;
}
});
delete act.case.contacts;
}
};
});

Expand All @@ -83,6 +107,7 @@
item.myRole = [];
item.client = [];
item.status = caseStatuses[item.status_id].label;
item.color = caseStatuses[item.status_id].color;
item.case_type = caseTypes[item.case_type_id].title;
item.selected = false;
item.is_deleted = item.is_deleted === '1';
Expand Down Expand Up @@ -370,23 +395,26 @@
data: '=civicaseActivityContacts'
},
link: function (scope, elem, attrs) {
var contacts = scope.data.activity[scope.data.type + '_contact_name'];
scope.url = CRM.url;
scope.contacts = [];
_.each(contacts, function(name, cid) {
scope.contacts.push({name: name, cid: cid});
});
if (_.isPlainObject(scope.data)) {
scope.contacts = [];
_.each(scope.data, function (name, cid) {
scope.contacts.push({display_name: name, contact_id: cid});
});
} else {
scope.contacts = scope.data;
}
},
template:
'<a ng-if="contacts.length" href="{{ url(\'civicrm/contact/view\', {cid: contacts[0].cid}) }}">{{ contacts[0].name }}</a> ' +
'<span ng-if="contacts.length === 2">&amp; <a href="{{ url(\'civicrm/contact/view\', {cid: contacts[1].cid}) }}">{{ contacts[1].name }}</a></span>' +
'<a ng-if="contacts.length" href="{{ url(\'civicrm/contact/view\', {cid: contacts[0].contact_id}) }}">{{ contacts[0].display_name }}</a> ' +
'<span ng-if="contacts.length === 2">&amp; <a href="{{ url(\'civicrm/contact/view\', {cid: contacts[1].contact_id}) }}">{{ contacts[1].display_name }}</a></span>' +
'<div class="btn-group btn-group-xs" ng-if="contacts.length > 2">' +
' <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
' + {{ contacts.length - 1 }}' +
' </button>' +
' <ul class="dropdown-menu" >' +
' <li ng-repeat="(index, contact) in contacts" ng-if="index">' +
' <a href="{{ url(\'civicrm/contact/view\', {cid: contact.cid}) }}">{{ contact.name }}</a>' +
' <a href="{{ url(\'civicrm/contact/view\', {cid: contact.contact_id}) }}">{{ contact.display_name }}</a>' +
' </li>' +
' </ul>' +
'</div>'
Expand Down

0 comments on commit 6369aa3

Please sign in to comment.