Project

General

Profile

Feature #27672 » 0002-Add-switch-the-display-for-selected-column.patch

Mizuki ISHIKAWA, 2018-02-23 08:03

View differences:

app/models/issue_query.rb
73 73
    options[:draw_progress_line] = (arg == '1' ? '1' : nil)
74 74
  end
75 75

  
76
  def draw_selected_columns
77
    r = options[:draw_selected_columns]
78
    r == '1'
79
  end
80

  
81
  def draw_selected_columns=(arg)
82
    options[:draw_selected_columns] = (arg == '1' ? '1' : nil)
83
  end
84

  
76 85
  def build_from_params(params, defaults={})
77 86
    super
78 87
    self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations])
79 88
    self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line])
89
    self.draw_selected_columns = params[:draw_selected_columns] || (params[:query] && params[:query][:draw_selected_columns])
80 90
    self
81 91
  end
82 92

  
app/views/gantts/show.html.erb
34 34
              <legend>
35 35
                <%= l(:field_column_names) %>
36 36
              </legend>
37
              <label for="draw_selected_columns">
38
                <%= check_box 'query', 'draw_selected_columns', :id => 'draw_selected_columns' %>
39
                  <%= l(:label_display) %>
40
              </label>
37 41
              <%= render_query_columns_selection(@query) %>
38 42
            </fieldset>
39 43
          </td>
......
413 417
    disable_unavailable_columns('<%= Redmine::Helpers::Gantt::UNAVAILABLE_COLUMNS.map{|column| column.to_s }.join(',') %>'.split(','));
414 418
    drawGanttHandler();
415 419
    resizableSubjectColumn();
416
    $("#draw_relations").change(drawGanttHandler);
417
    $("#draw_progress_line").change(drawGanttHandler);
420
    drawSelectedColumns();
421
    $("#draw_relations, #draw_progress_line, #draw_selected_columns").change(drawGanttHandler);
418 422
  });
419 423
  $(window).resize(function() {
420 424
    drawGanttHandler();
app/views/queries/_form.html.erb
42 42
  <p><label><%= l(:button_show) %></label>
43 43
  <label class="inline"><%= check_box_tag "query[draw_relations]", "1", @query.draw_relations %> <%= l(:label_related_issues) %></label>
44 44
  <label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label>
45
  <label class="inline"><%= check_box_tag "query[draw_selected_columns]", "1", @query.draw_selected_columns %> <%= l(:label_gantt_selected_columns) %></label>
45 46
  </p>
46 47
</fieldset>
47 48
<% end %>
config/locales/en.yml
1025 1025
  label_font_monospace: Monospaced font
1026 1026
  label_font_proportional: Proportional font
1027 1027
  label_last_notes: Last notes
1028
  label_gantt_selected_columns: Selected columns
1028 1029

  
1029 1030
  button_login: Login
1030 1031
  button_submit: Submit
public/javascripts/gantt.js
162 162
}
163 163

  
164 164
function drawSelectedColumns(){
165
  if(isMobile()) {
166
    $('td.gantt_selected_column').each(function(i) {
167
      $(this).hide();
168
    });
169
  }else{
170
    $('#content').addClass("gantt_content");
171
    $('td.gantt_selected_column').each(function() {
172
      $(this).show();
173
      var column_name = $(this).attr('id');
174
      $(this).resizable({
175
        alsoResize: `.gantt_${column_name}_container, .gantt_${column_name}_container > .gantt_hdr`,
176
        minWidth: 20,
177
        handles: "e",
178
        create: function( event, ui ) {
179
          $(".ui-resizable-e").css("cursor","ew-resize");
180
        }
181
      }).on('resize', function (e) {
182
          e.stopPropagation();
165
  if ($("#draw_selected_columns").prop('checked')) {
166
    if(isMobile()) {
167
      $('td.gantt_selected_column').each(function(i) {
168
        $(this).hide();
183 169
      });
170
    }else{
171
      $('#content').addClass("gantt_content");
172
      $('td.gantt_selected_column').each(function() {
173
        $(this).show();
174
        var column_name = $(this).attr('id');
175
        $(this).resizable({
176
          alsoResize: `.gantt_${column_name}_container, .gantt_${column_name}_container > .gantt_hdr`,
177
          minWidth: 20,
178
          handles: "e",
179
          create: function( event, ui ) {
180
            $(".ui-resizable-e").css("cursor","ew-resize");
181
          }
182
        }).on('resize', function (e) {
183
            e.stopPropagation();
184
        });
185
      });
186
    }
187
  }else{
188
    $('td.gantt_selected_column').each(function (i) {
189
      $(this).hide();
184 190
    });
185 191
  }
186 192
}
test/functional/queries_controller_test.rb
283 283
          :query => {
284 284
            :name => "test_create_from_gantt",
285 285
            :draw_relations => '1',
286
            :draw_progress_line => '1'
286
            :draw_progress_line => '1',
287
            :draw_selected_columns => '1'
287 288
          }
288 289
        }
289 290
      assert_response 302
......
292 293
    assert_redirected_to "/issues/gantt?query_id=#{query.id}"
293 294
    assert_equal true, query.draw_relations
294 295
    assert_equal true, query.draw_progress_line
296
    assert_equal true, query.draw_selected_columns
295 297
  end
296 298

  
297 299
  def test_create_project_query_from_gantt
......
309 311
          :query => {
310 312
            :name => "test_create_from_gantt",
311 313
            :draw_relations => '0',
312
            :draw_progress_line => '0'
314
            :draw_progress_line => '0',
315
            :draw_selected_columns => '0'
313 316
          }
314 317
        }
315 318
      assert_response 302
......
318 321
    assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}"
319 322
    assert_equal false, query.draw_relations
320 323
    assert_equal false, query.draw_progress_line
324
    assert_equal false, query.draw_selected_columns
321 325
  end
322 326

  
323 327
  def test_create_project_public_query_should_force_private_without_manage_public_queries_permission
(2-2/14)