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

Sort users by name on time tracking page dropdown #1885

Merged
merged 7 commits into from
Sep 3, 2024

Conversation

apoorv1316
Copy link
Contributor

Fixes #1884

@vipulnsward vipulnsward requested review from keshavbiswa and removed request for akhilgkrishnan July 29, 2024 13:53
Copy link
Contributor

@keshavbiswa keshavbiswa left a 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?

@apoorv1316
Copy link
Contributor Author

@keshavbiswa Please review

end

def is_admin?
current_user.has_role?(:owner, current_company) || current_user.has_role?(:admin, current_company)
Copy link
Contributor

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?

Comment on lines 57 to 59
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
Copy link
Contributor

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?

Comment on lines 57 to 59
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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module EmployeeFetcher
module EmployeeMethods

config/application.rb Show resolved Hide resolved

included do
def set_employees
@employees = admin? ? current_company_users : [current_user]
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@keshavbiswa keshavbiswa left a 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.

@apoorv1316 apoorv1316 merged commit 1069157 into develop Sep 3, 2024
1 check passed
@apoorv1316 apoorv1316 deleted the sort-username-time-tracking-dropdown branch September 3, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort users by name on time tracking page dropdown
3 participants