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



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

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

#charts(version, esm) ⇒ Object



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

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


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

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

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

#script_tag(attrs) ⇒ Object



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

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

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

#theme(version, file) ⇒ Object



46
47
48
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 46

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

#zuo_include_tagObject



14
15
16
17
18
19
20
21
22
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 14

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
9
10
11
12
# File 'app/helpers/zuora_connect_ui/application_helper.rb', line 6

def zuo_parameterize(string)
  if Rails::VERSION::STRING.start_with? '5'
    string.parameterize(separator: '_')
  else
    string.parameterize('_')
  end
end