Class: Avo::Fields::BadgeField

Inherits:
BaseField show all
Defined in:
lib/avo/fields/badge_field.rb

Defined Under Namespace

Classes: IndexComponent, ShowComponent

Instance Attribute Summary collapse

Attributes inherited from BaseField

#action, #as_avatar, #as_description, #as_label, #block, #computable, #computed, #computed_value, #default, #format_using, #help, #id, #model, #null_values, #nullable, #panel_name, #readonly, #required, #resource, #sortable, #updatable, #user, #view, #visible

Attributes included from FieldExtensions::VisibleInDifferentViews

#show_on_edit, #show_on_index, #show_on_new, #show_on_show

Instance Method Summary collapse

Methods inherited from BaseField

#component_for_view, #custom?, #database_id, #fill_field, #has_own_panel?, #hydrate, #model_errors, #name, #placeholder, #resolve_attribute, #to_permitted_param, #translation_key, #type, #value, #view_component_name, #visible?

Methods included from FieldExtensions::HasFieldName

#field_name, #get_field_name

Methods included from FieldExtensions::VisibleInDifferentViews

#except_on, #hide_on, #only_on, #show_on

Constructor Details

#initialize(id, **args, &block) ⇒ BadgeField

Returns a new instance of BadgeField.



6
7
8
9
10
11
12
13
# File 'lib/avo/fields/badge_field.rb', line 6

def initialize(id, **args, &block)
  super(id, **args, &block)

  hide_on [:edit, :new]

  default_options = {info: :info, success: :success, danger: :danger, warning: :warning}
  @options = args[:options].present? ? default_options.merge(args[:options]) : default_options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/avo/fields/badge_field.rb', line 4

def options
  @options
end