Sha256: 0ab3aa57a1d64f2731867677b6c17ce61abfdda06a3685216b79061bbae915ff

Contents?: true

Size: 991 Bytes

Versions: 16

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    module TagsHelper
      TAG_GROUPS = {
        ccss_standards: 'CCSS Standard',
        ccss_domain: 'CCSS Domain',
        ccss_cluster: 'CCSS Cluster',
        texts: 'Texts',
        authors: 'Authors'
      }.freeze

      def render_tag_clouds(resource)
        named_tags = resource.filtered_named_tags
        render partial: 'lcms/engine/resources/tags',
               locals: { tag_clouds: tag_clouds(named_tags), color_code: color_code(resource) }
      end

      def tag_clouds(named_tags)
        named_tags[:ell_appropriate] = named_tags[:ell_appropriate] ? 'ELL Appropriate' : nil
        named_tags.transform_values { |v| Array.wrap(v).flatten.compact.uniq.sort }
      end

      def each_tags_cloud!(tag_clouds)
        tags = tag_clouds.keep_if { |k, v| TAG_GROUPS.key?(k) && v.present? }
        tags.each { |k, v| yield(v, TAG_GROUPS[k]) }
        yield([], nil) if tags.empty?
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.5.4 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.5.3 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.5.2 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.5.1 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.5.0 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.4.2 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.4.1 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.4.0 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.3.1 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.1.4 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.3.0 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.1.3 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.2.0 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.1.2 app/helpers/lcms/engine/tags_helper.rb
lcms-engine-0.1.0 app/helpers/lcms/engine/tags_helper.rb