Feature #12704
closedAllow selecting subprojects on new issue form
Added by Adnan Topçu almost 12 years ago. Updated about 6 years ago.
0%
Description
happy new years!
As you know, redmine sub task mechanism supported cross-project since version 2.2.
But there is no project field on the new issue form. This is a need, when we creating new issue by the link "Sub task Add" on the parent issue.
Files
select_project.patch (2.08 KB) select_project.patch | Bastian B., 2014-05-24 00:23 | ||
project-select.patch (2.1 KB) project-select.patch | Greg T, 2016-10-26 15:46 | ||
12704_allow_selecting_subprojects_on_new_issue_page.patch (5.45 KB) 12704_allow_selecting_subprojects_on_new_issue_page.patch | Marius BĂLTEANU, 2017-04-11 00:29 | ||
12704-before@2x.png (28.4 KB) 12704-before@2x.png | Go MAEDA, 2017-07-20 02:22 | ||
12704-after@2x.png (17.4 KB) 12704-after@2x.png | Go MAEDA, 2017-07-20 02:22 | ||
12704_allow_selecting_subprojects_on_new_issue_page_17216.patch (4.89 KB) 12704_allow_selecting_subprojects_on_new_issue_page_17216.patch | Marius BĂLTEANU, 2018-02-26 22:33 |
Related issues
Updated by Toshi MARUYAMA over 10 years ago
- Related to Feature #16067: Generic New Issue page added
Updated by Bastian B. over 10 years ago
This can be implemented pretty easily as it seems.
You have to edit
apps/models/issue.rb
and change (starting at line 358)
safe_attributes 'project_id', :if => lambda {|issue, user| if issue.new_record? issue.copy? elsif user.allowed_to?(:move_issues, issue.project) Issue.allowed_target_projects_on_move.count > 1 end }
to
safe_attributes 'project_id', :if => lambda {|issue, user| if issue.new_record? true elsif user.allowed_to?(:move_issues, issue.project) Issue.allowed_target_projects_on_move.count > 1 end }
This will add the project selection drop-down box for all new issues, incl. subtasks.
I am not sure if there are any side effects, so use this hint at your own risk :-)
Updated by Bastian B. over 10 years ago
- File select_project.patch select_project.patch added
Patch that enables to configure the behavior (to select the project) via the settings.
Updated by Quan VN over 10 years ago
Hi Bastian
The patch is working great. However, I hit another wall. I have project1 with only tracker1, and project2 with tracker2. Then from project1 I create a subtask in project2, I expect that the subtask will be tracker2 but it is not possible since the tracker list show only tracker1. Could you find the way for the tracker to be refreshed according to the selected project? Thank you very much
Quan
Updated by Alex Stout about 10 years ago
I too have tried this approach. It's definitely nice and would be the optimal way to go for those who organize everything with a boat-load of projects. I haven't noticed the issue that @Quan has mentioned. When the project is changed in the drop down, the javascript is executed and the correct form is loaded for that project–i.e. the correct fields and correct options.
However, my app has some plugins installed that have some fields on the issues form (particularly redmine_tags), and when the form is loaded for the new project, the plugin's field isn't correctly stylized (as a taggable select list). Essentially, the plugin's javascript is run when the page first loads, but when a new project is selected in the drop down, the plugin's javascript is not rerun as it should be. I haven't been able to track down where these hooks are made nor have I been able to add a js hack that could make the right calls. If this were to be fixed, this would be the way to go for me, but I can't have the tags field broken; it renders it useless and confusing.
Updated by Toshi MARUYAMA over 9 years ago
- Has duplicate Feature #19838: Project selection while creation a new issue added
Updated by Sebastian Paluch over 9 years ago
+1
This is exactly what we need, it is huge effort to navigate between projects, especially when creating subtasks.
Updated by Mustafa Bahadır Pakalın over 9 years ago
Sebastian Paluch wrote:
+1
This is exactly what we need, it is huge effort to navigate between projects, especially when creating subtasks.
That patch file not working on latest version of redmine.
Updated by Mustafa Bahadır Pakalın over 9 years ago
Bastian B. wrote:
Patch that enables to configure the behavior (to select the project) via the settings.
Do u have the updated patch file ?
Updated by Sebastian Paluch about 9 years ago
The patch does not work due to a change done in r13999. The r13999 has actually implemented necessary change from the patch making project_id
safe for new form but at the same time it has restricted project drop down for new issues by !@issue.new_record?
in views\issues\_form.html.erb:
<% if @issue.safe_attribute?('project_id') && (!@issue.new_record? || @project.nil? || @issue.copy?) %>
To allow for project drop down when creating new issue or subtask it is enough to remove the "!" (or entire
!@issue.new_record?
from equation):<% if @issue.safe_attribute?('project_id') && (@issue.new_record? || @project.nil? || @issue.copy?) %>
then the drop down shows up, form gets updated correctly when project is changed, trackers gets updated, parent issue id gets verified against cross project restrictions.
Does anyone see something that could prevent from applying this?
...and related to #1003.
Updated by Harish Iyer almost 9 years ago
Just wanted to check if above is Ok i.e. removing !@issue.new_record from the form. Should I do this in my install?
Updated by Greg T over 8 years ago
Could you provide a plugin for this or integrate it into the core, please?
Updated by Manuel Morales about 8 years ago
That patch file not working on latest version of redmine. Do you have the updated patch file ?
Updated by Greg T about 8 years ago
Manuel Morales wrote:
Do you have the updated patch file ?
Do you mean this? (It works with redmine-3.3.1.)
diff -up redmine-3.2.1/app/views/issues/_form.html.erb.orig redmine-3.2.1/app/views/issues/_form.html.erb --- redmine-3.2.1/app/views/issues/_form.html.erb.orig 2016-03-13 18:18:44.000000000 +0100 +++ redmine-3.2.1/app/views/issues/_form.html.erb 2016-06-08 16:36:32.921088980 +0200 @@ -8,7 +8,8 @@ </p> <% end %> -<% if @issue.safe_attribute?('project_id') && (!@issue.new_record? || @project.nil? || @issue.copy?) %> +<% if @issue.safe_attribute?('project_id') #&& (!@issue.new_record? || @project.nil? || @issue.copy?) +%> <p><%= f.select :project_id, project_tree_options_for_select(@issue.allowed_target_projects, :selected => @issue.project), {:required => true}, :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %></p> <% end %>
Updated by Manuel Morales about 8 years ago
Thank you Gret T,
But I made the change, and even is not working.
Could you send me, your apps/models/issue.rb changes? My version is Redmine 3.2.3.stable
I appreciate your help.
Updated by Manuel Morales about 8 years ago
Greg T wrote:
Manuel Morales wrote:
Do you have the updated patch file ?
Do you mean this? (It works with redmine-3.3.1.)
[...]
Updated by Manuel Morales about 8 years ago
Thank you Gret T,
But I made the change, and even is not working.
Could you send me, your apps/models/issue.rb changes? My version is Redmine 3.2.3.stable
I appreciate your help.
Updated by Greg T about 8 years ago
- File project-select.patch project-select.patch added
Manuel Morales wrote:
Could you send me, your apps/models/issue.rb changes?
I didn't change that. I attach project-select.patch modifying issues_controller.rb.
Updated by Manuel Morales about 8 years ago
Greg T wrote:
Manuel Morales wrote:
Could you send me, your apps/models/issue.rb changes?
I didn't change that. I attach project-select.patch modifying issues_controller.rb.
Thank Greg T for you answer,
I change the file and restart the Apache service, but when new issue are created, it don't show selection field for projects only when copying or edit issues.
Do you have any idea or suggestions?
Updated by Greg T about 8 years ago
Manuel Morales wrote:
Do you have any idea or suggestions?
I'm afraid I don't. It works for me.
Updated by Marius BĂLTEANU over 7 years ago
- File 12704_allow_selecting_subprojects_on_new_issue_page.patch 12704_allow_selecting_subprojects_on_new_issue_page.patch added
Attached is a patch that adds the project field on the new issue form when the current project has subprojects.
When you're on a project with subprojects, if you want to add an issue on a subproject from the parent project page, you need to do various actions. For example:
- select the subproject from the quick selector and then new issue
- go to overview tab, select the subproject and then new issue
Allowing to add an issue on a subproject directly from the parent project it'll be a great improvement from my point of view (we've many projects with subprojects as I described in #9909#note-9).
Updated by Michael Weiss over 7 years ago
Hi, Marius. Your patch is exactly what I am looking for. Which Redmine Version do you use. I am using 3.2.1.stable. By using your patch I've got 2 FAILS:
patching file app/models/issue.rb Hunk #1 succeeded at 1397 (offset -108 lines). Hunk #2 succeeded at 1413 (offset -108 lines). patching file app/models/project.rb patching file app/views/issues/_form.html.erb Hunk #1 FAILED at 9. 1 out of 1 hunk FAILED -- saving rejects to file app/views/issues/_form.html.erb.rej patching file test/functional/issues_controller_test.rb Hunk #1 succeeded at 1604 (offset -208 lines). Hunk #2 succeeded at 1628 with fuzz 1 (offset -208 lines). Hunk #3 succeeded at 1663 (offset -207 lines). patching file test/unit/issue_test.rb Hunk #1 FAILED at 354. 1 out of 1 hunk FAILED -- saving rejects to file test/unit/issue_test.rb.rej
Updated by Marius BĂLTEANU over 7 years ago
Michael Weiss wrote:
Hi, Marius. Your patch is exactly what I am looking for. Which Redmine Version do you use. I am using 3.2.1.stable. By using your patch I've got 2 FAILS:
Hi Michael,
The patch was made against current Redmine trunk and it wasn't tested on 3.2.1 or latest 3.3.3. Hopefully, the patch will be taken into consideration for a future Redmine version.
Updated by Mischa The Evil over 7 years ago
- Target version set to Unplanned backlogs
I like the change proposed by Marius BALTEANU in note-23. Setting target version to 'Unplanned'.
Updated by Marius BĂLTEANU over 7 years ago
Mischa The Evil wrote:
I like the change proposed by Marius BALTEANU in note-23. Setting target version to 'Unplanned'.
Thanks for the feedback, Mischa. Looking forward to see this proposed for a future version.
Updated by Go MAEDA over 7 years ago
- File 12704-before@2x.png 12704-before@2x.png added
- File 12704-after@2x.png 12704-after@2x.png added
Here are screenshots of Marius BALTEANU's patch (12704_allow_selecting_subprojects_on_new_issue_page.patch).
before:
after:
Updated by Marius BĂLTEANU over 7 years ago
- Has duplicate Feature #26639: Enabling creating issue within the project regarding the subproject added
Updated by Simon Cruise about 7 years ago
Is there any chance of this making it into the main? With microservices and multiple interacting systems it is only natural that one parent task is going to require changes in multiple other projects.
It is a clunky process to create the issue and then edit to change project each time as notifications are triggered etc...
Updated by Marius BĂLTEANU almost 7 years ago
- File 12704_allow_selecting_subprojects_on_new_issue_page_r17173.patch added
Updated by Go MAEDA almost 7 years ago
I have tried out the patch and think there isn't any problem to include this feature in the upcoming release. Users will be able to create a subproject's issue when they see the parent project's issues list. I can easily imagine the use case and usefulness of the feature.
The only thing I was worried is that adding a new UI element, the "Project" drop-down, increases the complexity of the new issue form. But I found that it was needless anxiety because the drop-down is displayed only when the project has one or more subprojects.
Updated by Go MAEDA almost 7 years ago
- Target version changed from Unplanned backlogs to 4.1.0
LGTM, setting target version to 4.1.0.
Updated by Go MAEDA over 6 years ago
- Status changed from New to Needs feedback
- Assignee set to Marius BĂLTEANU
Marius, I had to change your code slightly in order to run test/functional/issues_controller_test.rb
. Could you review the change?
I got stuck with the following error while running the test.
Error: IssuesControllerTest#test_get_new_should_not_show_project_selector_for_project_without_subprojects: ArgumentError: unknown keywords: project_id, tracker_id test/functional/issues_controller_test.rb:2347:in `test_get_new_should_not_show_project_selector_for_project_without_subprojects'
To fix the error, I updated the code as follow:
--- test/functional/issues_controller_test.rb.orig 2018-02-26 04:56:07.000000000 +0000
+++ test/functional/issues_controller_test.rb 2018-02-26 04:59:07.000000000 +0000
@@ -2328,7 +2328,10 @@
def test_get_new_should_show_project_selector_for_project_with_subprojects
@request.session[:user_id] = 2
- get :new, :project_id => 1, :tracker_id => 1
+ get :new, :params => {
+ :project_id => 1,
+ :tracker_id => 1
+ }
assert_response :success
assert_select 'select[name="issue[project_id]"]' do
@@ -2344,7 +2347,10 @@
def test_get_new_should_not_show_project_selector_for_project_without_subprojects
@request.session[:user_id] = 2
- get :new, :project_id => 2, :tracker_id => 1
+ get :new, :params => {
+ :project_id => 2,
+ :tracker_id => 1
+ }
assert_response :success
assert_select 'select[name="issue[project_id]"]', 0
Updated by Marius BĂLTEANU over 6 years ago
- File deleted (
12704_allow_selecting_subprojects_on_new_issue_page_r17173.patch)
Updated by Marius BĂLTEANU over 6 years ago
- File 12704_allow_selecting_subprojects_on_new_issue_page_17216.patch 12704_allow_selecting_subprojects_on_new_issue_page_17216.patch added
Indeed, I missed the tests updates for Rails 5.1 in my previous patch.
I'm attaching now the updated patch which include that updates and one more improvement: replaced the projects.count
with projects.length
in order to avoid an unnecessary query to db.
@Go Maeda, on my environment, all the tests from issues_controller_test.rb pass with this patch:
notroot@42f1f3063342:/work$ ruby test/functional/issues_controller_test.rb Run options: --seed 49241 # Running: ............................... ........................................................................................................................................................................................................................................................................................................................................................ Finished in 88.663171s, 4.2295 runs/s, 18.8692 assertions/s. 375 runs, 1673 assertions, 0 failures, 0 errors, 0 skips
Updated by Marius BĂLTEANU over 6 years ago
- Status changed from Needs feedback to New
- Assignee deleted (
Marius BĂLTEANU)
Updated by Go MAEDA over 6 years ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Target version changed from 4.1.0 to 4.0.0
- Resolution set to Fixed
Committed.
Thank you for writing the patch.
Updated by Go MAEDA over 6 years ago
- Subject changed from Project Select on new issue to Allow selecting subprojects on new issue form
Updated by Sebastian Paluch over 6 years ago
This is long waited feature, thanks for implementing it.
The only issue it seems to have is that the select list will not preserve project hierarchy by not showing intermittent projects that do not have trackers enabled (or user has no access to). As a result we get flattered list of projects. This is an issue when we have deep hierarchy with "container" projects in between and sub-project names are not unique, on its own not allowing to clearly identify the project.
It would be good if all projects are shown but select items for those where issue cannot be added are disabled and grayed out.
Similar issue exists in project jump box (#8904).
Updated by Go MAEDA over 6 years ago
- Related to Feature #17286: change project while creating a ticket added
Updated by Anonymous about 6 years ago
what i have to change to get the project dropdown for any project (including projects without subprojects)? u should be able to choose every project, not only subprojects. is this possible?
Environment:
Redmine version 3.4.5.stable
Ruby version 2.3.1-p112 (2016-04-26) [x86_64-linux-gnu]
Rails version 4.2.8
Environment production
Database adapter Mysql2
SCM:
Git 2.7.4
Filesystem
thank u very much for ur help
Updated by Go MAEDA over 3 years ago
- Related to Patch #32109: Obey sub-task sharing settings on new issue creation added