Defect #24311

Project field disappears when target project disallows user to edit the project

Added by Luka Lüdicke 8 months ago. Updated 7 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Issues
Target version:3.3.2
Resolution:Fixed Affected version:3.3.1

Description

Issue

  1. Editing the Project Field in an Issue reloads the form
  2. On Reloading / Rendering the project field is excluded if the user is not allowed to change the project_id for issues in that project
  3. The field disappears when the user clicks on a project where changing the project field is not allowed
  4. The issue cannot be moved to the other project by that user, however: The list of target projects is calculated by the right to create issues in that project. This means that there is a mismatch.

Goal

The project field should not disappear on selection of a project, either by showing the field more often (lax approach) or reducing the target projects list.

Suggestion

My suggestion for the lax approach is:

# app/views/issues/_form.html.erb
- <% if @issue.safe_attribute?('project_id') && (!@issue.new_record? || @project.nil? || @issue.copy?) %>
+ <% if (@issue.safe_attribute?('project_id') || @issue.allowed_target_projects.include?(@issue.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 %>

issues_form.diff Magnifier - lax_approach (802 Bytes) Luka Lüdicke, 2016-11-11 11:32

Associated revisions

Revision 15959
Added by Jean-Philippe Lang 7 months ago

Project field disappears when target project disallows user to edit the project (#24311).

History

#1 Updated by Luka Lüdicke 8 months ago

#2 Updated by Jean-Philippe Lang 7 months ago

  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Target version set to 3.3.2
  • Resolution set to Fixed

Fixed in r15959 using a slightly different solution and tests added.
Thanks for pointing this out.

#3 Updated by Jean-Philippe Lang 7 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF