0001-Add-manage-custom-query-buttons-on-calendar.patch

Mizuki ISHIKAWA, 2019-11-29 03:08

Download (6.04 KB)

View differences:

app/controllers/queries_controller.rb
147 147
      else
148 148
        redirect_to issues_gantt_path(options)
149 149
      end
150
    elsif params[:calendar]
151
      if @project
152
        redirect_to project_calendar_path(@project, options)
153
      else
154
        redirect_to issues_calendar_path(options)
155
      end
150 156
    else
151 157
      redirect_to _project_issues_path(@project, options)
152 158
    end
app/views/calendars/show.html.erb
3 3
<%= form_tag({:controller => 'calendars', :action => 'show', :project_id => @project},
4 4
             :method => :get, :id => 'query_form') do %>
5 5
<%= hidden_field_tag 'set_filter', '1' %>
6
<%= hidden_field_tag 'calendar', '1' %>
6 7

  
7 8
<div id="query_form_with_buttons" class="hide-when-print">
8 9
<div id="query_form_content">
......
26 27

  
27 28
  <%= link_to_function l(:button_apply), '$("#query_form").submit()', :class => 'icon icon-checked' %>
28 29
  <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
30
  <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
31
    <%= link_to_function l(:button_save),
32
                         "$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();",
33
                         :class => 'icon icon-save' %>
34
  <% end %>
35
  <% if !@query.new_record? && @query.editable_by?(User.current) %>
36
    <%= link_to l(:button_edit), edit_query_path(@query, :calendar => 1), :class => 'icon icon-edit' %>
37
    <%= delete_link query_path(@query, :calendar => 1) %>
38
  <% end %>
29 39
</p>
30 40
</div>
31 41
<% end %>
app/views/queries/_form.html.erb
3 3
<div class="box">
4 4
<div class="tabular">
5 5
<%= hidden_field_tag 'gantt', '1' if params[:gantt] %>
6
<%= hidden_field_tag 'calendar', '1' if params[:calendar] %>
6 7

  
7 8
<p><label for="query_name"><%=l(:field_name)%></label>
8 9
<%= text_field 'query', 'name', :size => 80 %></p>
......
27 28
  <%= check_box_tag 'query_is_for_all', 1, @query.project.nil?, :class => (User.current.admin? ? '' : 'disable-unless-private') %></p>
28 29
<% end %>
29 30

  
31
<% unless params[:calendar] %>
30 32
<fieldset id="options"><legend><%= l(:label_options) %></legend>
31 33
  <% if @query.available_display_types.size > 1 %>
32 34
  <p><label for='display_type'><%= l(:label_display_type) %></label>
......
60 62
  <label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label>
61 63
  <label class="inline"><%= check_box_tag "query[draw_selected_columns]", "1", @query.draw_selected_columns, :data => { :enables => 'span.query-columns select, span.query-columns input'} %> <%= l(:description_selected_columns) %></label>
62 64
  </p>
63
<% end %>
65
<% end # unless params[:gantt] %>
64 66
</fieldset>
67
<% end # unless params[:calendar] %>
65 68
</div>
66 69

  
67 70
<fieldset id="filters"><legend><%= l(:label_filter_plural) %></legend>
68 71
<%= render :partial => 'queries/filters', :locals => {:query => query}%>
69 72
</fieldset>
70 73

  
71
<% unless params[:gantt] %>
74
<% if params[:calendar].nil? && params[:gantt].nil? %>
72 75
<fieldset id="sort"><legend><%= l(:label_sort) %></legend>
73 76
<% 3.times do |i| %>
74 77
<%= content_tag(:span, "#{i+1}:", :class => 'query_sort_criteria_count')%>
......
87 90
</fieldset>
88 91
<% end %>
89 92

  
93
<% unless params[:calendar] %>
90 94
<%= content_tag 'fieldset', :id => 'columns' do %>
91 95
<legend><%= l(:field_column_names) %></legend>
92 96
<%= render_query_columns_selection(query) %>
93 97
<% end %>
98
<% end %>
94 99

  
95 100
</div>
96 101

  
test/functional/queries_controller_test.rb
153 153
    assert_response :success
154 154
  end
155 155

  
156
  def test_new_with_gantt_params
157
    @request.session[:user_id] = 2
158
    get :new, :params => { :gantt => 1 }
159
    assert_response :success
160

  
161
    assert_select 'input[type="hidden"]#gantt', 1
162
    assert_select 'fieldset#options'
163
    assert_select 'fieldset#filters'
164
    assert_select 'fieldset legend', { :text => 'Sort', :count => 0 }
165
    assert_select 'fieldset#columns'
166
  end
167

  
168
  def test_new_with_calendar_params
169
    @request.session[:user_id] = 2
170
    get :new, :params => { :calendar => 1 }
171
    assert_response :success
172

  
173
    assert_select 'input[type="hidden"]#calendar', 1
174
    assert_select 'fieldset#options', :count => 0
175
    assert_select 'fieldset#filters'
176
    assert_select 'fieldset legend', { :text => 'Sort', :count => 0 }
177
    assert_select 'fieldset#columns', :count => 0
178
  end
179

  
180
  def test_new_without_gantt_and_calendar_params
181
    @request.session[:user_id] = 2
182
    get :new
183
    assert_response :success
184

  
185
    assert_select 'fieldset#options'
186
    assert_select 'fieldset#filters'
187
    assert_select 'fieldset legend', { :text => 'Sort' }
188
    assert_select 'fieldset#columns'
189
  end
190

  
156 191
  def test_create_project_public_query
157 192
    @request.session[:user_id] = 2
158 193
    post :create, :params => {
159
-