-
Notifications
You must be signed in to change notification settings - Fork 52
reduce list of projects for admin resolves #1187 #1238
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
base: dev
Are you sure you want to change the base?
Changes from 4 commits
b0bc997
b5e7fc6
bc5dac7
29bcd5d
7880426
816df7d
232d7b7
5941bee
809af83
69f24cb
f35dd41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,6 +118,22 @@ def group_select(parameter_name = "group_id", options = {}, select_tag_options = | |
| selected = selector.to_s | ||
| end | ||
|
|
||
| # for Admin filter out only public, invisible or non_assignable to reduce the clutter | ||
| if current_user.has_role? :admin_user | ||
| current_user_id = current_user.id | ||
MontrealSergiy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| admin_ids = AdminUser.all.pluck(:id) || [] | ||
| groups = groups.select do |g| | ||
| ( g.is_a?(SystemGroup) || # everyone group, to make a private tool public | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't there a better way to generate this list? Isn't this equivalent to groups = SystemGroup.all.to_a | WorkGroup.where(:creator_id => admin_ids).to_a(or close to that?) |
||
| g.is_a?(UserGroup) && (admin_ids & g.user_ids).present? || # admin usergroups | ||
| g.public || | ||
| g.invisible || | ||
| g.not_assignable && (g.user_ids & admin_ids ).present? || # notassingable admin groups | ||
| g.not_assignable && admin_ids.include?(g.creator_id) || # notassignable created by admin | ||
| (selected == g.id.to_s) || selected.include?(g.id.to_s) # already selected | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| # Optimize the labels for UserGroups and SiteGroups, by extracting in a hash | ||
| group_labels = {} | ||
| group_labels.merge!(UserGroup.prepare_pretty_labels(groups)) | ||
|
|
@@ -145,15 +161,17 @@ def group_select(parameter_name = "group_id", options = {}, select_tag_options = | |
|
|
||
| # Step 1: My Work Projects first | ||
| ordered_category_grouped << [ "My Work Projects", category_grouped_pairs.delete("My Work Projects") ] if category_grouped_pairs["My Work Projects"] | ||
|
|
||
| ordered_category_grouped << [ "My Public Work Projects", category_grouped_pairs.delete("My Public Work Projects") ] if category_grouped_pairs["My Public Work Projects"] | ||
| # Step 2: All personal work projects first | ||
| category_grouped_pairs.keys.select { |proj| proj =~ /Personal Work Projects/ }.sort.each do |proj| | ||
| category_grouped_pairs.keys.select { |proj| proj =~ /Personal (Public )?Work Projects/ }.sort.each do |proj| | ||
| ordered_category_grouped << [ proj, category_grouped_pairs.delete(proj) ] | ||
| end | ||
|
|
||
| # Step 3: Other project categories, in that order | ||
| [ "Shared Work Projects", "Empty Work Projects", "Site Projects", "User Projects", "System Projects", "Invisible Projects", "Everyone Projects" ].each do |proj| | ||
| ordered_category_grouped << [ proj, category_grouped_pairs.delete(proj) ] if category_grouped_pairs[proj] | ||
| proj = proj.sub(" ", " Public ") | ||
| ordered_category_grouped << [ proj, category_grouped_pairs.delete(proj) ] if category_grouped_pairs[proj] | ||
|
|
||
| end | ||
|
|
||
| # Step 4: Other mysterious categories ?!? | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,17 @@ def self.prepare_pretty_category_names(groups = [], as_user = nil) | |
| wgs | ||
| end | ||
|
|
||
| def pretty_category_name(as_user) #:nodoc: | ||
| def pretty_category_name(as_user = nil) #:nodoc: | ||
| category = pretty_category_name_no_pub(as_user) | ||
| if category.present? && self.public && ! category.include?('Public') && as_user.has_role?(:admin_user) | ||
| category.sub(" ", " Public ") | ||
| # category.split(' ', 2).insert(1, "Public").join # works even for empty str | ||
| else | ||
| category | ||
| end | ||
| end | ||
|
|
||
| def pretty_category_name_no_pub(as_user) #:nodoc: | ||
|
||
| return @_pretty_category_name if @_pretty_category_name | ||
| if self.invisible? | ||
| @_pretty_category_name = 'Invisible Project' | ||
|
|
||
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.
When reading the Issue:
I think to keep the old groups and then remove only the
private work projectswill do what we want.Instead of a long selection with a lot of conditions.
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.
that's was @prioux suggestion keep unassignable groups
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.
as a compromise maybe keep all the nonassignable group, rather than admin related