Sha256: 2845030cffe4ca769430dd026c5745fdca304b2cac4fff0635eca1bbbdbd0d9f
Contents?: true
Size: 1.55 KB
Versions: 9
Compression:
Stored size: 1.55 KB
Contents
module ActiveAdmin module Views # Build a StatusTag class StatusTag < ActiveAdmin::Component builder_method :status_tag def tag_name 'span' end def default_class_name 'status' end # @method status_tag(status, type = nil, options = {}) # # @param [String] status the status to display. One of the span classes will be an underscored version of the status. # @param [Symbol] type type of status. Will become a class of the span. ActiveAdmin provide style for :ok, :warning and :error. # @param [Hash] options such as :class, :id etc # # @return [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') # # => <span class='status active ok important' id='status_123'>Active</span> # def build(*args) options = args.extract_options! status = args[0] type = args[1] classes = options.delete(:class) status = status.titleize if status super(status, options) add_class(status_to_class(status)) if status add_class(type.to_s) if type add_class(classes) if classes end protected def status_to_class(status) status.titleize.gsub(/\s/, '').underscore end end end end
Version data entries
9 entries across 9 versions & 4 rubygems