Feature #12704

Project Select on new issue

Added by Adnan Topçu almost 5 years ago. Updated 3 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Issues
Target version:Unplanned
Resolution:

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.

select_project.patch Magnifier (2.08 KB) Bastian B., 2014-05-24 00:23

project-select.patch Magnifier (2.1 KB) Greg T, 2016-10-26 15:46

12704_allow_selecting_subprojects_on_new_issue_page.patch Magnifier (5.45 KB) Marius BALTEANU, 2017-04-11 00:29

12704-before@2x.png (28.4 KB) Go MAEDA, 2017-07-20 02:22

12704-after@2x.png (17.4 KB) Go MAEDA, 2017-07-20 02:22


Related issues

Related to Redmine - Feature #16067: Generic New Issue page New
Duplicated by Redmine - Feature #19838: Project selection while creation a new issue Closed
Duplicated by Redmine - Feature #26639: Enabling creating issue within the project regarding the ... Closed

History

#1 Updated by Toshi MARUYAMA over 3 years ago

#2 Updated by Bastian B. over 3 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 :-)

#3 Updated by Bastian B. over 3 years ago

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

#4 Updated by Quan VN about 3 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

#5 Updated by Alex Stout about 3 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.

#6 Updated by Toshi MARUYAMA about 3 years ago

  • Description updated (diff)

#7 Updated by Toshi MARUYAMA over 2 years ago

  • Duplicated by Feature #19838: Project selection while creation a new issue added

#8 Updated by Sebastian Paluch over 2 years ago

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

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

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

#11 Updated by Sebastian Paluch about 2 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.

#12 Updated by Harish Iyer over 1 year ago

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

#13 Updated by Greg T over 1 year ago

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

#14 Updated by Manuel Morales 12 months ago

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

#15 Updated by Greg T 12 months 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 %>

#16 Updated by Manuel Morales 12 months 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.

#17 Updated by Manuel Morales 12 months 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.)

[...]

#18 Updated by Manuel Morales 12 months 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.

#19 Updated by Greg T 12 months 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.

#20 Updated by Manuel Morales 12 months 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?

#21 Updated by Greg T 12 months ago

Manuel Morales wrote:

Do you have any idea or suggestions?

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

#22 Updated by Alessandro Zucchi 9 months ago

+1

#23 Updated by Marius BALTEANU 6 months 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).

#24 Updated by Michael Weiss 5 months 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

#25 Updated by Michael Weiss 5 months ago

+1

#26 Updated by Marius BALTEANU 5 months 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.

#27 Updated by Mischa The Evil 5 months ago

  • Target version set to Unplanned

I like the change proposed by Marius BALTEANU in note-23. Setting target version to 'Unplanned'.

#28 Updated by Marius BALTEANU 3 months 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.

#29 Updated by Go MAEDA 3 months ago

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

before:

after:

#30 Updated by Marius BALTEANU 2 months ago

  • Duplicated by Feature #26639: Enabling creating issue within the project regarding the subproject added

Also available in: Atom PDF