]> source.dussan.org Git - redmine.git/commitdiff
Adds helpers for query columns selection.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 23 Feb 2013 12:04:29 +0000 (12:04 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 23 Feb 2013 12:04:29 +0000 (12:04 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11451 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/settings_controller.rb
app/helpers/queries_helper.rb
app/views/queries/_columns.html.erb

index 3f48d1f7565795d5dc00513d3dfa3fb7a58daf51..586c239568b06e656365bcd380e02b8de265ee6e 100644 (file)
@@ -19,6 +19,8 @@ class SettingsController < ApplicationController
   layout 'admin'
   menu_item :plugins, :only => :plugin
 
+  helper :queries
+
   before_filter :require_admin
 
   def index
index 2001a59e67c1e0f79cdf03363881f848f531f297..77fe4c23046d85ff9ba375429ea2f7c93e923d95 100644 (file)
@@ -37,6 +37,14 @@ module QueriesHelper
     tags
   end
 
+  def query_available_inline_columns_options(query)
+    (query.available_inline_columns - query.columns).reject(&:frozen?).collect {|column| [column.caption, column.name]}
+  end
+
+  def query_selected_inline_columns_options(query)
+    (query.inline_columns & query.available_inline_columns).reject(&:frozen?).collect {|column| [column.caption, column.name]}
+  end
+
   def column_header(column)
     column.sortable ? sort_header_tag(column.name.to_s, :caption => column.caption,
                                                         :default_order => column.default_order) :
index 329ffd67c41be5cfcec539b6f3e49fb111ffb5d0..f359c1615b77b678153453686978767dbab91a86 100644 (file)
@@ -4,7 +4,7 @@
       <%= label_tag "available_columns", l(:description_available_columns) %>
       <br />
       <%= select_tag 'available_columns',
-              options_for_select((query.available_inline_columns - query.columns).reject(&:frozen?).collect {|column| [column.caption, column.name]}),
+              options_for_select(query_available_inline_columns_options(query)),
               :multiple => true, :size => 10, :style => "width:150px",
               :ondblclick => "moveOptions(this.form.available_columns, this.form.selected_columns);" %>
     </td>
@@ -18,7 +18,7 @@
       <%= label_tag "selected_columns", l(:description_selected_columns) %>
       <br />
       <%= select_tag((defined?(tag_name) ? tag_name : 'c[]'),
-              options_for_select((query.inline_columns & query.available_inline_columns).reject(&:frozen?).collect {|column| [column.caption, column.name]}),
+              options_for_select(query_selected_inline_columns_options(query)),
               :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px",
               :ondblclick => "moveOptions(this.form.selected_columns, this.form.available_columns);") %>
     </td>