Class: Alchemy::Admin::LocaleSelect

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/alchemy/admin/locale_select.rb

Overview

Renders a locale select tag for switching the backend locale.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :admin_locale, auto_submit: true) ⇒ LocaleSelect

Returns a new instance of LocaleSelect.



7
8
9
10
# File 'app/components/alchemy/admin/locale_select.rb', line 7

def initialize(name = :admin_locale, auto_submit: true)
  @name = name
  @auto_submit = auto_submit
end

Instance Attribute Details

#auto_submitObject (readonly)

Returns the value of attribute auto_submit.



5
6
7
# File 'app/components/alchemy/admin/locale_select.rb', line 5

def auto_submit
  @auto_submit
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'app/components/alchemy/admin/locale_select.rb', line 5

def name
  @name
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
# File 'app/components/alchemy/admin/locale_select.rb', line 12

def call
  form_tag(helpers.url_for, method: :get) do
    if auto_submit
      ("alchemy-auto-submit", locale_select)
    else
      locale_select
    end
  end
end

#render?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/components/alchemy/admin/locale_select.rb', line 22

def render?
  available_locales.many?
end