Patch #28861 » Add-dates-on-context-menu.patch
| app/views/context_menus/issues.html.erb | ||
|---|---|---|
|
</ul>
|
||
|
</li>
|
||
|
<% end %>
|
||
|
<% if @safe_attributes.include?('start_date') || @safe_attributes.include?('due_date') %>
|
||
|
<li><%= context_menu_link l(:label_date), '#', :onclick => "showModal('bulk_update_date', '350px'); return false;" %></li>
|
||
|
<div id="bulk_update_date" style="display:none;">
|
||
|
<h3 class="title"><%= l(:label_date) %></h3>
|
||
|
<%= form_tag(bulk_update_issues_path(:ids => @issue_ids, :back_url => @back), :id => 'bulk_update_date') do %>
|
||
|
<% if @safe_attributes.include?('start_date') %>
|
||
|
<p>
|
||
|
<label for='issue_start_date'><%= l(:field_start_date) %></label>
|
||
|
<%= date_field_tag 'issue[start_date]', '', :value => (@issue ? @issue.start_date : nil), :size => 10 %><%= calendar_for('issue_start_date') %>
|
||
|
<label class="inline"><%= check_box_tag 'issue[start_date]', 'none', false, :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
<% if @safe_attributes.include?('due_date') %>
|
||
|
<p>
|
||
|
<label for='issue_due_date'><%= l(:field_due_date) %></label>
|
||
|
<%= date_field_tag 'issue[due_date]', '', :value => (@issue ? @issue.due_date : nil), :size => 10 %><%= calendar_for('issue_due_date') %>
|
||
|
<label class="inline"><%= check_box_tag 'issue[due_date]', 'none', false, :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
<p class="buttons">
|
||
|
<%= button_tag l(:button_submit), :name => nil, :onclick => "hideModal(this);$('form#bulk_update_date').submit();", :data => { :disable_with => false } %>
|
||
|
<%= link_to_function l(:button_cancel), "hideModal(this);" %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<% if @can[:add_watchers] %>
|
||
|
<li class="folder">
|
||
|
<a href="#" class="submenu"><%= l(:label_issue_watchers) %></a>
|
||
| ... | ... | |
|
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
|
||
|
</ul>
|
||
|
<%= 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 %>
|
||
| test/functional/context_menus_controller_test.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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'
|
||
|
# Dates
|
||
|
assert_select 'a[href=?]', '#', :text => '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
|
||
| ... | ... | |
|
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
|
||