From d09b08046343d5fcd6a15024fdc8f48e73c9d064 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 13 Mar 2016 08:01:55 +0000 Subject: [PATCH] Merged r15202 (#22108). git-svn-id: http://svn.redmine.org/redmine/branches/3.2-stable@15226 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/queries_helper.rb | 30 +++++++++++++++++++++++ app/views/issues/index.html.erb | 6 +++-- test/functional/issues_controller_test.rb | 20 +++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 9ad2540e4..6714562ba 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -243,4 +243,34 @@ module QueriesHelper @query end end + + # Returns the query definition as hidden field tags + def query_as_hidden_field_tags(query) + tags = hidden_field_tag("set_filter", "1", :id => nil) + + if query.filters.present? + query.filters.each do |field, filter| + tags << hidden_field_tag("f[]", field, :id => nil) + tags << hidden_field_tag("op[#{field}]", filter[:operator], :id => nil) + filter[:values].each do |value| + tags << hidden_field_tag("v[#{field}][]", value, :id => nil) + end + end + end + if query.column_names.present? + query.column_names.each do |name| + tags << hidden_field_tag("c[]", name, :id => nil) + end + end + if query.totalable_names.present? + query.totalable_names.each do |name| + tags << hidden_field_tag("t[]", name, :id => nil) + end + end + if query.group_by.present? + tags << hidden_field_tag("group_by", query.group_by, :id => nil) + end + + tags + end end diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 8310dc73e..7cc2811f9 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -76,8 +76,10 @@ <% end %>