Skip to content

Commit

Permalink
Merge pull request #2811 from compucorp/PCHR-4094-add-admin-in-the-ma…
Browse files Browse the repository at this point in the history
…nagees-list

PCHR-4094: Add admin to leave request managees list
  • Loading branch information
igorpavlov authored Aug 2, 2018
2 parents 0f6bf79 + 0659b91 commit 1844505
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,9 @@ define([

/**
* Loads the managees of currently logged in user
* If a contact is pre-selected, then a single managee is loaded.
* If user is an admin, then all contacts, including the admin, are loaded.
* If user is a manager, then only contacts they manage are loaded.
*
* @return {Promise}
*/
Expand All @@ -828,10 +831,7 @@ define([
// In case of general administration
return Contact.all()
.then(function (contacts) {
vm.managedContacts = _.remove(contacts.list, function (contact) {
// Removes the admin from the list of contacts
return contact.id !== loggedInContact.id;
});
vm.managedContacts = contacts.list;
});
} else {
// In any other case (including managing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@

describe('admin opens leave request popup in create mode', function () {
var leaveRequest;
var adminId = '206';
var adminId = CRM.vars.leaveAndAbsences.contactId.toString();

beforeEach(function () {
leaveRequest = LeaveRequestInstance.init();
Expand All @@ -1151,8 +1151,8 @@
expect(controller.isRole('admin')).toBeTruthy();
});

it('does not contain admin in the list of managees', function () {
expect(_.find(controller.managedContacts, { 'id': adminId })).toBeUndefined();
it('contains admin in the list of managees', function () {
expect(!!_.find(controller.managedContacts, { 'id': adminId })).toBe(true);
});
});
});
Expand Down

0 comments on commit 1844505

Please sign in to comment.