Sha256: 9e5e4dcc3bbeda9872c7f5c59a4df113eebeef0fc28ee8a65796936af2fa010d

Contents?: true

Size: 850 Bytes

Versions: 26

Compression:

Stored size: 850 Bytes

Contents

module Locomotive
  class ApiKeyInput
    include Formtastic::Inputs::Base

    def to_html
      input_wrapping do
        label_html <<
        api_key_html <<
        regenerate_button
      end
    end

    def input_wrapping(&block)
      template.content_tag(:li,
        [template.capture(&block), hint_html].join("\n").html_safe,
        wrapper_html_options
      )
    end

    def api_key_html
      api_key = self.object.api_key || I18n.t('locomotive.api_key.none')
      template.content_tag :code, api_key
    end

    def regenerate_button
      url = options[:url]
      template.content_tag :button, I18n.t('locomotive.api_key.button'),
        class:  'regenerate',
        data:   {
          url:      url,
          confirm:  I18n.t('locomotive.messages.confirm')
        }
    end

    def errors?
      false
    end

  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.6 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.6.rc2 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.6.rc1 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.5 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.4 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.3 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.2 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.1 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.0 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.0.rc3 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.0.rc2 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.5.0.rc1 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.4.1 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.4.0 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.3.1 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.3.0 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.2.3 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.2.2 app/inputs/locomotive/api_key_input.rb
locomotive_cms-2.2.1 app/inputs/locomotive/api_key_input.rb