Class: Geoblacklight::ResourceHeaderBadgeComponent

Inherits:
HeaderBadgeComponent show all
Defined in:
app/components/geoblacklight/resource_header_badge_component.rb

Instance Attribute Summary

Attributes inherited from HeaderBadgeComponent

#document, #field

Instance Method Summary collapse

Methods inherited from HeaderBadgeComponent

#initialize

Constructor Details

This class inherits a constructor from Geoblacklight::HeaderBadgeComponent

Instance Method Details

#dataset_typeObject



29
30
31
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 29

def dataset_type
  @dataset_type ||= @document.resource_type.find { |type| type.include?(" data") }&.gsub(" data", "")
end

#default_resource_iconObject



16
17
18
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 16

def default_resource_icon
  helpers.geoblacklight_icon(first_resource)
end

#first_resourceObject



33
34
35
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 33

def first_resource
  @first_resource ||= @document.resource_class.first
end

#icon(field) ⇒ Object



11
12
13
14
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 11

def icon(field)
  return resource_type_icon unless resource_type_icon_missing?
  default_resource_icon
end

#labelObject



5
6
7
8
9
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 5

def label
  return first_resource if resource_type_icon_missing?

  dataset_type
end

#resource_type_iconObject



25
26
27
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 25

def resource_type_icon
  @resource_type_icon ||= helpers.geoblacklight_icon(dataset_type)
end

#resource_type_icon_missing?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'app/components/geoblacklight/resource_header_badge_component.rb', line 20

def resource_type_icon_missing?
  return @resource_type_icon_missing if defined?(@resource_type_icon_missing)
  @resource_type_icon_missing = resource_type_icon.include?("icon-missing")
end