Module: Lcms::Engine::TagsHelper

Defined in:
app/helpers/lcms/engine/tags_helper.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#each_tags_cloud!(tag_clouds) {|[], nil| ... } ⇒ Object

Yields:

  • ([], nil)


25
26
27
28
29
# File 'app/helpers/lcms/engine/tags_helper.rb', line 25

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

#render_tag_clouds(resource) ⇒ Object



14
15
16
17
18
# File 'app/helpers/lcms/engine/tags_helper.rb', line 14

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

#tag_clouds(named_tags) ⇒ Object



20
21
22
23
# File 'app/helpers/lcms/engine/tags_helper.rb', line 20

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