Sha256: dd559ef16c8f8e6a32e77b778c02fb2ce4ae0b96b3edd679685de48a2fd2eae9

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require 'ui_bibz/ui/extensions/core/forms/connect_extension'
module SurroundExtension
  include ConnectExtension

  private

  def surrounded?
    !options[:append].nil? || !options[:prepend].nil? || !options[:refresh].nil? || !options[:surrounded].nil?
  end

  def surround_wrapper_tag(ct_tag)
    UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(class: surround_classes).tap do |sf|
      sf.addon options[:append] unless options[:append].nil?
      sf.html ct_tag
      sf.button_refresh connect_opts      unless options[:refresh].nil?
      sf.addon options[:prepend]          unless options[:prepend].nil?
    end.render
  end

  def surround_field(field_tag, _options = {})
    surrounded? ? surround_wrapper_tag(field_tag) : field_tag
  end

  def surround_classes
    [input_group_refresh, input_group_classes]
  end

  def input_group_refresh
    'field-refresh' unless options[:refresh].nil?
  end

  def input_group_classes
    [input_group_status, input_group_size]
  end

  # :lg, :sm or :xs
  def input_group_size
    "input-group-#{options[:size]}" unless options[:size].nil?
  end

  def input_group_status
    "has-#{options[:status]}" unless options[:status].nil?
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ui_bibz-3.0.0.alpha6 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-3.0.0.alpha5 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-3.0.0.alpha3 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-3.0.0.alpha2 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-2.5.6 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-2.5.5 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-2.5.3 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-2.5.2 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-2.5.1 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb
ui_bibz-2.5.0 lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb