Merge branch 'feature/widgets' of https://dev.finn.de/git/reporting-engine into feature/widgets
commit
0f7e6c82d4
@ -1,2 +1,35 @@ |
||||
class Widget::Settings < Widget::Base |
||||
def render |
||||
form_for @query, :url => "#", :html => {:id => 'query_form', :method => :post} do |query_form| |
||||
content_tag :div, :id => "query_form_content" do |
||||
|
||||
fieldsets = render_widget Widget::Settings::Fieldset, :type => "filter" do |
||||
render_widget Widget::Filters, @query |
||||
end |
||||
|
||||
fieldsets += render_widget Widget::Settings::Fieldset, :type => "group_by" do |
||||
render_widget Widget::GroupBys, @query |
||||
end |
||||
|
||||
buttons = content_tag :p, :class => "buttons form_controls" do |
||||
p = link_to({}, {:href => "#", |
||||
:onclick => " |
||||
selectAllOptions('group_by_rows'); |
||||
selectAllOptions('group_by_columns'); |
||||
new Ajax.Updater('result-table', |
||||
'#{url_for(:action => 'index', :set_filter => '1')}', |
||||
{ asynchronous:true, |
||||
evalScripts:true, |
||||
postBody: Form.serialize('query_form') + '\\n' + $('filters').innerHTML }); |
||||
return false;".html_safe, |
||||
:class => 'button apply'}) do |
||||
content_tag(:span, content_tag(:em, l(:button_apply))) |
||||
end |
||||
p += link_to_function l(:button_reset), "restore_query_inputs();", :class => 'icon icon-reload' |
||||
end |
||||
|
||||
fieldsets + buttons |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
@ -0,0 +1,15 @@ |
||||
class Widget::Settings::Fieldset < Widget::Base |
||||
def render_with_options(options, &block) |
||||
@type = options.delete(:type) || "filter" |
||||
@id = "#{@type}-settings" |
||||
@label = :"label_#{@type}" |
||||
super(options, &block) |
||||
end |
||||
|
||||
def render |
||||
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 |
@ -1,2 +1,22 @@ |
||||
class Widget::Table < Widget::Base |
||||
def render |
||||
if @query.group_bys.empty? |
||||
widget = Widget::Table::DetailedTable |
||||
else |
||||
if @query.depth_of(:column) == 0 |
||||
@query.column(:singleton_value) |
||||
elsif @query.depth_of(:row) == 0 |
||||
@query.row(:singleton_value) |
||||
end |
||||
widget = Widget::Table::ReportTable |
||||
end |
||||
|
||||
content_tag :div, :id => "result-table" do |
||||
if @query.result.count > 0 |
||||
render_widget widget, @query |
||||
else |
||||
content_tag :p, l(:label_no_data), :class => "nodata" |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
@ -0,0 +1,2 @@ |
||||
class Widget::Table::DetailedTable < Widget::Base |
||||
end |
@ -0,0 +1,5 @@ |
||||
class Widget::Table::ReportTable < Widget::Base |
||||
def render |
||||
"blah" |
||||
end |
||||
end |
Loading…
Reference in new issue