class Matestack::Ui::VueJs::Components::Async
Public Class Methods
new(html_tag = nil, text = nil, options = {}, &block)
click to toggle source
register itself as an async component in the context
Calls superclass method
Matestack::Ui::VueJs::Vue::new
# File lib/matestack/ui/vue_js/components/async.rb, line 12 def initialize(html_tag = nil, text = nil, options = {}, &block) super(html_tag, text, options, &block) Matestack::Ui::Core::Context.async_components = {} if Matestack::Ui::Core::Context.async_components.nil? Matestack::Ui::Core::Context.async_components[self.ctx.id] = self end
Public Instance Methods
async_attributes()
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 49 def async_attributes options.merge({ id: ctx.id, class: 'matestack-async-component-root', 'v-if': 'showing' }) end
create_children(&block)
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 18 def create_children(&block) self.response &block end
is_deferred?()
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 68 def is_deferred? ctx.defer end
is_not_requested?()
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 72 def is_not_requested? params[:component_key].present? && params[:component_key] != ctx.id end
isolated_parent()
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 76 def isolated_parent Matestack::Ui::Core::Context.isolated_parent end
response() { || ... }
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 22 def response if params[:component_key] && !is_not_requested? div async_attributes do yield end else vue_component do div class: 'matestack-async-component-container', 'v-bind:class': '{ "loading": loading === true }' do div class: 'matestack-async-component-wrapper', 'v-if': 'asyncTemplate == null', 'v-bind:class': '{ "loading": loading === true }' do div async_attributes do if params[:component_key] # we need to yield if a request is looking for a async component, indicated through present params[:component_key] # the requested component could be hidden within this deferred async! yield else yield unless is_deferred? end end end div class: 'matestack-async-component-wrapper', 'v-if': 'asyncTemplate != null', 'v-bind:class': '{ "loading": loading === true }' do Matestack::Ui::Core::Base.new('v-runtime-template', ':template': 'asyncTemplate') end end end end end
vue_props()
click to toggle source
# File lib/matestack/ui/vue_js/components/async.rb, line 57 def vue_props { component_key: ctx.id, show_on: ctx.show_on, hide_on: ctx.hide_on, rerender_on: ctx.rerender_on, defer: ctx.defer, parent_class: isolated_parent ? isolated_parent.class.to_s : nil, } end