Module: Magick::AdminUI::Helpers

Defined in:
lib/magick/admin_ui/helpers.rb

Class Method Summary collapse

Class Method Details

.feature_status_badge(status) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/magick/admin_ui/helpers.rb', line 6

def self.feature_status_badge(status)
  klass = case status.to_sym
          when :active then 'badge badge-success'
          when :deprecated then 'badge badge-warning'
          when :inactive then 'badge badge-danger'
          else 'badge'
          end
  label = case status.to_sym
          when :active then 'Active'
          when :deprecated then 'Deprecated'
          when :inactive then 'Inactive'
          else 'Unknown'
          end

  if defined?(ActionController::Base)
    ActionController::Base.helpers.(:span, label, class: klass)
  else
    # Fallback when Rails is not present. Label is a whitelisted literal.
    "<span class=\"#{klass}\">#{label}</span>"
  end
end

.feature_type_label(type) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/magick/admin_ui/helpers.rb', line 28

def self.feature_type_label(type)
  case type.to_sym
  when :boolean then 'Boolean'
  when :string then 'String'
  when :number then 'Number'
  else type.to_s.capitalize
  end
end