diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb index 244f9c54e0..5ccdb1c0a0 100644 --- a/app/views/context_menus/issues.html.erb +++ b/app/views/context_menus/issues.html.erb @@ -116,7 +116,33 @@ <% end %> + <% if @safe_attributes.include?('start_date') || @safe_attributes.include?('due_date') %> +
  • <%= context_menu_link "#{l(:field_start_date)} / #{l(:field_due_date)}", '#', :onclick => "showModal('bulk_update_date', '350px'); return false;" %>
  • + + <% end %> <% if @can[:add_watchers] %>
  • <%= l(:label_issue_watchers) %> @@ -154,3 +180,12 @@ <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %> +<%= javascript_tag do %> +$('input[data-disables]').change(function() { + if ($(this).prop('checked')){ + $($(this).data('disables')).attr('disabled', true).val(''); + } else { + $($(this).data('disables')).attr('disabled', false); + } +}); +<% end %> \ No newline at end of file diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index 60ffdb819f..78db6733ee 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -35,8 +35,9 @@ class ContextMenusControllerTest < Redmine::ControllerTest def test_context_menu_one_issue @request.session[:user_id] = 2 + issue = Issue.find(1) get :issues, :params => { - :ids => [1] + :ids => [issue.id] } assert_response :success @@ -54,6 +55,12 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' # Assignees assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' + # Start date / Due date + assert_select 'a[href=?]', '#', :text => 'Start date / Due date', :onclick => "showModal('bulk_update_date', '350px'); return false;" + assert_select 'div#bulk_update_date' do + assert_select "input[name='issue[start_date]'][value=?]", issue.start_date.to_s + assert_select "input[name='issue[due_date]'][value=?]", issue.due_date.to_s + end end def test_context_menu_one_issue_by_anonymous @@ -247,6 +254,20 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a', :text => 'eCookbook - Shared' end + def test_context_menu_should_not_include_a_date_form_if_date_attributes_are_unsafe + issue = Issue.find(1) + # Change start_date and due_date to unsafe attributes + issue.tracker.core_fields = [] + issue.tracker.save + + @request.session[:user_id] = 2 + get :issues, :params => { + :ids => [issue.id] + } + assert_response :success + assert_select 'a[href=?]', '#', {:text => 'Date', :onclick => "showModal('bulk_update_date', '350px'); return false;", :count => 0} + end + def test_context_menu_with_issue_that_is_not_visible_should_fail get :issues, :params => { :ids => [1, 4] # issue 4 is not visible