Class: Geoblacklight::ResourceHeaderBadgeComponent
Instance Attribute Summary
#document, #field
Instance Method Summary
collapse
#initialize
Instance Method Details
#dataset_type ⇒ Object
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_icon ⇒ Object
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_resource ⇒ Object
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
|
#label ⇒ Object
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_icon ⇒ Object
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
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
|