Class: Matestack::Ui::VueJs::Components::Cable

Inherits:
Vue
  • Object
show all
Defined in:
lib/matestack/ui/vue_js/components/cable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Vue

#base_vue_props, #component_id, #component_uid, inherited, #initialize, #matestack_ui_vuejs_ref, #vue_component, vue_name, #vue_name

Constructor Details

This class inherits a constructor from Matestack::Ui::VueJs::Vue

Instance Attribute Details

#block_contentObject

Returns the value of attribute block_content.



8
9
10
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 8

def block_content
  @block_content
end

Instance Method Details

#component_attributesObject



25
26
27
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 25

def component_attributes
  super.merge('v-bind:initial-template': "#{self.block_content.to_json}")
end

#container_attributesObject



37
38
39
40
41
42
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 37

def container_attributes
  {
    class: 'matestack-cable-component-container',
    'v-bind:class': '{ loading: vc.loading === true }'
  }
end

#content(&block) ⇒ Object



19
20
21
22
23
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 19

def content(&block)
  Matestack::Ui::Core::Base.new(:without_parent, nil, nil) do
    div(class: 'matestack-cable-component-root', id: ctx.id, &block)
  end
end

#create_children(&block) ⇒ Object



13
14
15
16
17
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 13

def create_children(&block)
  # first render block content
  self.block_content = content(&block).render_content if block_given?
  super
end

#responseObject



29
30
31
32
33
34
35
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 29

def response
  div container_attributes do
    div wrapper_attributes do
      Matestack::Ui::Core::Base.new('matestack-ui-core-runtime-render', ':template': 'vc.cableTemplate', ':vc': 'vc')
    end
  end
end

#vue_propsObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 52

def vue_props
  {
    id: ctx.id,
    component_key: ctx.id,
    # events
    append_on: ctx.append_on,
    prepend_on: ctx.prepend_on,
    delete_on: ctx.delete_on,
    update_on: ctx.update_on,
    replace_on: ctx.replace_on,
  }
end

#wrapper_attributesObject



44
45
46
47
48
49
50
# File 'lib/matestack/ui/vue_js/components/cable.rb', line 44

def wrapper_attributes
  {
    class: 'matestack-cable-component-wrapper',
    'v-if': 'vc.cableTemplate != null',
    'v-bind:class': '{ loading: vc.loading === true }'
  }
end