Project

General

Profile

Patch #28861 » Add-dates-on-context-menu.patch

Mizuki ISHIKAWA, 2018-05-23 10:22

View differences:

app/views/context_menus/issues.html.erb
116 116
      </ul>
117 117
    </li>
118 118
  <% end %>
119
  <% if @safe_attributes.include?('start_date') || @safe_attributes.include?('due_date') %>
120
    <li><%= context_menu_link l(:label_date), '#', :onclick => "showModal('bulk_update_date', '350px'); return false;" %></li>
121
    <div id="bulk_update_date" style="display:none;">
122
      <h3 class="title"><%= l(:label_date) %></h3>
123
      <%= form_tag(bulk_update_issues_path(:ids => @issue_ids, :back_url => @back), :id => 'bulk_update_date') do %>
124
        <% if @safe_attributes.include?('start_date') %>
125
        <p>
126
          <label for='issue_start_date'><%= l(:field_start_date) %></label>
127
          <%= date_field_tag 'issue[start_date]', '', :value => (@issue ? @issue.start_date : nil), :size => 10 %><%= calendar_for('issue_start_date') %>
128
          <label class="inline"><%= check_box_tag 'issue[start_date]', 'none', false, :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
129
        </p>
130
        <% end %>
119 131

  
132
        <% if @safe_attributes.include?('due_date') %>
133
        <p>
134
          <label for='issue_due_date'><%= l(:field_due_date) %></label>
135
          <%= date_field_tag 'issue[due_date]', '', :value => (@issue ? @issue.due_date : nil), :size => 10 %><%= calendar_for('issue_due_date') %>
136
          <label class="inline"><%= check_box_tag 'issue[due_date]', 'none', false, :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
137
        </p>
138
        <% end %>
139
        <p class="buttons">
140
            <%= button_tag l(:button_submit), :name => nil, :onclick => "hideModal(this);$('form#bulk_update_date').submit();", :data => { :disable_with => false } %>
141
            <%= link_to_function l(:button_cancel), "hideModal(this);" %>
142
          </p>
143
      <% end %>
144
    </div>
145
  <% end %>
120 146
<% if @can[:add_watchers] %>
121 147
  <li class="folder">
122 148
    <a href="#" class="submenu"><%= l(:label_issue_watchers) %></a>
......
154 180

  
155 181
  <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
156 182
</ul>
183
<%= javascript_tag do %>
184
$('input[data-disables]').change(function() {
185
  if ($(this).prop('checked')){
186
    $($(this).data('disables')).attr('disabled', true).val('');
187
  } else {
188
    $($(this).data('disables')).attr('disabled', false);
189
  }
190
});
191
<% end %>
test/functional/context_menus_controller_test.rb
35 35

  
36 36
  def test_context_menu_one_issue
37 37
    @request.session[:user_id] = 2
38
    issue = Issue.find(1)
38 39
    get :issues, :params => {
39
        :ids => [1]
40
        :ids => [issue.id]
40 41
      }
41 42
    assert_response :success
42 43

  
......
54 55
    assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
55 56
    # Assignees
56 57
    assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper'
58
    # Dates
59
    assert_select 'a[href=?]', '#', :text => 'Date', :onclick => "showModal('bulk_update_date', '350px'); return false;"
60
    assert_select 'div#bulk_update_date' do
61
      assert_select "input[name='issue[start_date]'][value=?]", issue.start_date.to_s
62
      assert_select "input[name='issue[due_date]'][value=?]", issue.due_date.to_s
63
    end
57 64
  end
58 65

  
59 66
  def test_context_menu_one_issue_by_anonymous
......
247 254
    assert_select 'a', :text => 'eCookbook - Shared'
248 255
  end
249 256

  
257
  def test_context_menu_should_not_include_a_date_form_if_date_attributes_are_unsafe
258
    issue = Issue.find(1)
259
    # Change start_date and due_date to unsafe attributes
260
    issue.tracker.core_fields = []
261
    issue.tracker.save
262

  
263
    @request.session[:user_id] = 2
264
    get :issues, :params => {
265
        :ids => [issue.id]
266
      }
267
    assert_response :success
268
    assert_select 'a[href=?]', '#', {:text => 'Date', :onclick => "showModal('bulk_update_date', '350px'); return false;", :count => 0}
269
  end
270

  
250 271
  def test_context_menu_with_issue_that_is_not_visible_should_fail
251 272
    get :issues, :params => {
252 273
        :ids => [1, 4] # issue 4 is not visible
(3-3/7)