Sha256: 0cf56c099fe7dfd4a8683911be8eab3babb04494df6e73aeb037f4a513ec0451

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module Netzke
  module Basepack
    # Include this module into your component component class when you want lazy-loaded component in config to be auto-replaced with
    # a panel with the 'fit' layout, and a property wrappedComponent set to the name of the original component.
    # Used, for instance, in TabPanel and AccordionPanel to dynamically load components on expanding a panel or clicking
    # a tab.
    module WrapLazyLoaded
      def items
        orig = super.dup
        orig.each do |item|
          wrapped_component = components[item[:component]]
          # When a nested component with lazy loading is detected, it gets replaced with a 'fit' panel,
          # into which later the component itself is dynamically loaded on request.
          if wrapped_component && wrapped_component[:lazy_loading]
            item.replace({
              :layout => 'fit',
              :wrapped_component => wrapped_component[:name],
              :title => wrapped_component[:title] || wrapped_component[:name]
            })
          end
        end
        orig
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netzke-basepack-0.6.2 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.6.1 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.6.0 lib/netzke/basepack/wrap_lazy_loaded.rb