Class: Geoblacklight::HeaderIconsComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Geoblacklight::HeaderIconsComponent
- Defined in:
- app/components/geoblacklight/header_icons_component.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #icon(field) ⇒ Object
-
#initialize(document:, fields: [Settings.FIELDS.RESOURCE_CLASS, Settings.FIELDS.PROVIDER, Settings.FIELDS.ACCESS_RIGHTS]) ⇒ HeaderIconsComponent
constructor
A new instance of HeaderIconsComponent.
-
#resource_icon ⇒ Object
If the item has a resource type of “X data” where “X” is an existing icon, use that icon Otherwise just use the resource class icon.
Constructor Details
#initialize(document:, fields: [Settings.FIELDS.RESOURCE_CLASS, Settings.FIELDS.PROVIDER, Settings.FIELDS.ACCESS_RIGHTS]) ⇒ HeaderIconsComponent
Returns a new instance of HeaderIconsComponent.
7 8 9 10 11 |
# File 'app/components/geoblacklight/header_icons_component.rb', line 7 def initialize(document:, fields: [Settings.FIELDS.RESOURCE_CLASS, Settings.FIELDS.PROVIDER, Settings.FIELDS.ACCESS_RIGHTS]) @document = document @fields = fields super() end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'app/components/geoblacklight/header_icons_component.rb', line 5 def document @document end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'app/components/geoblacklight/header_icons_component.rb', line 5 def fields @fields end |
Instance Method Details
#icon(field) ⇒ Object
13 14 15 16 17 |
# File 'app/components/geoblacklight/header_icons_component.rb', line 13 def icon(field) return resource_icon if field == Settings.FIELDS.RESOURCE_CLASS helpers.geoblacklight_icon(@document[field], classes: "svg_tooltip") end |
#resource_icon ⇒ Object
If the item has a resource type of “X data” where “X” is an existing icon, use that icon Otherwise just use the resource class icon
21 22 23 24 25 26 27 |
# File 'app/components/geoblacklight/header_icons_component.rb', line 21 def resource_icon dataset_type = @document.resource_type.find { |type| type.include?(" data") }&.gsub(" data", "") resource_type_icon = helpers.geoblacklight_icon(dataset_type, classes: "svg_tooltip") return resource_type_icon unless resource_type_icon.include?("icon-missing") helpers.geoblacklight_icon(@document.resource_class.first, classes: "svg_tooltip") end |