Module: ZuoraConnectUi::ApplicationHelper

Defined in:
app/helpers/zuora_connect_ui/application_helper.rb

Overview

General helpers for application level

Constant Summary collapse

ANJUNA_VERSION =
'1.2.14'
THEME_VERSION =
'1.2.14'

Instance Method Summary collapse

Instance Method Details

#anjuna(version, esm) ⇒ Object



26
27
28
29
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 26

def anjuna(version, esm)
  "https://cdn.zuora.com/@anjuna/core@#{version}" \
    "/anjuna-core/anjuna-core#{'.esm' if esm}.js"
end

#charts(version, esm) ⇒ Object



31
32
33
34
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 31

def charts(version, esm)
  "https://cdn.zuora.com/@anjuna/charts@#{version}" \
    "/anjuna-charts/anjuna-charts#{'.esm' if esm}.js"
end


36
37
38
39
40
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 36

def link_tag(attrs)
  attr_map = attrs.map { |key, value| " #{key}=\"#{value}\"" }

  "<link#{attr_map.join('')}>".html_safe
end

#script_tag(attrs) ⇒ Object



20
21
22
23
24
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 20

def script_tag(attrs)
  attr_map = attrs.map { |key, value| " #{key}=\"#{value}\"" }

  "<script#{attr_map.join('')}></script>".html_safe
end

#theme(version, file) ⇒ Object



42
43
44
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 42

def theme(version, file)
  "https://cdn.zuora.com/@anjuna/theme@#{version}/css/#{file}.css"
end

#zuo_include_tagObject



10
11
12
13
14
15
16
17
18
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 10

def zuo_include_tag
  script_tag(type: 'module', src: anjuna(ANJUNA_VERSION, true)) +
    script_tag(nomodule: '', src: anjuna(ANJUNA_VERSION, false)) +
    script_tag(type: 'module', src: charts(ANJUNA_VERSION, true)) +
    script_tag(nomodule: '', src: charts(ANJUNA_VERSION, false)) +
    link_tag(href: theme(THEME_VERSION, 'application'), rel: 'stylesheet') +
    link_tag(href: theme(THEME_VERSION, 'theme'), rel: 'stylesheet') +
    link_tag(href: theme(THEME_VERSION, 'icons'), rel: 'stylesheet')
end

#zuo_parameterize(string) ⇒ Object



6
7
8
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 6

def zuo_parameterize(string)
  string.parameterize(separator: '_')
end