Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1207 - My Cases dashlet shouldn't crash for users with only my cases access #19689

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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