Class: CustomModuleComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/custom_module_component.rb

Instance Method Summary collapse

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/custom_module_component.rb', line 11

def to_s
  toolbar = tag.div(style: "position: absolute; top: 4px; right: 4px; z-index: 10;") {
    tag.button(
      class: "ui mini icon button",
      type: "button",
      onclick: "$('.ui.flyout').flyout('show'); document.querySelector('#editor').src = '#{edit_url}'"
    ) {
      tag.i(class: "pencil icon")
    }
  }

  content = tag.div(
    data: {
      controller: "custom-module",
      "custom-module-id-value": module_id,
      "custom-module-data-fn-url-value": data_function_url,
      "custom-module-render-fn-url-value": render_function_url,
      "custom-module-config-value": config,
      "custom-module-shares-value": shares
    },
    class: "custom-module-content"
  )

  tag.div(**merge_html_options(style: "position: relative;")) {
    safe_join([toolbar, content])
  }
end