-
Notifications
You must be signed in to change notification settings - Fork 48
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
PCHR-4019: Allow self leave approver to select leave request status on My Leave in the Leave Request Modal and delete a leave request #2794
Conversation
0dab694
to
ca66f97
Compare
ca66f97
to
de59269
Compare
? initRoleBasedOnSelfLeaveApproverState() | ||
: initRoleBasedOnPermissions()) | ||
.finally(function () { | ||
vm.canManage = vm.isRole('manager') || vm.isRole('admin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this from here, move it to a initCanManage
function, and call that function from the init
sequence after initRole
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I also checked if we need finally
, I don't think so, so I changed to then
@@ -767,10 +790,11 @@ define([ | |||
* | |||
* @return {Promise} | |||
*/ | |||
function loadLoggedInContactId () { | |||
return Session.get().then(function (value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we now don't use Session, can you please remove any reference to it from this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I wonder why linter did not notice this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linter doesn't care if you don't use one of the parameters in your function. I guess it does that in case you need to use the third parameter, but not the second one.
}); | ||
|
||
it('sets the `isSelfLeaveApprover` public property to `true`', function () { | ||
expect(controller.isSelfLeaveApprover).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to check if isSelfLeaveApprover
is set to false in the basic tests
group`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
expect(controller.isSelfLeaveApprover).toBe(true); | ||
}); | ||
|
||
it('sets the `canManage` public property to `true`', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check if it's set to false as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -507,6 +508,13 @@ define([ | |||
].concat(defaultStatuses); | |||
} | |||
|
|||
/** | |||
* Defines if the contact ca manage the leave request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*can
c290da6
to
1438816
Compare
Overview
This PR allows self leave approver to select leave request status on My Leave in the Leave Request Modal and delete a leave request. In other words, they become "admins" on My Leave for their own leave requests if they are self leave approvers.
Before
After
Technical Details
Loading logged in contact instance instead of just their ID
Now we use the
Contact.getLoggedIn
that resolves withContactInstance
instead of callingSession.get
to save some lines of code. We needContactInstance
to callContactInstance.checkIfSelfLeaveApprover
Init role now checks if self leave approver
Why
role = 'admin'
?From the business logic perspective a self leave approver "administers" their own leave requests.
Why
vm.isSelfLeaveApprover = true
?This is a new public property because we want to show some specific UI elements to the self leave approver: Status Selector and Delete button. We don't want to show other admin UI elements, such as, for example, the name of the contact on the top of the modal.
We also cannot only use
vm.canManage
property alone, because the templates also considervm.isSelfRecord
which prevents some UI elements to be shown when creating/editing you own leave request.The solution is to use a combination in the templates:
✅Manual Tests - passed
✅Jasmine Tests - amended and passed
✅JS distributive files - included
⏹CSS distributive files - not needed
⏹Backstop tests - not needed
⏹PHP Unit Tests - not needed