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

Remove ad-hoc client-side variable in favor of the one already available #795

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ang/civicase-base/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.constant('includeActivitiesForInvolvedContact', configuration.includeActivitiesForInvolvedContact)
.constant('civicaseSingleCaseRolePerType', configuration.civicaseSingleCaseRolePerType)
.constant('dateInputFormatValue', civiCrmConfig.dateInputFormat)
.constant('loggedInContactId', civiCrmConfig.user_contact_id)
.constant('loggedInContactId', civiCrmConfig.cid)
.constant('webformsList', {
isVisible: configuration.showWebformsListSeparately,
buttonLabel: configuration.webformsDropdownButtonLabel
Expand Down
1 change: 0 additions & 1 deletion ang/civicase.ang.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function load_resources() {
->addSetting([
'config' => [
'enableComponents' => CRM_Core_Config::singleton()->enableComponents,
'user_contact_id' => (int) CRM_Core_Session::getLoggedInContactID(),
],
]);
}
Expand Down
8 changes: 4 additions & 4 deletions ang/civicase/case/search/directives/search.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
*/
function caseManagerIsMe () {
return !!$scope.filters.case_manager && $scope.filters.case_manager.length === 1 &&
parseInt($scope.filters.case_manager[0], 10) === CRM.config.user_contact_id;
parseInt($scope.filters.case_manager[0], 10) === CRM.config.cid;
}

/**
Expand Down Expand Up @@ -373,7 +373,7 @@
function isFilterEqualToLoggedInUser (filterName) {
var filterValue = $scope.filters[filterName];
var isEqualToUserContactId = filterValue === 'user_contact_id';
var isSelectingLoggedInUser = _.isEqual(filterValue, [CRM.config.user_contact_id]);
var isSelectingLoggedInUser = _.isEqual(filterValue, [CRM.config.cid]);

return isEqualToUserContactId || isSelectingLoggedInUser;
}
Expand All @@ -400,11 +400,11 @@
function relationshipTypeWatcher () {
if ($scope.relationshipType) {
$scope.relationshipType[0] === 'is_case_manager'
? $scope.filters.case_manager = [CRM.config.user_contact_id]
? $scope.filters.case_manager = [CRM.config.cid]
: delete ($scope.filters.case_manager);

if ($scope.relationshipType[0] === 'is_involved') {
$scope.filters.contact_involved = [CRM.config.user_contact_id];
$scope.filters.contact_involved = [CRM.config.cid];
$scope.filters.has_activities_for_involved_contact =
includeActivitiesForInvolvedContact ? 1 : 0;
} else {
Expand Down
2 changes: 1 addition & 1 deletion ang/civicase/contact/services/contact.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
this.getCurrentContactID = function () {
var url = new URL(window.location.href);

return url.searchParams.get('cid') !== null ? url.searchParams.get('cid') : CRM.config.user_contact_id;
return url.searchParams.get('cid') !== null ? url.searchParams.get('cid') : CRM.config.cid;
};
});
})(angular, CRM.$, CRM._, CRM);
6 changes: 3 additions & 3 deletions ang/civicase/dashboard/directives/dashboard.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/
$scope.linkToManageCase = function (type, status) {
var cf = { case_type_category: $scope.currentCaseCategory };
var userContactId = [CRM.config.user_contact_id];
var userContactId = [CRM.config.cid];

if (type) {
cf.case_type_id = [type];
Expand Down Expand Up @@ -107,11 +107,11 @@
*/
function caseRelationshipTypeWatcher (newValue) {
newValue === 'is_case_manager'
? $scope.activityFilters.case_filter.case_manager = CRM.config.user_contact_id
? $scope.activityFilters.case_filter.case_manager = CRM.config.cid
: delete ($scope.activityFilters.case_filter.case_manager);

if (newValue === 'is_involved') {
$scope.activityFilters.case_filter.contact_involved = { IN: [CRM.config.user_contact_id] };
$scope.activityFilters.case_filter.contact_involved = { IN: [CRM.config.cid] };
$scope.activityFilters.case_filter.has_activities_for_involved_contact =
includeActivitiesForInvolvedContact ? 1 : 0;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
});

it('sets the case manager filter equal to my id', () => {
expect($scope.filters.case_manager).toEqual([CRM.config.user_contact_id]);
expect($scope.filters.case_manager).toEqual([CRM.config.cid]);
});
});

Expand All @@ -173,7 +173,7 @@
});

it('sets the contact id filter equal to my id', function () {
expect($scope.filters.contact_involved).toEqual([CRM.config.user_contact_id]);
expect($scope.filters.contact_involved).toEqual([CRM.config.cid]);
});

it('filters by case activities related to the involved contact', () => {
Expand Down Expand Up @@ -304,7 +304,7 @@
});

it('sets the case manager filter equal to the current logged in user id', () => {
expect($scope.filters.case_manager).toEqual([CRM.config.user_contact_id]);
expect($scope.filters.case_manager).toEqual([CRM.config.cid]);
});
});

Expand All @@ -324,7 +324,7 @@
});

it('sets the contact involved filter equal to the current logged in user id', () => {
expect($scope.filters.contact_involved).toEqual([CRM.config.user_contact_id]);
expect($scope.filters.contact_involved).toEqual([CRM.config.cid]);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

it('filters the cases and activties where the user is the manager', function () {
expect($scope.activityFilters.case_filter).toEqual(jasmine.objectContaining({
case_manager: CRM.config.user_contact_id
case_manager: CRM.config.cid
}));
});
});
Expand All @@ -78,7 +78,7 @@

it('filters the cases and activties where the user is involved', function () {
expect($scope.activityFilters.case_filter).toEqual(jasmine.objectContaining({
contact_involved: { IN: [CRM.config.user_contact_id] }
contact_involved: { IN: [CRM.config.cid] }
}));
});

Expand Down Expand Up @@ -129,7 +129,7 @@
case_type_category: '1',
case_type_id: ['type'],
status_id: ['status'],
case_manager: [CRM.config.user_contact_id]
case_manager: [CRM.config.cid]
})
}));
});
Expand All @@ -150,7 +150,7 @@
case_type_category: '1',
case_type_id: ['type'],
status_id: ['status'],
contact_involved: [CRM.config.user_contact_id]
contact_involved: [CRM.config.cid]
})
}));
});
Expand Down
2 changes: 1 addition & 1 deletion ang/test/mocks/data/crm.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'CiviReport',
'CiviCase'
],
user_contact_id: 203,
cid: 203,
isFrontend: false,
wysisygScriptLocation: '/sites/all/modules/civicrm/js/wysiwyg/crm.ckeditor.js',
CKEditorCustomConfig: {
Expand Down