From 1ac8fd8c4214f6cf829230a1dc067faf7c7e463a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 23 Feb 2013 12:04:29 +0000 Subject: [PATCH] Adds helpers for query columns selection. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11451 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/settings_controller.rb | 2 ++ app/helpers/queries_helper.rb | 8 ++++++++ app/views/queries/_columns.html.erb | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 3f48d1f75..586c23956 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -19,6 +19,8 @@ class SettingsController < ApplicationController layout 'admin' menu_item :plugins, :only => :plugin + helper :queries + before_filter :require_admin def index diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 2001a59e6..77fe4c230 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -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) : diff --git a/app/views/queries/_columns.html.erb b/app/views/queries/_columns.html.erb index 329ffd67c..f359c1615 100644 --- a/app/views/queries/_columns.html.erb +++ b/app/views/queries/_columns.html.erb @@ -4,7 +4,7 @@ <%= label_tag "available_columns", l(:description_available_columns) %>
<%= 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);" %> @@ -18,7 +18,7 @@ <%= label_tag "selected_columns", l(:description_selected_columns) %>
<%= 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);") %> -- 2.39.5