From 753843fd33112ed6d09a1b0b6c275753ba932d73 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 6 Apr 2011 11:57:28 +0200 Subject: [PATCH] transition all widgets to canvas api --- lib/widget/controls/apply.rb | 3 ++- lib/widget/controls/clear.rb | 4 +++- lib/widget/controls/delete.rb | 2 +- lib/widget/controls/query_name.rb | 2 +- lib/widget/controls/save.rb | 2 +- lib/widget/controls/save_as.rb | 2 +- lib/widget/filters.rb | 4 ++-- lib/widget/filters/date.rb | 4 ++-- lib/widget/filters/label.rb | 5 +++-- lib/widget/filters/multi_choice.rb | 11 ++++++----- lib/widget/filters/multi_values.rb | 5 +++-- lib/widget/filters/operators.rb | 5 +++-- lib/widget/filters/remove_button.rb | 4 ++-- lib/widget/filters/text_box.rb | 4 ++-- lib/widget/group_bys.rb | 4 ++-- lib/widget/settings.rb | 2 +- lib/widget/settings/fieldset.rb | 4 ++-- 17 files changed, 37 insertions(+), 30 deletions(-) diff --git a/lib/widget/controls/apply.rb b/lib/widget/controls/apply.rb index 4851a452c8..d8bcecbde0 100644 --- a/lib/widget/controls/apply.rb +++ b/lib/widget/controls/apply.rb @@ -1,6 +1,7 @@ + class Widget::Controls::Apply < Widget::Base def render - link_to content_tag(:span, content_tag(:em, l(:button_apply))), {}, + write link_to content_tag(:span, content_tag(:em, l(:button_apply))), {}, :href => "#", :id => "query-icon-apply-button", :class => "button apply reporting_button", :"data-target" => url_for(:action => 'index', :set_filter => '1') diff --git a/lib/widget/controls/clear.rb b/lib/widget/controls/clear.rb index f460105a8d..35c0a7bef5 100644 --- a/lib/widget/controls/clear.rb +++ b/lib/widget/controls/clear.rb @@ -1,5 +1,7 @@ + class Widget::Controls::Clear < Widget::Base def render - link_to content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")), '#', :id => 'query-link-clear', :class => 'button secondary' + write link_to(content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")), + '#', :id => 'query-link-clear', :class => 'button secondary') end end diff --git a/lib/widget/controls/delete.rb b/lib/widget/controls/delete.rb index b60d6ad07a..cb8859c171 100644 --- a/lib/widget/controls/delete.rb +++ b/lib/widget/controls/delete.rb @@ -19,6 +19,6 @@ class Widget::Controls::Delete < Widget::Base end question + options end - button + popup + write(button + popup) end end diff --git a/lib/widget/controls/query_name.rb b/lib/widget/controls/query_name.rb index 5cfe51f15e..7fb9ca2b52 100644 --- a/lib/widget/controls/query_name.rb +++ b/lib/widget/controls/query_name.rb @@ -14,7 +14,7 @@ class Widget::Controls::QueryName < Widget::Base options["data-update-url"] = url_for(:action => "rename", :id => @query.id) options["data-is_new"] = @query.new_record? end - content_tag(:span, name, options) + icon + write(content_tag(:span, name, options) + icon) end def translations diff --git a/lib/widget/controls/save.rb b/lib/widget/controls/save.rb index 900d3491dc..68891ba656 100644 --- a/lib/widget/controls/save.rb +++ b/lib/widget/controls/save.rb @@ -1,7 +1,7 @@ class Widget::Controls::Save < Widget::Base def render return "" if @query.new_record? - link_to content_tag(:span, content_tag(:em, l(:button_save)), :class => "button-icon icon-save"), {}, + write link_to content_tag(:span, content_tag(:em, l(:button_save)), :class => "button-icon icon-save"), {}, :href => "#", :id => "query-breadcrumb-save", :class => "button secondary", :title => l(:button_save), diff --git a/lib/widget/controls/save_as.rb b/lib/widget/controls/save_as.rb index 5ae48ed33e..93f05d7fc6 100644 --- a/lib/widget/controls/save_as.rb +++ b/lib/widget/controls/save_as.rb @@ -10,7 +10,7 @@ class Widget::Controls::SaveAs < Widget::Base button = link_to content_tag(:span, content_tag(:em, link_name, :class => "button-icon icon-save-as")), "#", :class => "button secondary", :id => 'query-icon-save-as', :title => link_name - button + render_popup + write(button + render_popup) end def render_popup_form diff --git a/lib/widget/filters.rb b/lib/widget/filters.rb index c924cdd107..1730d6a469 100644 --- a/lib/widget/filters.rb +++ b/lib/widget/filters.rb @@ -17,7 +17,7 @@ class Widget::Filters < Widget::Base :class => "select-small", :name => nil end - content_tag(:div, table + select) + write content_tag(:div, table + select) end def selectables @@ -72,4 +72,4 @@ class Widget::Filters < Widget::Base end render_widget Filters::RemoveButton, f, :to => html end -end \ No newline at end of file +end diff --git a/lib/widget/filters/date.rb b/lib/widget/filters/date.rb index dafcf4c3a6..8ea167e5f0 100644 --- a/lib/widget/filters/date.rb +++ b/lib/widget/filters/date.rb @@ -23,7 +23,7 @@ class Widget::Filters::Date < Widget::Filters::Base name = "values[#{filter_class.underscore_name}][]" id_prefix = "#{filter_class.underscore_name}_" - content_tag :td do + write(content_tag :td do arg1 = content_tag :span, :id => "#{id_prefix}arg_1", :class => "filter_values" do text1 = text_field_tag name, @filter.values.first.to_s, :size => 10, :class => "select-small", :id => "#{id_prefix}arg_1_val" cal1 = calendar_for("#{id_prefix}arg_1_val") @@ -35,6 +35,6 @@ class Widget::Filters::Date < Widget::Filters::Base text2 + cal2 end arg1 + arg2 - end + end) end end diff --git a/lib/widget/filters/label.rb b/lib/widget/filters/label.rb index bc520d6e93..a43cf28794 100644 --- a/lib/widget/filters/label.rb +++ b/lib/widget/filters/label.rb @@ -1,6 +1,7 @@ + class Widget::Filters::Label < Widget::Filters::Base def render - content_tag :td, :width => 150 do + write(content_tag :td, :width => 150 do options = { :id => filter_class.underscore_name } if (engine::Filter.all.any? {|f| f.dependent == filter_class}) options.merge! :class => 'dependent-filter-label' @@ -8,6 +9,6 @@ class Widget::Filters::Label < Widget::Filters::Base content_tag :label, options do l(filter_class.label) end - end + end) end end diff --git a/lib/widget/filters/multi_choice.rb b/lib/widget/filters/multi_choice.rb index 365a982692..a7864120b2 100644 --- a/lib/widget/filters/multi_choice.rb +++ b/lib/widget/filters/multi_choice.rb @@ -1,8 +1,9 @@ + class Widget::Filters::MultiChoice < Widget::Filters::Base def render filterName = filter_class.underscore_name - content_tag :td do + write(content_tag :td 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 = { @@ -21,11 +22,11 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base content_tag :div, choices.join.html_safe, :id => "#{filter_class.underscore_name}_arg_1_val" end - end + end) end - + private - + def translate(label) if label.is_a?(Symbol) ::I18n.t(label) @@ -33,5 +34,5 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base label end end - + end diff --git a/lib/widget/filters/multi_values.rb b/lib/widget/filters/multi_values.rb index 5872d540c5..f1015fef91 100644 --- a/lib/widget/filters/multi_values.rb +++ b/lib/widget/filters/multi_values.rb @@ -1,7 +1,8 @@ + class Widget::Filters::MultiValues < Widget::Filters::Base def render - content_tag :td do + write(content_tag :td do content_tag :div, :id => "#{filter_class.underscore_name}_arg_1", :class => "filter_values" do select_options = { :style => "vertical-align: top;", # FIXME: Do CSS :name => "values[#{filter_class.underscore_name}][]", @@ -52,6 +53,6 @@ class Widget::Filters::MultiValues < Widget::Filters::Base :"data-filter-name" => filter_class.underscore_name box + plus end - end + end) end end diff --git a/lib/widget/filters/operators.rb b/lib/widget/filters/operators.rb index 3b5f7e908e..fcacd92a42 100644 --- a/lib/widget/filters/operators.rb +++ b/lib/widget/filters/operators.rb @@ -1,6 +1,7 @@ + class Widget::Filters::Operators < Widget::Filters::Base def render - content_tag :td, :width => 100 do + write(content_tag :td, :width => 100 do hide_select_box = filter_class.available_operators.count == 1 options = {:class => "select-small filters-select filter_operator", :style => "vertical-align: top", # FIXME: put into CSS @@ -19,6 +20,6 @@ class Widget::Filters::Operators < Widget::Filters::Base l(filter_class.available_operators.first.label) end hide_select_box ? select_box + label : select_box - end + end) end end diff --git a/lib/widget/filters/remove_button.rb b/lib/widget/filters/remove_button.rb index a8c6bbde40..3cdbd16664 100644 --- a/lib/widget/filters/remove_button.rb +++ b/lib/widget/filters/remove_button.rb @@ -1,11 +1,11 @@ class Widget::Filters::RemoveButton < Widget::Filters::Base def render - content_tag :td, :width => "25px" do + write( content_tag :td, :width => "25px" do hidden_field = tag :input, :id => "rm_#{filter_class.underscore_name}", :name => "fields[]", :type => "hidden", :value => "" button = tag :input, :type => "button", :value => "", :class => "icon filter_rem icon-filter-rem" content_tag(:div, hidden_field + button, :id => "rm_box_#{filter_class.underscore_name}", :class => "remove-box") - end + end) end end diff --git a/lib/widget/filters/text_box.rb b/lib/widget/filters/text_box.rb index ae25d29b67..d32dec5c96 100644 --- a/lib/widget/filters/text_box.rb +++ b/lib/widget/filters/text_box.rb @@ -1,6 +1,6 @@ class Widget::Filters::TextBox < Widget::Filters::Base def render - content_tag :td do + write(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", @@ -8,6 +8,6 @@ class Widget::Filters::TextBox < Widget::Filters::Base :id => "#{filter_class.underscore_name}_arg_1_val", :'data-filter-name' => filter_class.underscore_name) end - end + end) end end diff --git a/lib/widget/group_bys.rb b/lib/widget/group_bys.rb index 5265204d6a..5639990ebe 100644 --- a/lib/widget/group_bys.rb +++ b/lib/widget/group_bys.rb @@ -51,10 +51,10 @@ class Widget::GroupBys < Widget::Base end def render - content_tag :div, :id => 'group_by_area' do + write(content_tag :div, :id => 'group_by_area' do out = render_group 'columns', @query.group_bys(:column) out += render_group 'rows', @query.group_bys(:row) out.html_safe - end + end) end end diff --git a/lib/widget/settings.rb b/lib/widget/settings.rb index f134cef9c2..4ee7161d90 100644 --- a/lib/widget/settings.rb +++ b/lib/widget/settings.rb @@ -19,7 +19,7 @@ class Widget::Settings < Widget::Base render_widget(Widget::Controls::Delete, @query, :to => widgets) end - fieldsets + controls + write(fieldsets + controls) end end end diff --git a/lib/widget/settings/fieldset.rb b/lib/widget/settings/fieldset.rb index c4f71d2d22..4f4b7db289 100644 --- a/lib/widget/settings/fieldset.rb +++ b/lib/widget/settings/fieldset.rb @@ -7,9 +7,9 @@ class Widget::Settings::Fieldset < Widget::Base end def render - content_tag :fieldset, :id => @id, :class => "collapsible collapsed" do + write(content_tag :fieldset, :id => @id, :class => "collapsible collapsed" do html = content_tag :legend, l(@label), :onclick => "toggleFieldset(this);" #FIXME: onclick html + yield - end + end) end end