app/presentation/section_renderer.rb in umlaut-4.0.3 vs app/presentation/section_renderer.rb in umlaut-4.1.0.pre.alpha.1
- old
+ new
@@ -234,11 +234,10 @@
# If you want to disable even this, becuase your partial will take care of it
# itself, you can do so with \:show_partial_only => true
# {:div_id => "search_inside", :partial => "search_inside", :show_partial_only => true}
class SectionRenderer
include ActionView::Helpers::TagHelper
- @@bg_update_sections = @@partial_update_sections = nil
# First argument is the current umlaut Request object.
# Second argument is a session description hash. See class overview
# for an overview. Recognized keys of session description hash:
# * [id] SessionRenderer will look up session description hash in
@@ -264,16 +263,16 @@
# standardized wrapping HTML. Custom partial will
# take care of it itself.
def initialize(a_umlaut_request, section_def = {})
@umlaut_request = a_umlaut_request
- @section_id = section_def[:id] || section_def[:div_id]
- raise Exception.new("SectionRenderer needs an :id passed in arguments hash") unless @section_id
+ @div_id = section_def[:div_id] || section_def[:id]
+ raise Exception.new("SectionRenderer needs a :div_id passed in arguments hash") unless @div_id
+
# Merge in default arguments for this section from config.
construct_options(section_def)
-
end
# Returns all ServiceTypeValue objects contained in this section, as
# configured. Lazy caches result for perfomance.
def service_type_values
@@ -317,11 +316,11 @@
def request
return @umlaut_request
end
def div_id
- return @section_id
+ return @div_id
end
def show_heading?
(! show_partial_only?) && @options[:show_heading]
end
@@ -339,11 +338,11 @@
custom_item_name = I18n.t("load_more_item_name", :scope => "umlaut.display_sections.#{self.div_id}", :default => "")
custom_item_name = nil if custom_item_name.blank?
{ :partial => "background_progress",
:locals =>{ :svc_types => service_type_values,
- :div_id => "progress_#{@section_id}",
+ :div_id => "progress_#{self.div_id}",
:current_set_empty => responses_empty?,
:item_name => custom_item_name
}
}
end
@@ -402,11 +401,11 @@
# Have any responses of our type actually been generated?
! responses_empty?
when :complete_with_responses
(! responses.empty?) && ! (services_in_progress?)
when Proc
- # It's a lambda, which takes @umlaut_request as an arg
+ # It's a lambda, which takes this SectionRenderer as an arg
@options[:visibility].call(self)
else true
end
end
@@ -502,23 +501,23 @@
:show_partial_only => false,
:partial_locals => {}}.merge!(arguments)
# service type value default to same name as section_id
- @options[:service_type_values] ||= [@section_id]
+ @options[:service_type_values] ||= [self.div_id]
# Partials to display. Default to _standard_response_item item partial.
if ( @options[:partial] == true)
- @options[:partial] = @section_id
+ @options[:partial] = self.div_id
end
- if (@options[:partial].blank?)
- @options[:item_partial] =
- case @options[:item_partial]
- when true then @section_id + "_item"
- when String then options[:item_partial]
- else "standard_response_item"
- end
- end
+
+ @options[:item_partial] =
+ case @options[:item_partial]
+ when true then self.div_id + "_item"
+ when String then options[:item_partial]
+ else "standard_response_item"
+ end
+
# sanity check
if ( @options[:show_partial_only] && ! @options[:partial])
raise Exception.new("SectionRenderer: You must supply a :partial argument if :show_partial_only is set true")
end