Ability to save Gantt query filters (#7836).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12020 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3c9263221d
commit
010bfc56e1
|
@ -59,7 +59,7 @@ class QueriesController < ApplicationController
|
|||
|
||||
if @query.save
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to _project_issues_path(@project, :query_id => @query)
|
||||
redirect_to_issues(:query_id => @query)
|
||||
else
|
||||
render :action => 'new', :layout => !request.xhr?
|
||||
end
|
||||
|
@ -77,7 +77,7 @@ class QueriesController < ApplicationController
|
|||
|
||||
if @query.save
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to _project_issues_path(@project, :query_id => @query)
|
||||
redirect_to_issues(:query_id => @query)
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ class QueriesController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@query.destroy
|
||||
redirect_to _project_issues_path(@project, :set_filter => 1)
|
||||
redirect_to_issues(:set_filter => 1)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -103,4 +103,16 @@ private
|
|||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def redirect_to_issues(options)
|
||||
if params[:gantt]
|
||||
if @project
|
||||
redirect_to project_gantt_path(@project, options)
|
||||
else
|
||||
redirect_to issues_gantt_path(options)
|
||||
end
|
||||
else
|
||||
redirect_to _project_issues_path(@project, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -97,6 +97,31 @@ class IssueQuery < Query
|
|||
!is_private?
|
||||
end
|
||||
|
||||
def draw_relations
|
||||
r = options[:draw_relations]
|
||||
r.nil? || r == '1'
|
||||
end
|
||||
|
||||
def draw_relations=(arg)
|
||||
options[:draw_relations] = (arg == '0' ? '0' : nil)
|
||||
end
|
||||
|
||||
def draw_progress_line
|
||||
r = options[:draw_progress_line]
|
||||
r == '1'
|
||||
end
|
||||
|
||||
def draw_progress_line=(arg)
|
||||
options[:draw_progress_line] = (arg == '1' ? '1' : nil)
|
||||
end
|
||||
|
||||
def build_from_params(params)
|
||||
super
|
||||
self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations])
|
||||
self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line])
|
||||
self
|
||||
end
|
||||
|
||||
def initialize_available_filters
|
||||
principals = []
|
||||
subprojects = []
|
||||
|
|
|
@ -130,6 +130,7 @@ class Query < ActiveRecord::Base
|
|||
serialize :filters
|
||||
serialize :column_names
|
||||
serialize :sort_criteria, Array
|
||||
serialize :options, Hash
|
||||
|
||||
attr_protected :project_id, :user_id
|
||||
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<% @gantt.view = self %>
|
||||
<div class="contextual">
|
||||
<% if !@query.new_record? && @query.editable_by?(User.current) %>
|
||||
<%= link_to l(:button_edit), edit_query_path(@query, :gantt => 1), :class => 'icon icon-edit' %>
|
||||
<%= delete_link query_path(@query, :gantt => 1) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
|
||||
|
||||
<%= form_tag({:controller => 'gantts', :action => 'show',
|
||||
|
@ -6,6 +13,7 @@
|
|||
:year => params[:year], :months => params[:months]},
|
||||
:method => :get, :id => 'query_form') do %>
|
||||
<%= hidden_field_tag 'set_filter', '1' %>
|
||||
<%= hidden_field_tag 'gantt', '1' %>
|
||||
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
||||
<div style="<%= @query.new_record? ? "" : "display: none;" %>">
|
||||
|
@ -20,8 +28,8 @@
|
|||
<td>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_related_issues) %></legend>
|
||||
<label>
|
||||
<%= check_box_tag "draw_rels", params["draw_rels"], params[:set_filter].blank? || params[:draw_rels] %>
|
||||
<label for="draw_relations">
|
||||
<%= check_box 'query', 'draw_relations', :id => 'draw_relations' %>
|
||||
<% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
|
||||
<% rels.each do |rel| %>
|
||||
<% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
|
||||
|
@ -35,8 +43,8 @@
|
|||
<td>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_gantt_progress_line) %></legend>
|
||||
<label>
|
||||
<%= check_box_tag "draw_progress_line", params[:draw_progress_line], params[:draw_progress_line] %>
|
||||
<label for="draw_progress_line">
|
||||
<%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %>
|
||||
<%= l(:label_display) %>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
@ -62,6 +70,11 @@
|
|||
:class => 'icon icon-checked' %>
|
||||
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
|
||||
:class => 'icon icon-reload' %>
|
||||
<% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
|
||||
<%= link_to_function l(:button_save),
|
||||
"$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();",
|
||||
:class => 'icon icon-save' %>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
@ -313,7 +326,7 @@
|
|||
$(document).ready(drawGanttHandler);
|
||||
$(window).resize(drawGanttHandler);
|
||||
$(function() {
|
||||
$("#draw_rels").change(drawGanttHandler);
|
||||
$("#draw_relations").change(drawGanttHandler);
|
||||
$("#draw_progress_line").change(drawGanttHandler);
|
||||
});
|
||||
<% end %>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
<div class="box">
|
||||
<div class="tabular">
|
||||
<%= hidden_field_tag 'gantt', '1' if params[:gantt] %>
|
||||
|
||||
<p><label for="query_name"><%=l(:field_name)%></label>
|
||||
<%= text_field 'query', 'name', :size => 80 %></p>
|
||||
|
||||
|
@ -31,6 +33,13 @@
|
|||
|
||||
<p><label><%= l(:button_show) %></label>
|
||||
<%= available_block_columns_tags(@query) %></p>
|
||||
|
||||
<% if params[:gantt] %>
|
||||
<p><label><%= l(:label_gantt) %></label>
|
||||
<label class="inline"><%= check_box_tag "query[draw_relations]", "1", @query.draw_relations %> <%= l(:label_related_issues) %></label>
|
||||
<label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label>
|
||||
</p>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class AddQueriesOptions < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :queries, :options, :text
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :queries, :options
|
||||
end
|
||||
end
|
|
@ -167,6 +167,6 @@ function drawGanttHandler() {
|
|||
setDrawArea();
|
||||
if ($("#draw_progress_line").attr('checked'))
|
||||
drawGanttProgressLines();
|
||||
if ($("#draw_rels").attr('checked'))
|
||||
if ($("#draw_relations").attr('checked'))
|
||||
drawRelations();
|
||||
}
|
||||
|
|
|
@ -155,6 +155,43 @@ class QueriesControllerTest < ActionController::TestCase
|
|||
assert_select 'input[name=?]', 'query[name]'
|
||||
end
|
||||
|
||||
def test_create_global_query_from_gantt
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'IssueQuery.count' do
|
||||
post :create,
|
||||
:gantt => 1,
|
||||
:operators => {"status_id" => "o"},
|
||||
:values => {"status_id" => ["1"]},
|
||||
:query => {:name => "test_create_from_gantt",
|
||||
:draw_relations => '1',
|
||||
:draw_progress_line => '1'}
|
||||
assert_response 302
|
||||
end
|
||||
query = IssueQuery.order('id DESC').first
|
||||
assert_redirected_to "/issues/gantt?query_id=#{query.id}"
|
||||
assert_equal true, query.draw_relations
|
||||
assert_equal true, query.draw_progress_line
|
||||
end
|
||||
|
||||
def test_create_project_query_from_gantt
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'IssueQuery.count' do
|
||||
post :create,
|
||||
:project_id => 'ecookbook',
|
||||
:gantt => 1,
|
||||
:operators => {"status_id" => "o"},
|
||||
:values => {"status_id" => ["1"]},
|
||||
:query => {:name => "test_create_from_gantt",
|
||||
:draw_relations => '0',
|
||||
:draw_progress_line => '0'}
|
||||
assert_response 302
|
||||
end
|
||||
query = IssueQuery.order('id DESC').first
|
||||
assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}"
|
||||
assert_equal false, query.draw_relations
|
||||
assert_equal false, query.draw_progress_line
|
||||
end
|
||||
|
||||
def test_edit_global_public_query
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 4
|
||||
|
|
Loading…
Reference in New Issue