Skip to content

Commit

Permalink
don't crash for users with only my cases access
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Feb 28, 2021
1 parent e0a95fa commit cc67bd8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion templates/CRM/Case/Page/DashboardSelector.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@
var selectorClass = '.case-selector-' + list;
var filterClass = '.case-search-options-' + list;

// Determine the url `type` parameter which is a combination of `list` and the `upcoming` checkbox.
// @todo This seems fragile. It makes `list` serve double-duty, and also relies on the fact that when list=all-cases that can only happen for users with all cases permission, which itself is what determines whether the upcoming checkbox is present.
var computeGetCasesType = function(selectorListType) {
return (!$("input[name='upcoming']").length) ?
(selectorListType == 'my-cases' ? 'any' : selectorListType) :
($("input[name='upcoming']").prop('checked') ? 'upcoming' : 'any');
}

CRM.$('table' + selectorClass).data({
"ajax": {
"url": {/literal}'{crmURL p="civicrm/ajax/get-cases" h=0 q="snippet=4&all=`$all`"}'{literal},
"data": function (d) {
d.type = (!$("input[name='upcoming']").length) ? list : $("input[name='upcoming']").prop('checked') ? 'upcoming' : 'any';
d.type = computeGetCasesType(list);
d.case_type_id = $(filterClass + ' select#case_type_id').val() || [];
d.case_type_id = d.case_type_id.join(',');
d.status_id = $(filterClass + ' select#case_status_id').val() || [];
Expand Down

0 comments on commit cc67bd8

Please sign in to comment.