Module: EgovUtils::ApplicationHelper
- Defined in:
- app/helpers/egov_utils/application_helper.rb
Instance Method Summary collapse
- #egov_breadcrumbs ⇒ Object
- #google_analytics_code ⇒ Object
- #google_analytics_snippet ⇒ Object
- #i18n_js_set_locales_tag ⇒ Object
- #main_schema_attribute(schema) ⇒ Object
- #role_based_render(name, *attributes) ⇒ Object
Instance Method Details
#egov_breadcrumbs ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/egov_utils/application_helper.rb', line 40 def if block_given? links = [] yield(links) end content_tag('nav', 'aria-label' => 'breadcrumb') do content_tag('ol', class: 'breadcrumb') do s = links[0..-2].collect do |link| content_tag(:li, link, class: 'breadcrumb-item' ) end.join(' ').html_safe s << content_tag(:li, links.last, class: 'breadcrumb-item active') s end end end |
#google_analytics_code ⇒ Object
25 26 |
# File 'app/helpers/egov_utils/application_helper.rb', line 25 def google_analytics_code end |
#google_analytics_snippet ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/egov_utils/application_helper.rb', line 28 def google_analytics_snippet javascript_tag(<<-END_JS) if google_analytics_code (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', '#{google_analytics_code}', 'auto'); ga('send', 'pageview'); END_JS end |
#i18n_js_set_locales_tag ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/helpers/egov_utils/application_helper.rb', line 4 def i18n_js_set_locales_tag s = '' s << "window.I18n.defaultLocale = '#{I18n.default_locale}';" s << "window.I18n.locale = '#{I18n.locale}';" s << "window.currency_symbols = #{Money::Currency.table.each_with_object({}){|(k,v),o|o[k]=v[:symbol]}.to_json};" s javascript_tag s end |
#main_schema_attribute(schema) ⇒ Object
13 14 15 |
# File 'app/helpers/egov_utils/application_helper.rb', line 13 def main_schema_attribute(schema) schema.available_attributes_hash[schema.main_attribute_name] end |
#role_based_render(name, *attributes) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/helpers/egov_utils/application_helper.rb', line 17 def role_based_render(name, *attributes) res = ''.html_safe current_user.all_role_names.each do |role_name| res << render(name+'_'+role_name, *attributes) if lookup_context.exists?(name+'_'+role_name, [], true) end res end |