mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Allow to add subtask from context menu (#34303).
Patch by Go MAEDA and Takenori TAKAKI. git-svn-id: http://svn.redmine.org/redmine/trunk@20617 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0cc5b52ac5
commit
f8bf009cd6
@ -36,7 +36,8 @@ class ContextMenusController < ApplicationController
|
||||
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
||||
:copy => User.current.allowed_to?(:copy_issues, @projects) && Issue.allowed_target_projects.any?,
|
||||
:add_watchers => User.current.allowed_to?(:add_issue_watchers, @projects),
|
||||
:delete => @issues.all?(&:deletable?)
|
||||
:delete => @issues.all?(&:deletable?),
|
||||
:add_subtask => @issue && !@issue.closed? && User.current.allowed_to?(:manage_subtasks, @project)
|
||||
}
|
||||
|
||||
@assignables = @issues.map(&:assignable_users).reduce(:&)
|
||||
|
||||
@ -235,11 +235,17 @@ module IssuesHelper
|
||||
|
||||
# Returns a link for adding a new subtask to the given issue
|
||||
def link_to_new_subtask(issue)
|
||||
link_to(l(:button_add), url_for_new_subtask(issue))
|
||||
end
|
||||
|
||||
def url_for_new_subtask(issue)
|
||||
attrs = {
|
||||
:parent_issue_id => issue
|
||||
}
|
||||
attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id')
|
||||
link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs, :back_url => issue_path(issue)))
|
||||
params = {:issue => attrs}
|
||||
params[:back_url] = issue_path(issue) if controller_name == 'issues' && action_name == 'show'
|
||||
new_project_issue_path(issue.project, params)
|
||||
end
|
||||
|
||||
def trackers_options_for_select(issue)
|
||||
|
||||
@ -151,6 +151,10 @@
|
||||
<li><%= context_menu_link l(:button_log_time), new_issue_time_entry_path(@issue),
|
||||
:class => 'icon icon-time-add' %></li>
|
||||
<% end %>
|
||||
<% if @can[:add_subtask] -%>
|
||||
<li><%= context_menu_link l(:button_add_subtask), url_for_new_subtask(@issue),
|
||||
:class => 'icon icon-add' %></li>
|
||||
<% end %>
|
||||
<li><%= context_menu_link l(:button_copy), project_copy_issue_path(@project, @issue),
|
||||
:class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
|
||||
<% else %>
|
||||
|
||||
@ -1160,6 +1160,7 @@ en:
|
||||
button_project_bookmark_delete: Remove bookmark
|
||||
button_filter: Filter
|
||||
button_actions: Actions
|
||||
button_add_subtask: Add subtask
|
||||
|
||||
status_active: active
|
||||
status_registered: registered
|
||||
|
||||
@ -290,6 +290,45 @@ class ContextMenusControllerTest < Redmine::ControllerTest
|
||||
assert_select 'a', :text => 'eCookbook - Shared'
|
||||
end
|
||||
|
||||
def test_context_menu_should_include_add_subtask_link
|
||||
@request.session[:user_id] = 2
|
||||
get(
|
||||
:issues,
|
||||
:params => {
|
||||
:ids => [1]
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
|
||||
assert_select 'a.icon-add[href=?]', '/projects/ecookbook/issues/new?issue%5Bparent_issue_id%5D=1&issue%5Btracker_id%5D=1', :text => 'Add subtask'
|
||||
end
|
||||
|
||||
def test_context_menu_with_closed_issue_should_not_include_add_subtask_link
|
||||
@request.session[:user_id] = 2
|
||||
get(
|
||||
:issues,
|
||||
:params => {
|
||||
:ids => [8]
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
|
||||
assert_select 'a.icon-add', :text => 'Add subtask', :count => 0
|
||||
end
|
||||
|
||||
def test_context_menu_multiple_issues_should_not_include_add_subtask_link
|
||||
@request.session[:user_id] = 2
|
||||
get(
|
||||
:issues,
|
||||
:params => {
|
||||
:ids => [1, 2]
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
|
||||
assert_select 'a.icon-add', :text => 'Add subtask', :count => 0
|
||||
end
|
||||
|
||||
def test_context_menu_with_issue_that_is_not_visible_should_fail
|
||||
get(
|
||||
:issues,
|
||||
|
||||
@ -360,4 +360,11 @@ class IssuesHelperTest < Redmine::HelperTest
|
||||
assert_equal '06/06/2019', issue_due_date_details(issue)
|
||||
end
|
||||
end
|
||||
|
||||
def test_url_for_new_subtask
|
||||
issue = Issue.find(1)
|
||||
params = {:issue => {:parent_issue_id => issue.id, :tracker_id => issue.tracker.id}}
|
||||
assert_equal new_project_issue_path(issue.project, params),
|
||||
url_for_new_subtask(issue)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user