Sha256: 8724a37d2cd7520d7a266477c17052ed004a805fe1f184b5ece204d881771d04

Contents?: true

Size: 1.78 KB

Versions: 68

Compression:

Stored size: 1.78 KB

Contents

module EgovUtils
  module ApplicationHelper

    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

    def main_schema_attribute(schema)
      schema.available_attributes_hash[schema.main_attribute_name]
    end

    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

    def google_analytics_code
    end

    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

    def egov_breadcrumbs
      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

  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
egov_utils-1.5.0.alpha16 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha15 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha14 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha13 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha12 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha11 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha10 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha9 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha8 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha7 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha6 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha5 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha4 app/helpers/egov_utils/application_helper.rb
egov_utils-1.4.5 app/helpers/egov_utils/application_helper.rb
egov_utils-1.4.4 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha3 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha2 app/helpers/egov_utils/application_helper.rb
egov_utils-1.5.0.alpha1 app/helpers/egov_utils/application_helper.rb
egov_utils-1.4.3 app/helpers/egov_utils/application_helper.rb
egov_utils-1.4.2 app/helpers/egov_utils/application_helper.rb