From a5e4dd9cbd06b26241b2f394385e7149cf140ae2 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 10:57:13 +0100 Subject: [PATCH 01/24] Added multi choice widget. --- lib/widget/filters.rb | 8 ++++++-- lib/widget/filters/base.rb | 7 +++++++ lib/widget/filters/multi_choice.rb | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 lib/widget/filters/multi_choice.rb diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index 0d082eefd9..c924cdd107 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -64,8 +64,12 @@ class Widget::Filters < Widget::Base render_widget Filters::MultiValues, f, :to => html end else - render_widget Filters::MultiValues, f, :to => html + if f_cls.is_multiple_choice? + render_widget Filters::MultiChoice, f, :to => html + else + render_widget Filters::MultiValues, f, :to => html + end end render_widget Filters::RemoveButton, f, :to => html end -end +end \ No newline at end of file diff --git a/lib/widget/filters/base.rb b/lib/widget/filters/base.rb index a41ff33516..dfedc6cf74 100644 --- a/lib/widget/filters/base.rb +++ b/lib/widget/filters/base.rb @@ -11,4 +11,11 @@ class Widget::Filters::Base < Widget::Base end @engine = filter.engine end + + ## + # Indicates whether this Filter is a multiple choice filter, + # meaning that the user must select a value of a given set of choices. + def is_multiple_choice? + false + end end diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb new file mode 100644 index 0000000000..193b31590a --- /dev/null +++ b/lib/widget/filters/multi_choice.rb @@ -0,0 +1,22 @@ +class Widget::Filters::MultiChoice < Widget::Filters::Base + + def render + content_tag :td do + content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do + text_field_tag("values[#{filter_class.underscore_name}]", "", + :size => "6", + :class => "select-small", + :id => "#{filter_class.underscore_name}_arg_1_val", + :'data-filter-name' => filter_class.underscore_name) + end + end + end + + def available_operators + "=".to_operator + end + + def is_multiple_choice? + true + end +end From 84d2611f748390d4175f781bad26f1104eb705f1 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Tue, 22 Mar 2011 11:28:50 +0100 Subject: [PATCH 02/24] have multi_choice.rb in lib/filter; move some funtionality from lib/widgets into lib/report/filter --- lib/report/filter/base.rb | 7 +++++++ lib/report/filter/multi_choice.rb | 11 +++++++++++ lib/widget/filters/base.rb | 7 ------- lib/widget/filters/multi_choice.rb | 8 -------- 4 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 lib/report/filter/multi_choice.rb diff --git a/lib/report/filter/base.rb b/lib/report/filter/base.rb index 1a29f31ef2..f9b56f9340 100644 --- a/lib/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -23,6 +23,13 @@ class Report::Filter false end + ## + # Indicates whether this Filter is a multiple choice filter, + # meaning that the user must select a value of a given set of choices. + def is_multiple_choice? + false + end + ## # A Filter may have a depentent filter. See the following example: # Filter::Project.dependent --> Filter::Issue diff --git a/lib/report/filter/multi_choice.rb b/lib/report/filter/multi_choice.rb new file mode 100644 index 0000000000..cb4e69fb1c --- /dev/null +++ b/lib/report/filter/multi_choice.rb @@ -0,0 +1,11 @@ +class Report::Filter + class MultiChoice < Base + + dont_inherit :available_operators + use '=' + + def is_multiple_choice? + true + end + end +end \ No newline at end of file diff --git a/lib/widget/filters/base.rb b/lib/widget/filters/base.rb index dfedc6cf74..a41ff33516 100644 --- a/lib/widget/filters/base.rb +++ b/lib/widget/filters/base.rb @@ -11,11 +11,4 @@ class Widget::Filters::Base < Widget::Base end @engine = filter.engine end - - ## - # Indicates whether this Filter is a multiple choice filter, - # meaning that the user must select a value of a given set of choices. - def is_multiple_choice? - false - end end diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 193b31590a..1d26409576 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -11,12 +11,4 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base end end end - - def available_operators - "=".to_operator - end - - def is_multiple_choice? - true - end end From e5f3e9a311e0bc44aacead8692cf482026d90251 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Tue, 22 Mar 2011 11:34:17 +0100 Subject: [PATCH 03/24] move is_multichouce? to class side --- lib/report/filter/base.rb | 2 +- lib/report/filter/multi_choice.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/report/filter/base.rb b/lib/report/filter/base.rb index f9b56f9340..2a1d65b74d 100644 --- a/lib/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -26,7 +26,7 @@ class Report::Filter ## # Indicates whether this Filter is a multiple choice filter, # meaning that the user must select a value of a given set of choices. - def is_multiple_choice? + def self.is_multiple_choice? false end diff --git a/lib/report/filter/multi_choice.rb b/lib/report/filter/multi_choice.rb index cb4e69fb1c..fd3f1db2f9 100644 --- a/lib/report/filter/multi_choice.rb +++ b/lib/report/filter/multi_choice.rb @@ -4,7 +4,7 @@ class Report::Filter dont_inherit :available_operators use '=' - def is_multiple_choice? + def self.is_multiple_choice? true end end From ec5eb6a5a0f5f7e85aa11ce14bf8d6bcff4fd964 Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Tue, 22 Mar 2011 13:00:21 +0100 Subject: [PATCH 04/24] render multi_choice filter --- assets/javascripts/reporting/filters.js | 11 +++++++++-- lib/widget/filters/multi_choice.rb | 25 ++++++++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/reporting/filters.js b/assets/javascripts/reporting/filters.js index 12a71112c4..ee7b1915f2 100644 --- a/assets/javascripts/reporting/filters.js +++ b/assets/javascripts/reporting/filters.js @@ -3,7 +3,7 @@ Reporting.Filters = { load_available_values_for_filter: function (filter_name, callback_func) { - var select; + var select, radio_options; select = $('' + filter_name + '_arg_1_val'); if (select !== null && select.readAttribute('data-loading') === "ajax" && select.childElements().length === 0) { Ajax.Updater({ success: select }, window.global_prefix + '/cost_reports/available_values', { @@ -25,7 +25,14 @@ Reporting.Filters = { callback_func(); } // select first option by default - select.selectedIndex = 0; + // check if we might have a radio-box + radio_options = $$('.' + filter_name + '_radio_option'); + if (select == null && radio_options && radio_options.size() != 0) { + radio_options.first().checked = true; + } + else { + select.selectedIndex = 0; + } }, show_filter: function (field, options) { diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 1d26409576..4210683f2c 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -3,11 +3,26 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base def render content_tag :td do content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do - text_field_tag("values[#{filter_class.underscore_name}]", "", - :size => "6", - :class => "select-small", - :id => "#{filter_class.underscore_name}_arg_1_val", - :'data-filter-name' => filter_class.underscore_name) + content = '' + available_values = filter_class.available_values + available_values.each_with_index do |(label, value), i| + label = content_tag :label, + :for => "#{filter_class.underscore_name}_radio_option_#{i}", + :'data-filter-name' => filter_class.underscore_name do + radio_button = content_tag :input, + :type => 'radio', + :name => "#{filter_class.underscore_name}_arg_1_val", + :id => "#{filter_class.underscore_name}_radio_option_#{i}", + :class => "#{filter_class.underscore_name}_radio_option", + :value => value do + '' + end + radio_button + label + end + br = (i == available_values.size - 1) ? '' : content_tag(:br) {} + content += (label + br) + end + content.html_safe end end end From a1b886a64aa0e274096ccc397009d8cdc19bc98e Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 14:32:52 +0100 Subject: [PATCH 05/24] Restructured the MultiChoice Widget's render method a little. --- lib/widget/filters/multi_choice.rb | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 4210683f2c..ba6e178464 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -3,26 +3,17 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base def render content_tag :td do content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do - content = '' - available_values = filter_class.available_values - available_values.each_with_index do |(label, value), i| - label = content_tag :label, - :for => "#{filter_class.underscore_name}_radio_option_#{i}", - :'data-filter-name' => filter_class.underscore_name do - radio_button = content_tag :input, - :type => 'radio', - :name => "#{filter_class.underscore_name}_arg_1_val", - :id => "#{filter_class.underscore_name}_radio_option_#{i}", - :class => "#{filter_class.underscore_name}_radio_option", - :value => value do - '' - end - radio_button + label - end - br = (i == available_values.size - 1) ? '' : content_tag(:br) {} - content += (label + br) + choices = filter_class.available_values.each_with_index.map do |(label, value), i| + radio_button = tag :input, + :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val", + :id => "#{filter_class.underscore_name}_radio_option_#{i}", + :class => "#{filter_class.underscore_name}_radio_option", + :value => value + content_tag :label, radio_button + label, + :for => "#{filter_class.underscore_name}_radio_option_#{i}", + :'data-filter-name' => filter_class.underscore_name end - content.html_safe + choices.join(content_tag(:br)).html_safe end end end From 1b48d66392ed694f31bcf72585b4e09aa93e3b89 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 14:40:50 +0100 Subject: [PATCH 06/24] adjusted indentation --- lib/widget/filters/multi_choice.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index ba6e178464..24cf8fba39 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -5,13 +5,13 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do choices = filter_class.available_values.each_with_index.map do |(label, value), i| radio_button = tag :input, - :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val", - :id => "#{filter_class.underscore_name}_radio_option_#{i}", - :class => "#{filter_class.underscore_name}_radio_option", - :value => value + :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val", + :id => "#{filter_class.underscore_name}_radio_option_#{i}", + :class => "#{filter_class.underscore_name}_radio_option", + :value => value content_tag :label, radio_button + label, - :for => "#{filter_class.underscore_name}_radio_option_#{i}", - :'data-filter-name' => filter_class.underscore_name + :for => "#{filter_class.underscore_name}_radio_option_#{i}", + :'data-filter-name' => filter_class.underscore_name end choices.join(content_tag(:br)).html_safe end From 6a314c3f4e270b3a60e654bca8a5e867bd6e9dcf Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 14:50:05 +0100 Subject: [PATCH 07/24] fixed br (content_tag -> tag) --- lib/widget/filters/multi_choice.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 24cf8fba39..30381186ad 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -13,7 +13,7 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base :for => "#{filter_class.underscore_name}_radio_option_#{i}", :'data-filter-name' => filter_class.underscore_name end - choices.join(content_tag(:br)).html_safe + choices.join(tag(:br)).html_safe end end end From 1e1ea52260c6eaffc676446e9f3ca848c3bc8e89 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 15:19:30 +0100 Subject: [PATCH 08/24] multi choice filter styling --- assets/javascripts/reporting/filters.js | 6 +++--- assets/stylesheets/reporting.css | 17 +++++++++++------ lib/widget/filters/multi_choice.rb | 6 +++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/assets/javascripts/reporting/filters.js b/assets/javascripts/reporting/filters.js index ee7b1915f2..611dbffa70 100644 --- a/assets/javascripts/reporting/filters.js +++ b/assets/javascripts/reporting/filters.js @@ -26,9 +26,9 @@ Reporting.Filters = { } // select first option by default // check if we might have a radio-box - radio_options = $$('.' + filter_name + '_radio_option'); - if (select == null && radio_options && radio_options.size() != 0) { - radio_options.first().checked = true; + radio_options = $$('.' + filter_name + '_radio_option input'); + if (select === null && radio_options && radio_options.size() !== 0) { + radio_options.first().checked = true; } else { select.selectedIndex = 0; diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 65387d51f6..600c8aecf6 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -7,9 +7,9 @@ font-weight: bold; } -#content p, -#content label, -#content a, +#content p, +#content label, +#content a, #content div { font-size: 11px; line-height: 16px; @@ -64,9 +64,9 @@ background-color: #e8e8e8 !important; } -.report tr:hover .inner, -.report tr:hover .bottom, -.report tr:hover .empty, +.report tr:hover .inner, +.report tr:hover .bottom, +.report tr:hover .empty, .report tr:hover .right { background-color: #f5f5c5 !important; } @@ -223,6 +223,11 @@ white-space: nowrap; } +.filter_radio_option { + padding-left: 5px; + padding-right: 5px; +} + #add_filter_block { margin-top: 6px; } diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 30381186ad..e6beae078c 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -7,13 +7,13 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base radio_button = tag :input, :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val", :id => "#{filter_class.underscore_name}_radio_option_#{i}", - :class => "#{filter_class.underscore_name}_radio_option", :value => value content_tag :label, radio_button + label, :for => "#{filter_class.underscore_name}_radio_option_#{i}", - :'data-filter-name' => filter_class.underscore_name + :'data-filter-name' => filter_class.underscore_name, + :class => "#{filter_class.underscore_name}_radio_option filter_radio_option" end - choices.join(tag(:br)).html_safe + choices.join.html_safe end end end From ab73d7d270d87c14139073a3e6681bc7654002b5 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 16:07:41 +0100 Subject: [PATCH 09/24] renamed Chainable#initialize_query_with to initial_report_with --- lib/report/chainable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index ceee3ca44c..d1777c9d60 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -74,7 +74,7 @@ class Report < ActiveRecord::Base # The query will be given to the block as a parameter. # Example: # initialize_query_with { |query| query.filter Report::Filter::City, :operators => '=', :values => 'Berlin, da great City' } - def self.initialize_query_with(&block) + def self.initialize_report_with(&block) engine.chain_initializer.push block end From 939c42451226d84e16877a4875bad2d2fab50fe0 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 16:08:21 +0100 Subject: [PATCH 10/24] Tried to fix selection. --- lib/widget/filters/multi_choice.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index e6beae078c..b3580bcbc1 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -4,10 +4,12 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base content_tag :td do content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do choices = filter_class.available_values.each_with_index.map do |(label, value), i| - radio_button = tag :input, - :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val", - :id => "#{filter_class.underscore_name}_radio_option_#{i}", - :value => value + opts = { :type => "radio", + :name => "#{filter_class.underscore_name}_arg_1_val", + :id => "#{filter_class.underscore_name}_radio_option_#{i}", + :value => value } + opts[:checked] = "checked" if filter.values.first.first == label + radio_button = tag :input, opts content_tag :label, radio_button + label, :for => "#{filter_class.underscore_name}_radio_option_#{i}", :'data-filter-name' => filter_class.underscore_name, From 0e52a7f51e92fd440b5087c011ba947e4fa243ed Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 16:48:53 +0100 Subject: [PATCH 11/24] fixed alumni radio selection --- lib/widget/filters/multi_choice.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index b3580bcbc1..9fb6f13ee3 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -8,7 +8,7 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base :name => "#{filter_class.underscore_name}_arg_1_val", :id => "#{filter_class.underscore_name}_radio_option_#{i}", :value => value } - opts[:checked] = "checked" if filter.values.first.first == label + opts[:checked] = "checked" if filter.values.first == value radio_button = tag :input, opts content_tag :label, radio_button + label, :for => "#{filter_class.underscore_name}_radio_option_#{i}", From 6a86793fbf5bd9e67aef1b91ec6b2ebaa2e818a4 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 17:19:29 +0100 Subject: [PATCH 12/24] handle arrays for radio button values --- lib/widget/filters/multi_choice.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 9fb6f13ee3..4f25393b5a 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -7,7 +7,7 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base opts = { :type => "radio", :name => "#{filter_class.underscore_name}_arg_1_val", :id => "#{filter_class.underscore_name}_radio_option_#{i}", - :value => value } + :value => value.to_json } opts[:checked] = "checked" if filter.values.first == value radio_button = tag :input, opts content_tag :label, radio_button + label, From d1d1330673558aa12c2f66acb8878379bc5793bd Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Tue, 22 Mar 2011 17:36:17 +0100 Subject: [PATCH 13/24] reverted rename of Chainable#intialize_query_with --- lib/report/chainable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index d1777c9d60..ceee3ca44c 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -74,7 +74,7 @@ class Report < ActiveRecord::Base # The query will be given to the block as a parameter. # Example: # initialize_query_with { |query| query.filter Report::Filter::City, :operators => '=', :values => 'Berlin, da great City' } - def self.initialize_report_with(&block) + def self.initialize_query_with(&block) engine.chain_initializer.push block end From b6bacddf377208546c604e59ee6c133de4fde03e Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Thu, 24 Mar 2011 12:34:40 +0100 Subject: [PATCH 14/24] Fixed radio name for the Alumni Filer. Enclosed radio button in div which represents 'arg_1_val'. --- lib/widget/filters/multi_choice.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 4f25393b5a..ddeb9ba18c 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -1,21 +1,25 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base def render + filterName = filter_class.underscore_name content_tag :td do - content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do + content_tag :div, :id => "#{filterName}_arg_1", :class => "filter_values" do choices = filter_class.available_values.each_with_index.map do |(label, value), i| - opts = { :type => "radio", - :name => "#{filter_class.underscore_name}_arg_1_val", - :id => "#{filter_class.underscore_name}_radio_option_#{i}", - :value => value.to_json } - opts[:checked] = "checked" if filter.values.first == value + opts = { + :type => "radio", + :name => "values[#{filterName}][]", + :id => "#{filterName}_radio_option_#{i}", + :value => value + } + opts[:checked] = "checked" if filter.values == value radio_button = tag :input, opts content_tag :label, radio_button + label, - :for => "#{filter_class.underscore_name}_radio_option_#{i}", + :for => "#{filterName}_radio_option_#{i}", :'data-filter-name' => filter_class.underscore_name, - :class => "#{filter_class.underscore_name}_radio_option filter_radio_option" + :class => "#{filterName}_radio_option filter_radio_option" end - choices.join.html_safe + content_tag :div, choices.join.html_safe, + :id => "#{filter_class.underscore_name}_arg_1_val" end end end From ee700b5b214f5f8379924bd0f2ed8ee24c47d46e Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Thu, 24 Mar 2011 15:43:01 +0100 Subject: [PATCH 15/24] Fixed pre-selection of radio options in load_available_values_for_filter. --- assets/javascripts/reporting/filters.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/assets/javascripts/reporting/filters.js b/assets/javascripts/reporting/filters.js index aa25008afd..be17cb8cfb 100644 --- a/assets/javascripts/reporting/filters.js +++ b/assets/javascripts/reporting/filters.js @@ -26,12 +26,13 @@ Reporting.Filters = { callback_func(); } // select first option by default - // check if we might have a radio-box - radio_options = $$('.' + filter_name + '_radio_option input'); - if (select === null && radio_options && radio_options.size() !== 0) { - radio_options.first().checked = true; - } - else { + if (select.localName === "div") { + // check if we might have a radio-box + radio_options = $$('.' + filter_name + '_radio_option input'); + if (radio_options && radio_options.size() !== 0) { + radio_options.first().checked = true; + } + } else if (select.localName === "select") { select.selectedIndex = 0; } }, From fae6e8450e7c87344c1277147f229944628c0b3e Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Thu, 24 Mar 2011 15:46:03 +0100 Subject: [PATCH 16/24] Yielded to Redcar's complaints (fixed indentation and added missing semicolons). --- assets/javascripts/reporting/filters.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/reporting/filters.js b/assets/javascripts/reporting/filters.js index be17cb8cfb..bed53bc041 100644 --- a/assets/javascripts/reporting/filters.js +++ b/assets/javascripts/reporting/filters.js @@ -66,7 +66,7 @@ Reporting.Filters = { (options.slowly ? Effect.Appear : Element.show)(field_el); Reporting.Filters.load_available_values_for_filter(field, options.callback_func); $('rm_' + field).value = field; // set the value, so the serialized form will return this filter - Reporting.Filters.value_changed(field) + Reporting.Filters.value_changed(field); Reporting.Filters.set_filter_value_widths(100); } else { (options.slowly ? Effect.Fade : Element.hide)(field_el); @@ -152,15 +152,13 @@ Reporting.Filters = { val = $(field + '_arg_1_val'); tr = $('tr_' + field); if (!val) { - return + return; + } + if (val.value === '<>') { + tr.addClassName('inactive-filter'); + } else { + tr.removeClassName('inactive-filter'); } - if (val.value == '<>') { - tr.addClassName('inactive-filter') - } - else - { - tr.removeClassName('inactive-filter') - } }, change_argument_visibility: function (field, arg_nr) { From 279477c776ed70606d54e8acc36e6e03f00edfc2 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Thu, 24 Mar 2011 17:02:47 +0100 Subject: [PATCH 17/24] made multi_choice filter understand symbols for labels as i18n keys --- lib/widget/filters/multi_choice.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index ddeb9ba18c..365a982692 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -13,7 +13,7 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base } opts[:checked] = "checked" if filter.values == value radio_button = tag :input, opts - content_tag :label, radio_button + label, + content_tag :label, radio_button + translate(label), :for => "#{filterName}_radio_option_#{i}", :'data-filter-name' => filter_class.underscore_name, :class => "#{filterName}_radio_option filter_radio_option" @@ -23,4 +23,15 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base end end end + + private + + def translate(label) + if label.is_a?(Symbol) + ::I18n.t(label) + else + label + end + end + end From 96d5d48f52a7294d08b46f9aab784b2298e8d3e6 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Mon, 28 Mar 2011 15:17:46 +0200 Subject: [PATCH 18/24] Added ?= operator which means 'null or equal'. --- lib/report/operator.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 7bce779ee6..2a728b6ee0 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -88,6 +88,16 @@ class Report::Operator end end + new "?=", :label => :label_null_or_equal do + def modify(query, field, *values) + where_clause = "(#{field} IS NULL" + where_clause += " OR #{field} IN #{collection(*values)}" unless values.compact.empty? + where_clause += ")" + query.where where_clause + query + end + end + new "~", :arity => 1, :label => :label_contains do def modify(query, field, *values) value = values.first || '' From 9eba26b50fa0d2b893bd5b3871ca2f77d62c5a6f Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Mon, 28 Mar 2011 18:35:31 +0200 Subject: [PATCH 19/24] slightly change arrow-angel of group_bys --- assets/stylesheets/reporting.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 01d1fec71e..be2dd8f75d 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -249,7 +249,7 @@ fieldset#filter-settings table td > label { height: 0; width: 0; border-style: solid; - border-width: 9px; + border-width: 9px 11px 9px 7px; } .arrow_left { From 901fc6a016fb5475d9e8cf17dd604ba427c0f3cf Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 29 Mar 2011 17:47:26 +0200 Subject: [PATCH 20/24] ask the engine for our connection rather than ActiveRecord::Base --- lib/report/chainable.rb | 2 +- lib/report/query_utils.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/report/chainable.rb b/lib/report/chainable.rb index e5138225fe..fa2ddbf7d8 100644 --- a/lib/report/chainable.rb +++ b/lib/report/chainable.rb @@ -206,7 +206,7 @@ class Report < ActiveRecord::Base end def compute_result - engine::Result.new ActiveRecord::Base.connection.select_all(sql_statement.to_s), {}, type + engine::Result.new engine.connection.select_all(sql_statement.to_s), {}, type end def table_joins diff --git a/lib/report/query_utils.rb b/lib/report/query_utils.rb index 6423feb351..28fee8b8dc 100644 --- a/lib/report/query_utils.rb +++ b/lib/report/query_utils.rb @@ -1,7 +1,7 @@ module Report::QueryUtils alias singleton_class metaclass unless respond_to? :singleton_class - delegate :quoted_false, :quoted_true, :to => "ActiveRecord::Base.connection" + delegate :quoted_false, :quoted_true, :to => "engine.connection" attr_writer :engine module PropagationHook @@ -43,7 +43,7 @@ module Report::QueryUtils # @return [Object] Quoted version def quote_string(str) return str unless str.respond_to? :to_str - ActiveRecord::Base.connection.quote_string(str) + engine.connection.quote_string(str) end ## @@ -71,7 +71,7 @@ module Report::QueryUtils end def quoted_date(date) - ActiveRecord::Base.connection.quoted_date date.to_dateish + engine.connection.quoted_date date.to_dateish end ## @@ -172,7 +172,7 @@ module Report::QueryUtils end def adapter_name - ActiveRecord::Base.connection.adapter_name.downcase.to_sym + engine.connection.adapter_name.downcase.to_sym end def cache From 372b3ac2b2920f4e20a139d905b82a4c22ebee0d Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 30 Mar 2011 10:53:01 +0200 Subject: [PATCH 21/24] moved new operator to own ones --- lib/report/operator.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 2a728b6ee0..2a915df6b2 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -88,16 +88,6 @@ class Report::Operator end end - new "?=", :label => :label_null_or_equal do - def modify(query, field, *values) - where_clause = "(#{field} IS NULL" - where_clause += " OR #{field} IN #{collection(*values)}" unless values.compact.empty? - where_clause += ")" - query.where where_clause - query - end - end - new "~", :arity => 1, :label => :label_contains do def modify(query, field, *values) value = values.first || '' @@ -184,6 +174,16 @@ class Report::Operator end end + new "?=", :label => :label_null_or_equal do + def modify(query, field, *values) + where_clause = "(#{field} IS NULL" + where_clause += " OR #{field} IN #{collection(*values)}" unless values.compact.empty? + where_clause += ")" + query.where where_clause + query + end + end + end ############################################################################################# From f97b49474c059c13990766e8f20bcaae931db9b5 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 30 Mar 2011 13:42:54 +0200 Subject: [PATCH 22/24] Added alias method (named aka) to Operator. --- lib/report/operator.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/report/operator.rb b/lib/report/operator.rb index 2a915df6b2..23fcdb171c 100644 --- a/lib/report/operator.rb +++ b/lib/report/operator.rb @@ -214,6 +214,10 @@ class Report::Operator all[name.to_s] or raise ArgumentError, "Operator #{name.inspect} not defined" end + def self.exists?(name) + all.has_key?(name.to_s) + end + def self.defaults(&block) class_eval &block end @@ -279,6 +283,17 @@ class Report::Operator self.name <=> other.name end + ## Creates an alias for a given operator. + def aka(alt_name, alt_label) + all = self.class.all + alt = alt_name.to_s + raise ArgumentError, "Can't alias operator with an existing one's name ( #{alt} )." if all.has_key?(alt) + op = all[name].clone + op.send(:rename_to, alt_name) + op.singleton_class.send(:define_method, 'label') { alt_label } + all[alt] = op + end + module DateRange def modify(query, field, from, to) query.where ["#{field} > '%s'", quoted_date((Date.yesterday + from).to_time.end_of_day)] if from @@ -287,6 +302,12 @@ class Report::Operator end end + private + + def rename_to(new_name) + @name = new_name + end + # Done with class method definition, let's initialize the operators load From dc2f0601715a65f998349cbdec4a2888338f5921 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Wed, 30 Mar 2011 15:09:35 +0200 Subject: [PATCH 23/24] Made check for element name IE and Opera compatible. --- assets/javascripts/reporting/filters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/reporting/filters.js b/assets/javascripts/reporting/filters.js index 5978cebca9..d43e4090ae 100644 --- a/assets/javascripts/reporting/filters.js +++ b/assets/javascripts/reporting/filters.js @@ -26,13 +26,13 @@ Reporting.Filters = { callback_func(); } // select first option by default - if (select.localName === "div") { + if (select.tagName.toLowerCase() === "div") { // check if we might have a radio-box radio_options = $$('.' + filter_name + '_radio_option input'); if (radio_options && radio_options.size() !== 0) { radio_options.first().checked = true; } - } else if (select.localName === "select") { + } else if (select.tagName.toLowerCase() === "select") { select.selectedIndex = 0; } }, From 4d71734994ca611f66f7a2aeeae12203c92e9bef Mon Sep 17 00:00:00 2001 From: Philipp Tessenow Date: Fri, 1 Apr 2011 16:57:30 +0200 Subject: [PATCH 24/24] fix ie7/chrome org-structure reloading bug --- assets/javascripts/reporting/restore_query.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/reporting/restore_query.js b/assets/javascripts/reporting/restore_query.js index 0bb06633d8..b48da12300 100644 --- a/assets/javascripts/reporting/restore_query.js +++ b/assets/javascripts/reporting/restore_query.js @@ -33,8 +33,8 @@ Reporting.RestoreQuery = { // (and possibly are dependents themselfes) initialize_load_dependent_filters: function(elements) { var filters_to_load, dependent_filters; - dependent_filters = elements.findAll(function (select) { return select.value == '<>' }); - filters_to_load = elements.reject( function (select) { return select.value == '<>' }); + dependent_filters = elements.findAll(function (select) { return select.getValue() == '<>' || select.select('option[selected]').size()==0 }); + filters_to_load = elements.reject( function (select) { return select.getValue() == '<>' }); // Filters which are <> are probably dependents themselfes, so remove and forget them for now. // This is OK as they get reloaded later dependent_filters.each(function(select) {