Project

General

Profile

Actions

Feature #12704

closed

Allow selecting subprojects on new issue form

Added by Adnan Topçu about 11 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

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


Related issues

Related to Redmine - Feature #16067: Generic New Issue pageNew

Actions
Related to Redmine - Feature #17286: change project while creating a ticketClosed

Actions
Related to Redmine - Patch #32109: Obey sub-task sharing settings on new issue creationNew

Actions
Has duplicate Redmine - Feature #19838: Project selection while creation a new issueClosed

Actions
Has duplicate Redmine - Feature #26639: Enabling creating issue within the project regarding the subprojectClosed

Actions
Actions #1

Updated by Toshi MARUYAMA about 10 years ago

Actions #2

Updated by Bastian B. almost 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 :-)

Actions #3

Updated by Bastian B. almost 10 years ago

Patch that enables to configure the behavior (to select the project) via the settings.

Actions #4

Updated by Quan VN over 9 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

Actions #5

Updated by Alex Stout over 9 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 Florian S. 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.

Actions #6

Updated by Toshi MARUYAMA over 9 years ago

  • Description updated (diff)
Actions #7

Updated by Toshi MARUYAMA almost 9 years ago

  • Has duplicate Feature #19838: Project selection while creation a new issue added
Actions #8

Updated by Sebastian Paluch over 8 years ago

+1
This is exactly what we need, it is huge effort to navigate between projects, especially when creating subtasks.

Actions #9

Updated by Mustafa Bahadır Pakalın over 8 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.

Actions #10

Updated by Mustafa Bahadır Pakalın over 8 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 ?

Actions #11

Updated by Sebastian Paluch over 8 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.

Actions #12

Updated by Harish Iyer about 8 years ago

Just wanted to check if above is Ok i.e. removing _record from the form. Should I do this in my install?

Actions #13

Updated by Greg T almost 8 years ago

Could you provide a plugin for this or integrate it into the core, please?

Actions #14

Updated by Manuel Morales over 7 years ago

That patch file not working on latest version of redmine. Do you have the updated patch file ?

Actions #15

Updated by Greg T over 7 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 %>
Actions #16

Updated by Manuel Morales over 7 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.

Actions #17

Updated by Manuel Morales over 7 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.)

[...]

Actions #18

Updated by Manuel Morales over 7 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.

Actions #19

Updated by Greg T over 7 years ago

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.

Actions #20

Updated by Manuel Morales over 7 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?

Actions #21

Updated by Greg T over 7 years ago

Manuel Morales wrote:

Do you have any idea or suggestions?

I'm afraid I don't. It works for me.

Actions #22

Updated by Alessandro Zucchi about 7 years ago

+1

Actions #23

Updated by Marius BĂLTEANU almost 7 years ago

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).

Actions #24

Updated by Michael Weiss almost 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

Actions #25

Updated by Michael Weiss almost 7 years ago

+1

Actions #26

Updated by Marius BĂLTEANU almost 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.

Actions #27

Updated by Mischa The Evil almost 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'.

Actions #28

Updated by Marius BĂLTEANU over 6 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.

Actions #29

Updated by Go MAEDA over 6 years ago

Here are screenshots of Marius BALTEANU's patch (12704_allow_selecting_subprojects_on_new_issue_page.patch).

before:

after:

Actions #30

Updated by Marius BĂLTEANU over 6 years ago

  • Has duplicate Feature #26639: Enabling creating issue within the project regarding the subproject added
Actions #31

Updated by Simon Cruise over 6 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...

Actions #32

Updated by Marius BĂLTEANU about 6 years ago

  • File 12704_allow_selecting_subprojects_on_new_issue_page_r17173.patch added

Updated the patch to cleanly apply on the current trunk.

Mischa, Go Maeda, the feature is quite requested and really improves the UX when working with subprojects (it saves at least 3 clicks). Can we propose the patch for the next major release (4.0.0 or 4.1.0)?

Actions #33

Updated by Go MAEDA about 6 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.

Actions #34

Updated by Go MAEDA about 6 years ago

  • Target version changed from Unplanned backlogs to 4.1.0

LGTM, setting target version to 4.1.0.

Actions #35

Updated by Go MAEDA about 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
Actions #36

Updated by Marius BĂLTEANU about 6 years ago

  • File deleted (12704_allow_selecting_subprojects_on_new_issue_page_r17173.patch)
Actions #37

Updated by Marius BĂLTEANU about 6 years ago

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
Actions #38

Updated by Marius BĂLTEANU about 6 years ago

  • Status changed from Needs feedback to New
  • Assignee deleted (Marius BĂLTEANU)
Actions #39

Updated by Go MAEDA about 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.

Actions #40

Updated by Go MAEDA about 6 years ago

  • Subject changed from Project Select on new issue to Allow selecting subprojects on new issue form
Actions #41

Updated by Sebastian Paluch about 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).

Actions #42

Updated by Go MAEDA almost 6 years ago

  • Related to Feature #17286: change project while creating a ticket added
Actions #43

Updated by Anonymous over 5 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

Actions #44

Updated by Go MAEDA almost 3 years ago

  • Related to Patch #32109: Obey sub-task sharing settings on new issue creation added
Actions

Also available in: Atom PDF