Project

General

Profile

Defect #32194 » 0001-Add-manage-custom-query-buttons-on-calendar.patch

Mizuki ISHIKAWA, 2019-10-09 07:48

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>
......
22 23
<p><label for="query_is_for_all"><%=l(:field_is_for_all)%></label>
23 24
<%= check_box_tag 'query_is_for_all', 1, @query.project.nil?, :class => (User.current.admin? ? '' : 'disable-unless-private') %></p>
24 25

  
26
<% unless params[:calendar] %>
25 27
<fieldset id="options"><legend><%= l(:label_options) %></legend>
26 28
<p><label for="query_default_columns"><%=l(:label_default_columns)%></label>
27 29
<%= check_box_tag 'default_columns', 1, @query.has_default_columns?, :id => 'query_default_columns',
......
45 47
  <label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label>
46 48
  <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>
47 49
  </p>
48
<% end %>
50
<% end # unless params[:gantt] %>
49 51
</fieldset>
52
<% end # unless params[:calendar] %>
50 53
</div>
51 54

  
52 55
<fieldset id="filters"><legend><%= l(:label_filter_plural) %></legend>
53 56
<%= render :partial => 'queries/filters', :locals => {:query => query}%>
54 57
</fieldset>
55 58

  
59
<% unless params[:calendar] %>
56 60
<% unless params[:gantt] %>
57 61
<fieldset><legend><%= l(:label_sort) %></legend>
58 62
<% 3.times do |i| %>
......
76 80
<legend><%= l(:field_column_names) %></legend>
77 81
<%= render_query_columns_selection(query) %>
78 82
<% end %>
83
<% end # unless params[:calendar] %>
79 84

  
80 85
</div>
81 86

  
test/functional/queries_controller_test.rb
100 100
    assert_response :success
101 101
  end
102 102

  
103
  def test_new_with_gantt_params
104
    @request.session[:user_id] = 2
105
    get :new, :params => { :gantt => 1 }
106
    assert_response :success
107

  
108
    assert_select 'input[type="hidden"]#gantt', 1
109
    assert_select 'fieldset#options'
110
    assert_select 'fieldset#filters'
111
    assert_select 'fieldset legend', { :text => 'Sort', :count => 0 }
112
    assert_select 'fieldset#columns'
113
  end
114

  
115
  def test_new_with_calendar_params
116
    @request.session[:user_id] = 2
117
    get :new, :params => { :calendar => 1 }
118
    assert_response :success
119

  
120
    assert_select 'input[type="hidden"]#calendar', 1
121
    assert_select 'fieldset#options', :count => 0
122
    assert_select 'fieldset#filters'
123
    assert_select 'fieldset legend', { :text => 'Sort', :count => 0 }
124
    assert_select 'fieldset#columns', :count => 0
125
  end
126

  
127
  def test_new_without_gantt_and_calendar_params
128
    @request.session[:user_id] = 2
129
    get :new
130
    assert_response :success
131

  
132
    assert_select 'fieldset#options'
133
    assert_select 'fieldset#filters'
134
    assert_select 'fieldset legend', { :text => 'Sort' }
135
    assert_select 'fieldset#columns'
136
  end
137

  
103 138
  def test_create_project_public_query
104 139
    @request.session[:user_id] = 2
105 140
    post :create, :params => {
(3-3/6)