Class: Matestack::Ui::VueJs::Vue
- Inherits:
-
Component
- Object
- Matestack::Ui::VueJs::Vue
show all
- Defined in:
- lib/matestack/ui/vue_js/vue.rb
Direct Known Subclasses
Components::Action, Components::App, Components::Async, Components::Cable, Components::Collection::Content, Components::Collection::Order, Components::Form::Base, Components::Form::FieldsForAddItem, Components::Form::Form, Components::Isolated, Components::Onclick, Components::PageSwitch, Components::Toggle, Components::Transition
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(html_tag = nil, text = nil, options = {}, &block) ⇒ Vue
Returns a new instance of Vue.
6
7
8
9
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 6
def initialize(html_tag = nil, text = nil, options = {}, &block)
(text, options)
super(html_tag, text, options, &block)
end
|
Class Method Details
.inherited(subclass) ⇒ Object
67
68
69
70
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 67
def self.inherited(subclass)
subclass.vue_name(self.vue_name)
super
end
|
.vue_name(name = nil) ⇒ Object
58
59
60
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 58
def self.vue_name(name = nil)
name ? @vue_name = name : @vue_name
end
|
Instance Method Details
#base_vue_props ⇒ Object
45
46
47
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 45
def base_vue_props
{ component_uid: component_uid }
end
|
#component_attributes ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 27
def component_attributes
{
is: vue_name,
ref: component_id,
':params': params.to_json,
':props': base_vue_props.merge(vue_props)&.to_json,
'v-slot': "{ vc }"
}
end
|
#component_id ⇒ Object
37
38
39
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 37
def component_id
options[:id] || nil
end
|
#component_uid ⇒ Object
41
42
43
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 41
def component_uid
@component_uid ||= SecureRandom.hex
end
|
#create_children(&block) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 11
def create_children(&block)
vue_component do
self.response do
block.call if block_given?
end
end
end
|
#matestack_ui_vuejs_ref(value) ⇒ Object
54
55
56
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 54
def matestack_ui_vuejs_ref(value)
return "#{component_uid}-#{value}" unless value.nil?
end
|
#vue_component(&block) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 19
def vue_component(&block)
Matestack::Ui::Core::Base.new(:component, component_attributes) do
Matestack::Ui::Core::Base.new("matestack-component-template", 'for': vue_name, 'id': "uid-#{component_uid}") do
yield
end
end
end
|
#vue_name ⇒ Object
62
63
64
65
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 62
def vue_name
raise "vue_name missing for #{self.class}" unless self.class.vue_name
self.class.vue_name
end
|
#vue_props ⇒ Object
Also known as:
config
49
50
51
|
# File 'lib/matestack/ui/vue_js/vue.rb', line 49
def vue_props
{} end
|