Merge branch 'feature/widgets' of https://dev.finn.de/git/reporting-engine into feature/widgets

pull/6827/head
jwollert 14 years ago
commit 0bd5bbdcda
  1. 2
      assets/javascripts/reporting/controls.js
  2. 10
      assets/javascripts/reporting/progressbar.js
  3. 15
      lib/widget/base.rb
  4. 4
      lib/widget/controls.rb
  5. 2
      lib/widget/controls/apply.rb
  6. 2
      lib/widget/controls/clear.rb
  7. 2
      lib/widget/controls/delete.rb
  8. 2
      lib/widget/controls/query_name.rb
  9. 2
      lib/widget/controls/save.rb
  10. 3
      lib/widget/controls/save_as.rb
  11. 4
      lib/widget/help.rb

@ -121,8 +121,10 @@ Reporting.Controls = {
default_failure_callback: function (response) {
if (response.status >= 400 && response.status < 500) {
Reporting.flash(response.responseText);
Reporting.Progress.abort();
} else {
Reporting.flash("There was an error getting the results. The administrator has been informed.");
Reporting.Progress.abort();
}
}
};

@ -3,14 +3,18 @@
Reporting.Progress = {
abort: function () {
window.progressbar.stop();
},
replace_with_bar: function (element) {
var parent = element.up();
var size = parseInt(element.getAttribute('data-query-size'), 10) || 500;
element.remove();
var bar = Reporting.Progress.add_bar_to_parent(parent);
window.progressbar = Reporting.Progress.add_bar_to_parent(parent);
// Speed determined through laborous experimentation!
bar.options.interval = (size * (Math.log(size))) / 100000;
bar.start();
window.progressbar.options.interval = (size * (Math.log(size))) / 100000;
window.progressbar.start();
},
add_bar_to_parent: function (parent) {

@ -1,3 +1,5 @@
require 'digest/sha1'
class Widget::Base < Widget
attr_reader :engine, :output
@ -57,10 +59,12 @@ class Widget::Base < Widget
end
def cache_key
@cache_key ||= if subject.respond_to? :cache_key
"#{self.class.name.demodulize}/#{subject.cache_key}/#{@options.sort_by(&:to_s)}"
else
subject
@cache_key ||= Digest::SHA1::hexdigest begin
if subject.respond_to? :cache_key
"#{self.class.name.demodulize}/#{subject.cache_key}/#{@options.sort_by(&:to_s)}"
else
subject.inspect
end
end
end
@ -74,7 +78,6 @@ class Widget::Base < Widget
!self.class.dont_cache?
end
##
# Render this widget or serve it from cache
def render_with_cache(options = {}, &block)
@ -111,7 +114,7 @@ class Widget::Base < Widget
options[:fallback_html] ||= ''
output = "".html_safe
if text = options[:help_text] || help_text
output += render_widget Widget::Controls::Help, text do
output += render_widget Widget::Help, text do
options
end
else

@ -1,3 +1,7 @@
class Widget::Controls < Widget::Base
extend ProactiveAutoloader
def cache_key
"#{super}#{@query.new_record? ? 1 : 0}"
end
end

@ -1,5 +1,5 @@
class Widget::Controls::Apply < Widget::Base
class Widget::Controls::Apply < Widget::Controls
def render
write link_to content_tag(:span, content_tag(:em, l(:button_apply))), {},
:href => "#", :id => "query-icon-apply-button",

@ -1,5 +1,5 @@
class Widget::Controls::Clear < Widget::Base
class Widget::Controls::Clear < Widget::Controls
def render
html = link_to(content_tag(:span, content_tag(:em, l(:"button_clear"), :class => "button-icon icon-clear")),
'#', :id => 'query-link-clear', :class => 'button secondary')

@ -1,4 +1,4 @@
class Widget::Controls::Delete < Widget::Base
class Widget::Controls::Delete < Widget::Controls
def render
return "" if @query.new_record? or !@options[:can_delete]
button = link_to content_tag(:span, content_tag(:em, l(:button_delete), :class => "button-icon icon-delete")), "#",

@ -1,4 +1,4 @@
class Widget::Controls::QueryName < Widget::Base
class Widget::Controls::QueryName < Widget::Controls
dont_cache! # The name might change, but the query stays the same...
def render

@ -1,4 +1,4 @@
class Widget::Controls::Save < Widget::Base
class Widget::Controls::Save < Widget::Controls
def render
return "" if @query.new_record? or !@options[:can_save]
write link_to content_tag(:span, content_tag(:em, l(:button_save)), :class => "button-icon icon-save"), {},

@ -1,4 +1,5 @@
class Widget::Controls::SaveAs < Widget::Base
class Widget::Controls::SaveAs < Widget::Controls
def render
if @query.new_record?
link_name = l(:button_save)

@ -1,8 +1,8 @@
##
# Usgae: render_widget Widget::Controls::Help, :text
# Usage: render_widget Widget::Help, :text
#
# Where :text is a i18n key.
class Widget::Controls::Help < Widget::Base
class Widget::Help < Widget::Base
dont_cache!
def render
Loading…
Cancel
Save