Sha256: f5b7bb68c6ce40fd6a07c38ef701118faf3d253a212a8d3a4d87f18f996f81c0

Contents?: true

Size: 880 Bytes

Versions: 4

Compression:

Stored size: 880 Bytes

Contents

module PageletRails::Concerns::Placeholder
  extend ActiveSupport::Concern

  # This concern should be called after cache callback
  # #process_action method does not give such order
  # as it's called before callbacks
  def send_action *args
    render_remote_load
    if !performed?
      super
    end
  end

  def render_remote_load
    # puts 'render_remote_load'.blue
    render_remotely = pagelet_render_remotely?
    if render_remotely && pagelet_options.has_cache
      render_remotely = false
    end

    return unless render_remotely

    data = params.deep_dup
    data.permit!

    if pagelet_options.remote != :stream
      pagelet_options html: { 'data-widget-url' => url_for(data) }
    end

    default_view = '/layouts/pagelet_rails/loading_placeholder'
    view = pagelet_options.placeholder.try(:[], :view).presence || default_view

    render view
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pagelet_rails-0.1.3 lib/pagelet_rails/concerns/placeholder.rb
pagelet_rails-0.1.2 lib/pagelet_rails/concerns/placeholder.rb
pagelet_rails-0.1.1 lib/pagelet_rails/concerns/placeholder.rb
pagelet_rails-0.1.0 lib/pagelet_rails/concerns/placeholder.rb