Class: Avo::Resources::Controls::CreateButton

Inherits:
BaseControl
  • Object
show all
Defined in:
lib/avo/resources/controls/create_button.rb

Instance Attribute Summary

Attributes inherited from BaseControl

#as_index_control, #color, #confirmation_message, #icon, #icon_class, #label, #size, #style, #title

Instance Method Summary collapse

Methods inherited from BaseControl

#type

Constructor Details

#initialize(**args) ⇒ CreateButton

Returns a new instance of CreateButton.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/avo/resources/controls/create_button.rb', line 5

def initialize(**args)
  super

  if args[:item].present?
    # upcase_first, not humanize: the item is already the sentence form
    # (translation verbatim, generated fallback lowercased), and locales
    # like de put it first ("%{item} hinzufügen"), so only the sentence's
    # initial is cased -- the interpolated name stays as translated.
    @label = I18n.t("avo.create_new_item", item: args[:item]).upcase_first if label.nil?
  end
end