Class: SolidusAdmin::Products::Status::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::Products::Status::Component
- Defined in:
- app/components/solidus_admin/products/status/component.rb
Constant Summary collapse
- STATUSES =
{ available: :green, discontinued: :yellow, deleted: :red, unavailable: :yellow }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(status:) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(status:) ⇒ Component
Returns a new instance of Component.
26 27 28 |
# File 'app/components/solidus_admin/products/status/component.rb', line 26 def initialize(status:) @status = status end |
Class Method Details
.from_product(product) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/solidus_admin/products/status/component.rb', line 11 def self.from_product(product) status = if product.deleted? :deleted elsif product.discontinued? :discontinued elsif product.available? :available else :unavailable end new(status:) end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 |
# File 'app/components/solidus_admin/products/status/component.rb', line 30 def call render component('ui/badge').new( name: t(".#{@status}"), color: STATUSES.fetch(@status) ) end |