Sha256: c75b837fcb5df548dd5e67db67d0be280ae9b75c95f5191539c0348457482fc0

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 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[:netzke_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],
              :icon_cls => wrapped_component[:icon_cls],
              :disabled => wrapped_component[:disabled]
            })
          end
        end
        orig
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
netzke-basepack-0.7.7 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-zh-0.7.6 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.6 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.5 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.4 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.3 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.2 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.1 lib/netzke/basepack/wrap_lazy_loaded.rb
netzke-basepack-0.7.0 lib/netzke/basepack/wrap_lazy_loaded.rb