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

How to change the assignee to their group #293

Open
ashrafalzyoud opened this issue Jan 27, 2023 · 7 comments
Open

How to change the assignee to their group #293

ashrafalzyoud opened this issue Jan 27, 2023 · 7 comments

Comments

@ashrafalzyoud
Copy link

Hi all
What the code if the user create issue the assignee her group

@AirTibu
Copy link

AirTibu commented Jan 28, 2023

Hi,

There is a logic error in this request. If I understand correctly, the request is that if a user creates an issue, the issue assignee should be the group of which the user is a member.

The problem with this is that a user can be a member of several groups, if a user is in 3 groups, which group should be assigned to the issue as assignee?

The code below assigns the first group in which the user who created the issue is included:


self.assigned_to = User.current.groups.first

I hope it helps!

@ashrafalzyoud
Copy link
Author

ashrafalzyoud commented Jan 28, 2023

how i can choose (assigned_to_id) from array and this group_id and each group_id for only one project
in my case

if [1, 3, 7, 8, 18, 12, 10, 6, 55, 13]  include?(status_id)
self.assigned_to = [149, 25, 27, 34, 46, 9, 18, 20, 24, 15, 14, 53] .include?(assigned_to_id)
end

the answer is one form assigned _to_id ,and this id its currently member in project
thx @AirTibu for your help

@ashrafalzyoud
Copy link
Author

@AirTibu any news

@picman picman changed the title The user can assigne her group How to change the assignee to their group Mar 23, 2023
@ashrafalzyoud
Copy link
Author

How I can choosing the first option group

@AirTibu
Copy link

AirTibu commented May 11, 2023

Hi,

I'm not sure if I understand your intent correctly, but if everything is correct, you want this:

  1. You have a user, who is the assignee.
  2. Find this user's group, which group is a member of this project
  3. Add this group to the issue as assignee

If so, then use this code


self.assigned_to_id =  = (Project.find(self.project_id).principals.pluck(:id) & User.find(assigned_to_id).group_ids).first  if assigned_to_id && project_id

I hope it helps!

@ashrafalzyoud
Copy link
Author

ashrafalzyoud commented May 11, 2023

Thx for replying me
In my case
The user assigned for another group he not member

I'm using the JavaScript to choose first option in list groups
But I need it in custom work flow

If status id 1 then assigned to id
( First option in list groups)

$('#issue_assigned_to_id').val($('#issue_assigned_to_id > optgroup > option:nth-child(1)').val());

@AirTibu
Copy link

AirTibu commented May 12, 2023

Hi,

Ok, I understand now. Try this code:


@my_group_ids = [149, 25, 27, 34, 46, 9, 18, 20, 24, 15, 14, 53] 

@group_to_assignee = @my_group_ids.index(status_id.to_i)

self.assigned_to = Group.find(@group_to_assignee.to_i) unless @group_to_assignee.nil?


I hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants