Class: ActiveAdmin::Views::StatusTag
- Defined in:
- lib/active_admin/views/components/status_tag.rb
Overview
Build a StatusTag
Instance Method Summary collapse
-
#build(*args) ⇒ ActiveAdmin::Views::StatusTag
Examples: status_tag(‘In Progress’) # => <span class=‘status in_progress’>In Progress</span>.
- #default_class_name ⇒ Object
-
#status_tag(status, type = nil, options = {}) ⇒ ActiveAdmin::Views::StatusTag
Examples: status_tag(‘In Progress’) # => <span class=‘status in_progress’>In Progress</span>.
- #status_to_class(status) ⇒ Object protected
- #tag_name ⇒ Object
Methods inherited from Component
Constructor Details
This class inherits a constructor from ActiveAdmin::Component
Instance Method Details
#build(*args) ⇒ ActiveAdmin::Views::StatusTag
Examples:
status_tag('In Progress')
# => <span class='status in_progress'>In Progress</span>
status_tag('active', :ok)
# => <span class='status active ok'>Active</span>
status_tag('active', :ok, :class => 'important', :id => 'status_123', :label => 'on')
# => <span class='status active ok important' id='status_123'>on</span>
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_admin/views/components/status_tag.rb', line 33 def build(*args) = args. status = args[0] type = args[1] label = .delete(:label) classes = .delete(:class) content = label || status.titleize if status super(content, ) add_class(status_to_class(status)) if status add_class(type.to_s) if type add_class(classes) if classes end |
#default_class_name ⇒ Object
11 12 13 |
# File 'lib/active_admin/views/components/status_tag.rb', line 11 def default_class_name 'status' end |
#status_tag(status, type = nil, options = {}) ⇒ ActiveAdmin::Views::StatusTag
Examples:
status_tag('In Progress')
# => <span class='status in_progress'>In Progress</span>
status_tag('active', :ok)
# => <span class='status active ok'>Active</span>
status_tag('active', :ok, :class => 'important', :id => 'status_123', :label => 'on')
# => <span class='status active ok important' id='status_123'>on</span>
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_admin/views/components/status_tag.rb', line 33 def build(*args) = args. status = args[0] type = args[1] label = .delete(:label) classes = .delete(:class) content = label || status.titleize if status super(content, ) add_class(status_to_class(status)) if status add_class(type.to_s) if type add_class(classes) if classes end |
#status_to_class(status) ⇒ Object (protected)
51 52 53 |
# File 'lib/active_admin/views/components/status_tag.rb', line 51 def status_to_class(status) status.titleize.gsub(/\s/, '').underscore end |
#tag_name ⇒ Object
7 8 9 |
# File 'lib/active_admin/views/components/status_tag.rb', line 7 def tag_name 'span' end |