Sha256: f844f1a1b907f4685bfa71dd5945fa64a1501a1bd217e0e0a0e5c98bb8289268

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 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 Accordion to dynamically load components on expanding a panel or clicking
    # a tab.
    module WrapLazyLoaded
      def extend_item(item)
        item = super

        c = components[item[:netzke_component]].try(:merge, item)

        # 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 c && !c[:eager_loading]
          { layout: :fit,
            wrapped_component: c[:item_id],
            title: c[:title] || c[:item_id].humanize,
            icon_cls: c[:icon_cls],
            disabled: c[:disabled]
          }
        else
          item
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netzke-basepack-0.8.0 lib/netzke/basepack/wrap_lazy_loaded.rb