Class: Matestack::Ui::VueJs::Components::Isolated
- Inherits:
-
Vue
- Object
- Vue
- Matestack::Ui::VueJs::Components::Isolated
show all
- Defined in:
- lib/matestack/ui/vue_js/components/isolated.rb
Instance Method Summary
collapse
Methods inherited from Vue
#base_vue_props, #component_attributes, #component_id, #component_uid, inherited, #matestack_ui_vuejs_ref, #vue_component, vue_name, #vue_name
Constructor Details
#initialize(html_tag = nil, text = nil, options = {}, &block) ⇒ Isolated
Returns a new instance of Isolated.
10
11
12
13
14
15
16
17
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 10
def initialize(html_tag = nil, text = nil, options = {}, &block)
(text, options)
only_public_options!
isolated_parent = Matestack::Ui::Core::Context.isolated_parent
Matestack::Ui::Core::Context.isolated_parent = self
super(html_tag, text, options, &block)
Matestack::Ui::Core::Context.isolated_parent = isolated_parent
end
|
Instance Method Details
#authorized? ⇒ Boolean
70
71
72
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 70
def authorized?
raise "'authorized?' needs to be implemented by '#{self.class}'"
end
|
#create_children ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 19
def create_children
warn "[WARNING] '#{self.class}' was accessed but not authorized" unless authorized?
if params[:component_class].present?
self.response if authorized?
else
self.isolated do
self.response if authorized?
end
end
end
|
#isolated ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 31
def isolated
vue_component do
div class: 'matestack-isolated-component-container', 'v-bind:class': '{ loading: vc.loading === true }' do
if self.respond_to? :loading_state_element
div class: 'loading-state-element-wrapper', 'v-bind:class': '{ loading: vc.loading === true }' do
loading_state_element
end
end
unless ctx.defer || ctx.init_on
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate == null', 'v-bind:class': '{ loading: vc.loading === true }' do
div class: 'matestack-isolated-component-root' do
yield
end
end
end
div class: 'matestack-isolated-component-wrapper', 'v-if': 'vc.isolatedTemplate != null', 'v-bind:class': '{ loading: vc.loading === true }' do
div class: 'matestack-isolated-component-root' do
Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.isolatedTemplate', ':vc': 'vc')
end
end
end
end
end
|
#only_public_options! ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 74
def only_public_options!
if self.options.except(:defer, :init_on, :public_options, :rerender_on, :rerender_delay).keys.any?
error_message = "isolated components can only take params in a public_options hash, which will be exposed to the client side in order to perform an async request with these params."
error_message << " Check your usages of '#{self.class}' components"
raise error_message
end
end
|
#public_options ⇒ Object
66
67
68
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 66
def public_options
ctx.public_options || {}
end
|
#vue_props ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/matestack/ui/vue_js/components/isolated.rb', line 55
def vue_props
{
component_class: self.class.name,
public_options: ctx.public_options,
defer: ctx.defer,
rerender_on: ctx.rerender_on,
rerender_delay: ctx.rerender_delay,
init_on: ctx.init_on,
}
end
|