Feature #16045
closedAdd "Author / Previous assignee" group to assignee dropdown in issue form
0%
Description
Intention : assign ticket back to previous assignee easily, without scrolling down the list until I found it.
attached proposed implementation as svn patch. It needs to run "db:migrate"
Missing in the implementation:
- previous assignee in contextual menu
- maybe reusing changes done in r12419
Works good and very popular in my firm.
Files
Related issues
Updated by Gurvan Le Dromaguet almost 11 years ago
Works against 2.4-stable rev 12697
Updated by Toshi MARUYAMA almost 11 years ago
- You missed db migrate file.
- mix tabs and spaces
- please add tests
Updated by Gurvan Le Dromaguet almost 11 years ago
Thanks for pointing out !!! attached file, I will work on adding a test.
Updated by Gurvan Le Dromaguet almost 11 years ago
Toshi MARUYAMA wrote:
- mix tabs and spaces
What is the rule for Redmine ?
Updated by Toshi MARUYAMA almost 11 years ago
Gurvan Le Dromaguet wrote:
Toshi MARUYAMA wrote:
- mix tabs and spaces
What is the rule for Redmine ?
two spaces for indent.
Updated by Samuel Samfra over 10 years ago
dear all, how do I install this ? patch -p0 for the patch ? What about the rb file ? thank you.. I come from the Java world :)
Updated by Gurvan Le Dromaguet over 10 years ago
Samuel Samfra wrote:
dear all, how do I install this ? patch -p0 for the patch ? What about the rb file ? thank you.. I come from the Java world :)
1- apply "patch -p0"
2- copy rb file to db/migrate
3- run "RAILS_ENV=production rake db:migrate"
Updated by Go MAEDA about 8 years ago
- Has duplicate Feature #24319: Last assigned to option in the Assignee selection list added
Updated by Luka Lüdicke about 8 years ago
I have a solution for this which does not require an extra column in the database for this, the information can be gathered from the journal_details
I am mentioning it just in case the reason for ignoring this proposal is the extra column.
Updated by Go MAEDA about 8 years ago
Luka Lüdicke wrote:
I have a solution for this which does not require an extra column in the database for this, the information can be gathered from the
journal_details
Sounds great. Could you attach your patch to this issue?
Updated by Luka Lüdicke about 8 years ago
Alright, this from how I patched it at our company.
As you can see from the comments, it is a work in progress.
If you like it and want to include it, I can make a "cleaner" diff and add a unit test for the last_assignee method.
(my colleagues really love the feature)
things to look out for:
- the option should not come up if current user und last_assignee are the same
- the option should not come up if last_assignee is nil
- when there is old assignee (new issue), the last_assignee should be the author (TODO)
- the option should not appear in issue category and bulk update
Updated by Luka Lüdicke about 8 years ago
- File last_assignee_wip.diff last_assignee_wip.diff added
Updated by Luka Lüdicke over 7 years ago
Luka Lüdicke wrote:
If you like it and want to include it, I can make a "cleaner" diff and add a unit test for the last_assignee method.
like I said, if you like it I would make the effort for a clean patch that you could "just" apply...
Updated by Luka Lüdicke over 7 years ago
suggestions for specs
Test Plan¶
Edit Issue¶
- open issue edit form
- use select box
- expect: last assignee is shown in the fist options
- expect: assignment to that user is successful
bulk edit¶
- open multiple issues with batch edit
- expect: successful page load and no last assignee option in assigned_to select box
Issue Category¶
- open project settings configuration
- open issue categories tab
- edit issue category
- expect: successful page load and no last assignee option in assigned_to select box
New Issue¶
- create new issue with an assignee
- open edit page of that issue
- expect: last assignee shows the author of the issue
- expect: assignment to the user is successful
Updated by Albrecht Dreß almost 7 years ago
I applied the patch “last_assignee_wip.diff” to a standard Debian Stretch Redmine (v. 3.3.1), and it works somehow – only the value in the combo reads
<< <span class="translation_missing"; title="translation missing: en.issue.last_assignee">Last Assignee</span> >>Anything I missed here?
BTW, it would be cool if the Last Assignee could be added to the Field Permissions in the workflow configuration, i.e. as an additional option for the Assignee field, which would actually force setting the previous assignee whenever the ticket is edited. Think of a typical (for me) use case: developer A needs feedback from reporter R, who has only the permission to set the Assignee field to the previous one. So A just sets the assignee to R. Now, when R edits the ticket, it will automatically be assigned back to A, avoiding all problems of a ticket mistakenly being assigned to another person. Would such an implementation be possible?
Updated by Albrecht Dreß almost 7 years ago
Albrecht Dreß wrote:
I applied the patch “last_assignee_wip.diff” to a standard Debian Stretch Redmine (v. 3.3.1), and it works somehow – only the value in the combo reads
It appears that changing in app/helpers/application_helper.rb
the line
s << content_tag('option', "<< #{t('issue.last_assignee', name: User.find_by_id(last_assignee_id).try(:name))} >>", value: last_assignee_id) if (last_assignee_id && (last_assignee_id != User.current.id))to
s << content_tag('option', "<< #{l(:last_assignee, name: User.find_by_id(last_assignee_id).try(:name))} >>", value: last_assignee_id) if (last_assignee_id && (last_assignee_id != User.current.id))fixes this.
However, now the wrong “last assignee” is displayed…
After printing some debugging output, it seems that the journals in app/models/issue.rb
, last_assigned_to
are actually sorted as latest first. Replacing
journals.reverse_each do |j|by
journals.each do |j|seems to do the right thing. Can you confirm this is the proper solution?
Updated by Mizuki ISHIKAWA over 6 years ago
- File previous-assignee-v2.0.patch previous-assignee-v2.0.patch added
- File previous-assignee-v2.1.patch previous-assignee-v2.1.patch added
Thank you for sharing your patch, Luka Lüdicke.
I think this feature will be useful in projects with many users.
I made some changes, such as adding a test to your patch.( and I removed it because some changes for German were included. )
→ previous-assignee-v2.0.patch
Since I think that p"revious_assignee" is more appropriate than "last_assignee", I also created a version patch that replaced the "previous".
→ previous-assignee-v2.1.patch
Albrecht Dreß wrote:
However, now the wrong “last assignee” is displayed…
After printing some debugging output, it seems that the journals in
app/models/issue.rb
,last_assigned_to
are actually sorted as latest first. Replacing [...] by [...] seems to do the right thing. Can you confirm this is the proper solution?
In my environment I seemed to work normally even with reverse_each.
Therefore, I use reverse_each also in the patch attached by me.
Updated by Albrecht Dreß over 6 years ago
Mizuki ISHIKAWA wrote:
Albrecht Dreß wrote:
However, now the wrong “last assignee” is displayed…
After printing some debugging output, it seems that the journals in
app/models/issue.rb
,last_assigned_to
are actually sorted as latest first. Replacing [...] by [...] seems to do the right thing. Can you confirm this is the proper solution?In my environment I seemed to work normally even with reverse_each. Therefore, I use reverse_each also in the patch attached by me.
Hmmm, strange. Which Redmine version do you use?
Updated by Mizuki ISHIKAWA over 6 years ago
Albrecht Dreß wrote:
Hmmm, strange. Which Redmine version do you use?
I tested on trunk( r17463 ) and 3.4 versions.
When I checked sql on rails console, it looks like ascending order.
[1] pry(main)> puts Journal.all.to_sql SELECT "journals".* FROM "journals" => nil [2] pry(main)> issue = Issue.first ~~ [3] pry(main)> puts issue.journals.to_sql SELECT "journals".* FROM "journals" WHERE "journals"."journalized_id" = 1 AND "journals"."journalized_type" = 'Issue' => nil
thanks
Updated by Go MAEDA over 6 years ago
- Related to Feature #19501: Assign issue to <<author>> added
Updated by Go MAEDA about 6 years ago
- Target version set to Candidate for next major release
Updated by Go MAEDA about 6 years ago
- Target version changed from Candidate for next major release to 4.1.0
The patch looks good to me. Setting target version to 4.1.0.
Updated by Go MAEDA almost 6 years ago
previous_assigned_to
method in the patch should return nil
if no previous assignee is found, but it returns Journal::ActiveRecord_Associations_CollectionProxy
which is the return value of journals.reverse_each
.
Probably we should add nil
at the end of the method.
# Returns the previous assignee from the issue history
def previous_assigned_to
journals.reverse_each do |j|
previous_assignee_change = j.detail_for_attribute 'assigned_to_id'
return User.find_by(id: previous_assignee_change.old_value.to_i) if previous_assignee_change && previous_assignee_change.old_value
end
nil
end
Updated by Go MAEDA over 5 years ago
- Related to Feature #14602: Assignee list should be (optionally) ordered by probability added
Updated by Go MAEDA over 5 years ago
- Related to Feature #23072: Speed-Up the setting of "assigned to" by showing good guesses at the top of the list added
Updated by Go MAEDA over 5 years ago
- Target version changed from 4.1.0 to Candidate for next major release
Updated by Mizuki ISHIKAWA over 1 year ago
Fixed conflicts with the latest code and added tests.
Updated by Go MAEDA 4 months ago
I have updated the patch as follows:
1. Changed the method name from Issue#previous_assigned_to to Issue#prior_assigned_to
This change was made to avoid confusion with the existing Issue#previous_assignee method, which serves a different purpose.
2. Optimized Issue#prior_assigned_to
The method was optimized to retrieve the previous assignee id using a single query.
Before optimization:
redmine-app(dev)> Issue.find(30).previous_assigned_to Issue Load (0.1ms) SELECT "issues".* FROM "issues" WHERE "issues"."id" = ? LIMIT ? [["id", 30], ["LIMIT", 1]] Journal Load (0.1ms) SELECT "journals".* FROM "journals" WHERE "journals"."journalized_id" = ? AND "journals"."journalized_type" = ? [["journalized_id", 30], ["journalized_type", "Issue"]] JournalDetail Load (0.1ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 55]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 54]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 53]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 52]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 51]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 50]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 49]] JournalDetail Load (0.1ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 48]] JournalDetail Load (0.0ms) SELECT "journal_details".* FROM "journal_details" WHERE "journal_details"."journal_id" = ? [["journal_id", 47]] User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."type" = ? AND "users"."id" = ? LIMIT ? [["type", "User"], ["id", 1], ["LIMIT", 1]]
After optimization:
redmine-app(dev)> Issue.find(30).prior_assigned_to Issue Load (0.3ms) SELECT "issues".* FROM "issues" WHERE "issues"."id" = ? LIMIT ? [["id", 30], ["LIMIT", 1]] Journal Pluck (0.2ms) SELECT "old_value" FROM "journals" INNER JOIN "journal_details" "details" ON "details"."journal_id" = "journals"."id" WHERE "journals"."journalized_id" = ? AND "journals"."journalized_type" = ? AND "details"."prop_key" = ? AND "details"."old_value" IS NOT NULL ORDER BY "journals"."id" DESC LIMIT ? [["journalized_id", 30], ["journalized_type", "Issue"], ["prop_key", "assigned_to_id"], ["LIMIT", 1]] Principal Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Updated by Go MAEDA 4 months ago
- File clipboard-202409031826-4kecg.png clipboard-202409031826-4kecg.png added
- File previous-assignee-v5.patch previous-assignee-v5.patch added
I have updated the patch again.
In the new patch, I have added an optgroup
labeled "Author / Prior assignee", allowing users to select not only the previous assignee but also the issue’s author. The author is displayed first, followed by the prior assignee.
This enhancement addresses a feature request posted as #19501, the feature to quickly select the issue's author.
Updated by Go MAEDA 4 months ago
- Related to Feature #35282: Assign to former/previous assignee short cut added
Updated by Go MAEDA 4 months ago
- File previous-assignee-v6.patch added
- File clipboard-202409040942-dihus.png clipboard-202409040942-dihus.png added
I have slightly updated the patch. The revised patch always shows the author and prior assignee even if they are unassignable.
The previous patch did not show the author or prior assignee when they were unassignable, for example, they were locked or removed from the projects' members after their activity. However, I found the behavior confusing and may be mistaken for a defect of Redmine. So, I have improved the patch to display an unassignable author or prior assignee in disabled state.
Updated by Marius BĂLTEANU 3 months ago
- <<me>>
- in "Author / Prior assignee" group because you're the author of the new issue
- in the "User" group
- if we really want to add a new group, maybe it is better to name it "Involved" which is a term already used in the notification setting and it means that the user is author, assignee or prior assignee. Also, this allows us on future development to add new users that are already involved in the issue somehow.
- if we don't want to a new group, maybe it is good enough to add the author and the prior assignee right after <<me>> (which is first entry) and add the label next to the name, something like Redmine Admin (Author), John Doe (Previous assignee).
What do you think?
Updated by Go MAEDA 3 months ago
- File clipboard-202409101910-mqn4m.png clipboard-202409101910-mqn4m.png added
- File clipboard-202409101913-akkjl.png clipboard-202409101913-akkjl.png added
- File previous-assignee-v7.patch previous-assignee-v7.patch added
Marius, thank you for reviewing the patch.
Marius BĂLTEANU wrote in #note-36:
This is nice, but I think on new issue form, we should not show the new group because in most of the cases you're going to see your user three times:
I have updated the patch not to display the new group on the "New issue" form.
Also, two additional thoughts on this:
- if we really want to add a new group, maybe it is better to name it "Involved" which is a term already used in the notification setting and it means that the user is author, assignee or prior assignee. Also, this allows us on future development to add new users that are already involved in the issue somehow.
- if we don't want to a new group, maybe it is good enough to add the author and the prior assignee right after <<me>> (which is first entry) and add the label next to the name, something like Redmine Admin (Author), John Doe (Previous assignee).
I have changed the group name to "Involved users".
I would still like to add the new group because the dropdown looks messy to me without it, and the name like "John Smith (Previous assignee)" is too long. Please see the following screenshots.
Updated by Go MAEDA 3 months ago
I have updated the patch.
In #note-37, I renamed the group to "Involved users" following the suggestion in #note-36. However, I later felt that this name was somewhat ambiguous, so I changed it to "Author / Previous assignee" in the committed code. That said, in the i18n translation files, the label remains as label_involved_principals
, and the variable names in the code also still use the word "involved". This should allow for future extension to display other types of users, in which case we could simply update the translation to “Involved” or another appropriate term.
From config/locales/en.yml:
label_involved_principals: Author / Previous assignee
Updated by Go MAEDA 3 months ago
- Subject changed from Add "Previous Assignee" entry when changing issue assignee to Add "Author / Previous assignee" group to assignee dropdown in issue form
- Status changed from New to Closed
- Assignee set to Go MAEDA
Committed the patch in r23059.
The assignee dropdown now has a new options group "Author / Previous assignee" and you can choose the author and the previous assignee from there.
Updated by Pete Davis 2 months ago
This is exciting to see being developed. I have a simple question (I think) but appreciate it may totally not fit with this work.
The idea is that on any issue, alongside the EDIT | WATCH | COPY options (on the top+bottom right of the screen), we add another which is REPLY which then triggers much of what you are working towards, namely to ensure the assignee is changed back to the person who just submitted the ticket or the comment.
Does this idea have any validity to others? It seems to simply the steps - namely instead of clicking EDIT and having to do anything to set the assignee to the prior assignee, you just click on REPLY.
I dare say there could be a bunch of workflows I am not considering - but for over 90% of your usage, we are commenting and resetting assignee to the person who previously was the assignee.
Just a thought. Appreciate your efforts.