-
Notifications
You must be signed in to change notification settings - Fork 73
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
Sort users by name on time tracking page dropdown #1885
Conversation
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.
It seems like we're duplicating the code, is it possible to extract this out to a reusable module?
@keshavbiswa Please review |
end | ||
|
||
def is_admin? | ||
current_user.has_role?(:owner, current_company) || current_user.has_role?(:admin, current_company) |
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 you check if it's possible to add both together, in one check?
def set_is_admin | ||
@is_admin = current_user.has_role?(:owner, current_company) || current_user.has_role?(:admin, current_company) | ||
@is_admin = is_admin? | ||
end |
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 you try removing this?
def set_is_admin | ||
@is_admin = current_user.has_role?(:owner, current_company) || current_user.has_role?(:admin, current_company) | ||
@is_admin = is_admin? | ||
end |
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 you try removing this?
@@ -0,0 +1,19 @@ | |||
# frozen_string_literal: true | |||
|
|||
module EmployeeFetcher |
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.
module EmployeeFetcher | |
module EmployeeMethods |
|
||
included do | ||
def set_employees | ||
@employees = admin? ? current_company_users : [current_user] |
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.
There is an inconsistency of data being sent here.
If admin
is true:, we're sending only :id, :first_name, :last_name, but if it's false then we're sending current_user
to the array.
Can you check if it's possible to just send id, first_name, last_name or just send the whole object?
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.
Looks good, can we replace the slices of data with the full data itself? Seems easier that way and makes it reusable.
Fixes #1884