Class: ActiveAdmin::Views::StatusTag
- Defined in:
- lib/active_admin/views/components/status_tag.rb
Overview
Build a StatusTag
Instance Method Summary collapse
- #status_tag(status, options = {}) ⇒ ActiveAdmin::Views::StatusTag
- #convert_to_boolean_status(status) ⇒ Object protected
- #default_class_name ⇒ Object
- #status_to_class(status) ⇒ Object protected
- #tag_name ⇒ Object
Instance Method Details
#status_tag(status, options = {}) ⇒ ActiveAdmin::Views::StatusTag
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/active_admin/views/components/status_tag.rb', line 31 def build(*args) = args. status = args[0] type = args[1] label = .delete(:label) classes = .delete(:class) status = convert_to_boolean_status(status) if status content = label || if s = status.to_s and s.present? I18n.t "active_admin.status_tag.#{s.downcase}", default: s.titleize end end super(content, ) add_class(status_to_class(status)) if status if type Deprecation.warn <<-MSG.strip_heredoc The `type` parameter has been deprecated. Provide the "#{type}" type as a class instead. For example, `status_tag(status, :#{type}, class: "abc")` would change to `status_tag(status, class: "#{type} abc")`. Also note that the "#{type}" CSS rule will be removed too, so you'll have to provide the styles yourself. See https://github.com/varyonic/activeadmin/blob/main/CHANGELOG.md#110- for more information. MSG add_class(type.to_s) end add_class(classes) if classes end |
#convert_to_boolean_status(status) ⇒ Object (protected)
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_admin/views/components/status_tag.rb', line 67 def convert_to_boolean_status(status) case status when true, 'true' 'Yes' when false, 'false', nil 'No' else status end end |
#default_class_name ⇒ Object
11 12 13 |
# File 'lib/active_admin/views/components/status_tag.rb', line 11 def default_class_name 'status_tag' end |
#status_to_class(status) ⇒ Object (protected)
78 79 80 81 82 83 84 85 |
# File 'lib/active_admin/views/components/status_tag.rb', line 78 def status_to_class(status) case status when String, Symbol status.to_s.titleize.gsub(/\s/, '').underscore else '' end end |
#tag_name ⇒ Object
7 8 9 |
# File 'lib/active_admin/views/components/status_tag.rb', line 7 def tag_name 'span' end |