Class: UiBibz::Ui::Core::Forms::Surrounds::SurroundField

Inherits:
Component
  • Object
show all
Includes:
UiBibz::Ui::Concerns::HtmlConcern
Defined in:
lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb

Overview

Create a TextField

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

  • content - Content of element

  • options - Options of element

  • html_options - Html Options of element

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

  • prepend - String, Html

  • append - String, Html

Signatures

UiBibz::Ui::Core::Forms::Surrounds::Surround.new(options = {}, html_options = {}) do |s|
  s.
end.render

Examples

UiBibz::Ui::Core::Forms::Texts::TextField.new('search', prepend: 'Prepend content', append: 'Append content', class: 'test')

UiBibz::Ui::Core::Forms::Texts::TextField.new(prepend: glyph('pencil'), append: glyph('camera-retro')) do
  #content
end

Helper

text_field(options = {}, html_options = {}) do
 # content
end

Constant Summary

Constants inherited from Component

Component::BREAKPOINTS, Component::SIZES, Component::STATUSES

Instance Attribute Summary collapse

Attributes inherited from Component

#content, #html_options, #options

Attributes inherited from Base

#output_buffer

Instance Method Summary collapse

Methods inherited from Component

#render, #tapped?

Methods included from PopoverExtension

#popover_data_html, #tooltip_data_html

Methods included from GlyphExtension

#generate_glyph, #glyph_and_content_html

Methods included from KlassExtension

#exclude_classes, #exclude_classes_in_html_options, #join_classes

Methods inherited from Base

#generate_id, #i18n_set?, #inject_url

Constructor Details

#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ SurroundField

See UiBibz::Ui::Core::Component.initialize



55
56
57
58
59
60
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 55

def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @items = []
  @errors = []
  @required_fields = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



52
53
54
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 52

def errors
  @errors
end

#required_fieldsObject (readonly)

Returns the value of attribute required_fields.



52
53
54
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 52

def required_fields
  @required_fields
end

Instance Method Details

#addon(content = nil, options = {}, html_options = nil, &block) ⇒ Object



82
83
84
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 82

def addon(content = nil, options = {}, html_options = nil, &block)
  @items << SurroundAddon.new(content, options, html_options, &block).render
end

#auto_complete_field(content = nil, options = nil, html_options = nil, &block) ⇒ Object



127
128
129
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 127

def auto_complete_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new(content, options, html_options, &block).render
end

#button(content = nil, options = nil, html_options = nil, &block) ⇒ Object



86
87
88
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 86

def button(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButton.new(content, options, html_options, &block).render
end

#button_group(content = nil, options = nil, html_options = nil, &block) ⇒ Object



90
91
92
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 90

def button_group(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButtonGroup.new(content, options, html_options).tap(&block).render
end


94
95
96
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 94

def button_link(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButtonLink.new(content, options, html_options, &block).render
end

#button_refresh(content = nil, options = nil, html_options = nil, &block) ⇒ Object



98
99
100
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 98

def button_refresh(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundButtonRefresh.new(content, options, html_options, &block).render
end

#checkbox_field(content = nil, options = nil, html_options = nil, &block) ⇒ Object



102
103
104
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 102

def checkbox_field(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundCheckboxField.new(content, options, html_options, &block).render
end

#date_picker_field(content = nil, options = nil, html_options = nil, &block) ⇒ Object



114
115
116
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 114

def date_picker_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Dates::DatePickerField.new(content, options, html_options, &block).render
end


67
68
69
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 67

def dropdown(content, options = nil, html_options = nil, &block)
  @items << SurroundDropdown.new(content, options, html_options).tap(&block).render
end


118
119
120
121
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 118

def dropdown_select_field(content = nil, options = nil, html_options = nil, &block)
  html_options = (html_options || {}).merge('data-wrapper-classes': 'input-group-btn')
  @items << UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new(content, options, html_options, &block).render
end

#glyph(content = nil, options = {}, html_options = nil, &block) ⇒ Object



78
79
80
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 78

def glyph(content = nil, options = {}, html_options = nil, &block)
  @items << SurroundAddon.new(UiBibz::Ui::Core::Icons::Glyph.new(content, options, html_options, &block).render).render
end

#input(attribute_name, options = {}, &block) ⇒ Object



71
72
73
74
75
76
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 71

def input(attribute_name, options = {}, &block)
  @items << @options[:form].input(attribute_name, options.merge({ label: false, wrapper: false, error: false }), &block)
  obj = @options[:form].object
  @errors << obj.errors[attribute_name] unless obj.errors[attribute_name].empty?
  @required_fields << (obj._validators[attribute_name].try(:first).class.to_s == 'ActiveRecord::Validations::PresenceValidator')
end

#pre_renderObject

Render html tag



63
64
65
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 63

def pre_render
   :div, @items.join.html_safe, html_options
end

#radio_field(content = nil, options = nil, html_options = nil, &block) ⇒ Object



106
107
108
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 106

def radio_field(content = nil, options = nil, html_options = nil, &block)
  @items << SurroundRadioField.new(content, options, html_options, &block).render
end

#select_field(content = nil, options = nil, html_options = nil, &block) ⇒ Object



123
124
125
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 123

def select_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Selects::SelectField.new(content, options, html_options, &block).render
end

#text_field(content = nil, options = nil, html_options = nil, &block) ⇒ Object



110
111
112
# File 'lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb', line 110

def text_field(content = nil, options = nil, html_options = nil, &block)
  @items << UiBibz::Ui::Core::Forms::Texts::TextField.new(content, options, html_options, &block).render
end