ui_bibz 2.0.0.alpha → 2.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTORS.md +23 -0
- data/Gemfile.lock +53 -43
- data/Rakefile +1 -0
- data/app/assets/javascripts/fix_bootstrap.coffee +7 -0
- data/app/assets/javascripts/form.coffee +65 -0
- data/app/assets/javascripts/interface.coffee +17 -0
- data/app/assets/javascripts/table.coffee +35 -0
- data/app/assets/javascripts/ui_bibz.coffee +24 -38
- data/app/assets/stylesheets/bootstrap-switch.sass +150 -0
- data/app/assets/stylesheets/fix-bootstrap-4.sass +33 -2
- data/app/assets/stylesheets/fix-dropdown-select.sass +239 -0
- data/app/assets/stylesheets/ui_bibz.sass +29 -18
- data/app/inputs/custom_inputs/autocomplete_input.rb +14 -0
- data/app/inputs/custom_inputs/date_picker_input.rb +2 -0
- data/app/inputs/custom_inputs/dropdown_select_input.rb +15 -0
- data/app/inputs/custom_inputs/multi_column_input.rb +51 -5
- data/app/inputs/custom_inputs/multi_select_input.rb +1 -1
- data/app/inputs/custom_inputs/surround_input.rb +3 -1
- data/app/inputs/custom_inputs/switch_input.rb +11 -0
- data/lib/ui_bibz/concerns/models/searchable.rb +6 -2
- data/lib/ui_bibz/helpers/ui_core_helper.rb +76 -54
- data/lib/ui_bibz/rails/engine.rb +9 -1
- data/lib/ui_bibz/ui/core/button/button_group.rb +1 -1
- data/lib/ui_bibz/ui/core/card/components/card_image.rb +1 -1
- data/lib/ui_bibz/ui/core/component.rb +1 -0
- data/lib/ui_bibz/ui/core/input/autocomplete_field.rb +87 -0
- data/lib/ui_bibz/ui/core/input/date_picker_field.rb +10 -2
- data/lib/ui_bibz/ui/core/input/dropdown_select_field.rb +124 -0
- data/lib/ui_bibz/ui/core/input/multi_select_field.rb +5 -0
- data/lib/ui_bibz/ui/core/input/surround_field.rb +11 -2
- data/lib/ui_bibz/ui/core/input/switch_field.rb +127 -0
- data/lib/ui_bibz/ui/ux/table/components/thead.rb +51 -0
- data/lib/ui_bibz/ui/ux/table/extensions/actionable.rb +1 -1
- data/lib/ui_bibz/ui/ux/table/extensions/sortable.rb +2 -2
- data/lib/ui_bibz/ui/ux/table/table.rb +47 -4
- data/lib/ui_bibz/ui/ux/table/table_card.rb +12 -4
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +24 -10
- data/test/ui/card_test.rb +1 -1
- data/test/ui/input_dropdown_select_field_test.rb +78 -0
- data/test/ui/input_switch_field_test.rb +86 -0
- data/test/ui/inputs_test.rb +12 -4
- data/test/ui/table_test.rb +16 -0
- data/ui_bibz.gemspec +14 -4
- data/vendor/assets/stylesheets/bootstrap-switch.min.css +1 -1
- metadata +132 -13
- data/app/assets/javascripts/multi_column.coffee +0 -45
- data/app/inputs/custom_inputs/date_picker_input_old.rb +0 -61
- data/vendor/assets/javascripts/bootstrap-4.0.0-alpha.min.js +0 -7
- data/vendor/assets/javascripts/bootstrap-select.min.js +0 -8
- data/vendor/assets/stylesheets/bootstrap-4.0.0-alpha.min.css +0 -6
- data/vendor/assets/stylesheets/bootstrap-select.min.css +0 -6
@@ -1,5 +1,32 @@
|
|
1
1
|
module UiBibz::Helpers::UiCoreHelper
|
2
2
|
|
3
|
+
# Button section begin ----------------------------------------------------
|
4
|
+
def button content = nil, options = nil, html_options = nil, &block
|
5
|
+
UiBibz::Ui::Core::Button.new(content, options, html_options, &block).render
|
6
|
+
end
|
7
|
+
|
8
|
+
def button_choice content = nil, options = nil, html_options = nil, &block
|
9
|
+
UiBibz::Ui::Core::ButtonChoice.new(content, options, html_options, &block).render
|
10
|
+
end
|
11
|
+
|
12
|
+
def button_dropdown name, options = nil, html_options = nil, &block
|
13
|
+
UiBibz::Ui::Core::ButtonDropdown.new(name, options, html_options).tap(&block).render
|
14
|
+
end
|
15
|
+
|
16
|
+
def button_group content = nil, options = nil, html_options = nil, &block
|
17
|
+
UiBibz::Ui::Core::ButtonGroup.new(content, options, html_options, &block).render
|
18
|
+
end
|
19
|
+
|
20
|
+
def button_link content = nil, options = nil, html_options = nil, &block
|
21
|
+
UiBibz::Ui::Core::ButtonLink.new(content, options, html_options, &block).render
|
22
|
+
end
|
23
|
+
|
24
|
+
def button_split_dropdown name, options = nil, html_options = nil, &block
|
25
|
+
UiBibz::Ui::Core::ButtonSplitDropdown.new(name, options, html_options).tap(&block).render
|
26
|
+
end
|
27
|
+
# Button section end ----------------------------------------------------
|
28
|
+
|
29
|
+
# Card section begin ----------------------------------------------------
|
3
30
|
def card content = nil, options = nil, html_options = nil, &block
|
4
31
|
if is_tap(content, options)
|
5
32
|
UiBibz::Ui::Core::Card.new(content, options, html_options).tap(&block).render
|
@@ -19,82 +46,67 @@ module UiBibz::Helpers::UiCoreHelper
|
|
19
46
|
def card_column content = nil, options = nil, html_options = nil, &block
|
20
47
|
UiBibz::Ui::Core::CardColumn.new(content, options, html_options).tap(&block).render
|
21
48
|
end
|
49
|
+
# Card section end ----------------------------------------------------
|
22
50
|
|
51
|
+
# Input section begin ----------------------------------------------------
|
23
52
|
def date_picker_field content = nil, options = nil, html_options = nil, &block
|
24
53
|
UiBibz::Ui::Core::DatePickerField.new(content, options, html_options, &block).render
|
25
54
|
end
|
26
55
|
|
27
|
-
def
|
28
|
-
UiBibz::Ui::Core::
|
29
|
-
end
|
30
|
-
|
31
|
-
# Use "notify" instead of "alert" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
32
|
-
def notify content = nil, options = nil, html_options = nil, &block
|
33
|
-
UiBibz::Ui::Core::Alert.new(content, options, html_options, &block).render
|
34
|
-
end
|
35
|
-
|
36
|
-
def stars content = nil, options = nil, html_options = nil, &block
|
37
|
-
UiBibz::Ui::Core::Stars.new(content, options, html_options, &block).render
|
38
|
-
end
|
39
|
-
|
40
|
-
# Use "etiquette" instead of "label" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
41
|
-
def etiquette content = nil, options = nil, html_options = nil, &block
|
42
|
-
UiBibz::Ui::Core::Label.new(content, options, html_options, &block).render
|
43
|
-
end
|
44
|
-
|
45
|
-
def jumbotron content = nil, options = nil, html_options = nil, &block
|
46
|
-
UiBibz::Ui::Core::Jumbotron.new(content, options, html_options, &block).render
|
56
|
+
def multi_column_field content = nil, options = nil, html_options = nil, &block
|
57
|
+
UiBibz::Ui::Core::MultiColumnField.new(content, options, html_options, &block).render
|
47
58
|
end
|
48
59
|
|
49
|
-
def
|
50
|
-
UiBibz::Ui::Core::
|
60
|
+
def multi_select_field content = nil, options = nil, html_options = nil, &block
|
61
|
+
UiBibz::Ui::Core::MultiSelectField.new(content, options, html_options, &block).render
|
51
62
|
end
|
52
63
|
|
53
64
|
def surround_field content = nil, options = nil, html_options = nil, &block
|
54
65
|
UiBibz::Ui::Core::SurroundField.new(content, options, html_options, &block).render
|
55
66
|
end
|
56
67
|
|
57
|
-
def
|
58
|
-
UiBibz::Ui::Core::
|
59
|
-
end
|
60
|
-
|
61
|
-
def multi_select_field content = nil, options = nil, html_options = nil, &block
|
62
|
-
UiBibz::Ui::Core::MultiSelectField.new(content, options, html_options, &block).render
|
68
|
+
def switch_field content = nil, options = nil, html_options = nil, &block
|
69
|
+
UiBibz::Ui::Core::SwitchField.new(content, options, html_options, &block).render
|
63
70
|
end
|
64
71
|
|
65
|
-
def
|
66
|
-
UiBibz::Ui::Core::
|
72
|
+
def dropdown_select_field content = nil, options = nil, html_options = nil, &block
|
73
|
+
UiBibz::Ui::Core::DropdownSelectField.new(content, options, html_options, &block).render
|
67
74
|
end
|
68
75
|
|
69
|
-
def
|
70
|
-
UiBibz::Ui::Core::
|
76
|
+
def autocomplete_field content = nil, options = nil, html_options = nil, &block
|
77
|
+
UiBibz::Ui::Core::AutocompleteField.new(content, options, html_options, &block).render
|
71
78
|
end
|
79
|
+
# Input section end ----------------------------------------------------
|
72
80
|
|
73
|
-
#
|
74
|
-
def
|
75
|
-
UiBibz::Ui::Core::
|
81
|
+
# Nav section begin ----------------------------------------------------
|
82
|
+
def nav content = nil, options = nil, html_options = nil, &block
|
83
|
+
UiBibz::Ui::Core::Nav.new(content, options, html_options).tap(&block).render
|
76
84
|
end
|
77
85
|
|
78
|
-
def
|
79
|
-
UiBibz::Ui::Core::
|
86
|
+
def navbar content = nil, options = nil, html_options = nil, &block
|
87
|
+
UiBibz::Ui::Core::Navbar.new(content, options, html_options).tap(&block).render
|
80
88
|
end
|
89
|
+
# Nav section end ----------------------------------------------------
|
81
90
|
|
82
|
-
|
83
|
-
|
91
|
+
# Layout section begin ----------------------------------------------------
|
92
|
+
def row content = nil, options = nil, html_options = nil, &block
|
93
|
+
UiBibz::Ui::Core::Row.new(content, options, html_options, &block).render
|
84
94
|
end
|
85
95
|
|
86
|
-
def
|
87
|
-
UiBibz::Ui::Core::
|
96
|
+
def col content = nil, options = nil, html_options = nil, &block
|
97
|
+
UiBibz::Ui::Core::Col.new(content, options, html_options, &block).render
|
88
98
|
end
|
89
99
|
|
90
|
-
def
|
91
|
-
UiBibz::Ui::Core::
|
100
|
+
def container content = nil, options = nil, html_options = nil, &block
|
101
|
+
UiBibz::Ui::Core::Container.new(content, options, html_options, &block).render
|
92
102
|
end
|
103
|
+
# Layout section end ----------------------------------------------------
|
93
104
|
|
94
|
-
|
95
|
-
|
105
|
+
# Other section begin ----------------------------------------------------
|
106
|
+
# Use "notify" instead of "alert" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
107
|
+
def notify content = nil, options = nil, html_options = nil, &block
|
108
|
+
UiBibz::Ui::Core::Alert.new(content, options, html_options, &block).render
|
96
109
|
end
|
97
|
-
# Button section end ----------------------------------------------------
|
98
110
|
|
99
111
|
def breadcrumb content = nil, options = nil, html_options = nil, &block
|
100
112
|
if is_tap(content, options)
|
@@ -112,21 +124,31 @@ module UiBibz::Helpers::UiCoreHelper
|
|
112
124
|
UiBibz::Ui::Core::Glyph.new(content, options, html_options, &block).render
|
113
125
|
end
|
114
126
|
|
115
|
-
def
|
116
|
-
UiBibz::Ui::Core::
|
127
|
+
def jumbotron content = nil, options = nil, html_options = nil, &block
|
128
|
+
UiBibz::Ui::Core::Jumbotron.new(content, options, html_options, &block).render
|
117
129
|
end
|
118
130
|
|
119
|
-
|
120
|
-
|
131
|
+
# Use "etiquette" instead of "label" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
132
|
+
def etiquette content = nil, options = nil, html_options = nil, &block
|
133
|
+
UiBibz::Ui::Core::Label.new(content, options, html_options, &block).render
|
121
134
|
end
|
122
135
|
|
123
|
-
def
|
124
|
-
UiBibz::Ui::Core::
|
136
|
+
def list_group content = nil, options = nil, html_options = nil, &block
|
137
|
+
UiBibz::Ui::Core::ListGroup.new(content, options, html_options).tap(&block).render
|
125
138
|
end
|
126
139
|
|
127
|
-
def
|
128
|
-
UiBibz::Ui::Core::
|
140
|
+
def modal content = nil, options = nil, html_options = nil, &block
|
141
|
+
UiBibz::Ui::Core::Modal.new(content, options, html_options).tap(&block).render
|
142
|
+
end
|
143
|
+
|
144
|
+
def progress percentage = nil, options = nil, html_options = nil, &block
|
145
|
+
UiBibz::Ui::Core::Progress.new(percentage, options, html_options, &block).render
|
146
|
+
end
|
147
|
+
|
148
|
+
def stars content = nil, options = nil, html_options = nil, &block
|
149
|
+
UiBibz::Ui::Core::Stars.new(content, options, html_options, &block).render
|
129
150
|
end
|
151
|
+
# Other section end ----------------------------------------------------
|
130
152
|
|
131
153
|
private
|
132
154
|
|
data/lib/ui_bibz/rails/engine.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
# to load pagination in rails app
|
2
2
|
require 'will_paginate'
|
3
3
|
require 'bootstrap'
|
4
|
-
require 'rails-assets-tether'
|
5
4
|
require "font-awesome-sass"
|
6
5
|
|
6
|
+
# Javascript requires
|
7
|
+
require 'rails-assets-tether'
|
8
|
+
require 'rails-assets-bootstrap-select'
|
9
|
+
require 'rails-assets-bootstrap-datepicker'
|
10
|
+
#
|
11
|
+
# not compatible with boostrap 4
|
12
|
+
#require 'rails-assets-bootstrap-switch'
|
13
|
+
#require 'rails-assets-bootstrap-multiselect'
|
14
|
+
|
7
15
|
module UiBibz
|
8
16
|
module Rails
|
9
17
|
class Engine < ::Rails::Engine
|
@@ -129,6 +129,7 @@ module UiBibz::Ui::Core
|
|
129
129
|
# Add html data arguments
|
130
130
|
def add_html_data name, value = true
|
131
131
|
html_options[:data] = {} if html_options[:data].nil?
|
132
|
+
value = value.kind_of?(String) ? value.strip : value
|
132
133
|
html_options[:data].update(Hash[name, value])
|
133
134
|
end
|
134
135
|
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create a AutocompleteField
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
#
|
7
|
+
# ==== Attributes
|
8
|
+
#
|
9
|
+
# * +content+ - Content of element
|
10
|
+
# * +options+ - Options of element
|
11
|
+
# * +html_options+ - Html Options of element
|
12
|
+
#
|
13
|
+
# ==== Options
|
14
|
+
#
|
15
|
+
# You can add HTML attributes using the +html_options+.
|
16
|
+
# You can pass arguments in options attribute:
|
17
|
+
# * option_tags - Array, Object [required]
|
18
|
+
#
|
19
|
+
# ==== Signatures
|
20
|
+
#
|
21
|
+
# UiBibz::Ui::Core::AutocompleteField.new(content, options = {}, html_options = {}).render
|
22
|
+
#
|
23
|
+
# UiBibz::Ui::Core::AutocompleteField.new(options = {}, html_options = {}) do
|
24
|
+
# content
|
25
|
+
# end.render
|
26
|
+
#
|
27
|
+
# ==== Examples
|
28
|
+
#
|
29
|
+
# options = options_for_select(2.times.map{ |i| "option #{i}" })
|
30
|
+
# UiBibz::Ui::Core::AutocompleteField.new('company', { option_tags: options }, { class: 'test' })
|
31
|
+
#
|
32
|
+
# options = options_for_select(2.times.map{ |i| "option #{i}" })
|
33
|
+
# UiBibz::Ui::Core::AutocompleteField.new(option_tags: options) do
|
34
|
+
# #content
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# ==== Helper
|
38
|
+
#
|
39
|
+
# autocomplete_field(options = {}, html_options = {}) do
|
40
|
+
# # content
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
class AutocompleteField < Component
|
44
|
+
|
45
|
+
# See UiBibz::Ui::Core::Component.initialize
|
46
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
# Render html tag
|
51
|
+
def render
|
52
|
+
text_field_input_tag + data_list_render
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def data_list_render
|
58
|
+
content_tag :datalist, options[:option_tags], id: data_list_name
|
59
|
+
end
|
60
|
+
|
61
|
+
def text_field_input_tag
|
62
|
+
if options[:builder].nil?
|
63
|
+
text_field_tag content, html_options[:value], html_options
|
64
|
+
else
|
65
|
+
options[:builder].text_field content, html_options
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def component_html_options
|
70
|
+
{ autocomplete: true, list: data_list_name }
|
71
|
+
end
|
72
|
+
|
73
|
+
def component_html_classes
|
74
|
+
'form-control'
|
75
|
+
end
|
76
|
+
|
77
|
+
def data_list_name
|
78
|
+
@datalist ||= "#{ html_options[:id] || content }-datalist"
|
79
|
+
end
|
80
|
+
|
81
|
+
# :lg, :sm or :xs
|
82
|
+
def size
|
83
|
+
"input-group-#{ options[:size] }" if options[:size]
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -53,9 +53,9 @@ module UiBibz::Ui::Core
|
|
53
53
|
if options[:range]
|
54
54
|
content_tag :div, class: join_classes('input-group', 'input-daterange', size) do
|
55
55
|
concat content_tag :span, options[:append], class: 'input-group-addon' unless @options[:append].nil?
|
56
|
-
concat
|
56
|
+
concat text_field_input_tag content[0]
|
57
57
|
concat content_tag :span, options[:range], class: 'input-group-addon input-group-range'
|
58
|
-
concat
|
58
|
+
concat text_field_input_tag content[1]
|
59
59
|
concat content_tag :span, options[:prepend], class: 'input-group-addon' unless @options[:prepend].nil?
|
60
60
|
end
|
61
61
|
else
|
@@ -65,6 +65,14 @@ module UiBibz::Ui::Core
|
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
|
+
def text_field_input_tag name
|
69
|
+
if options[:builder].nil?
|
70
|
+
text_field_tag name, html_options[:value], html_options
|
71
|
+
else
|
72
|
+
options[:builder].text_field name, html_options
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
68
76
|
def component_html_data
|
69
77
|
date_locale
|
70
78
|
provide
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create a DropdownSelectField
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
# source : http://silviomoreto.github.io/bootstrap-select/examples/
|
7
|
+
#
|
8
|
+
# ==== Attributes
|
9
|
+
#
|
10
|
+
# * +content+ - Content of element
|
11
|
+
# * +options+ - Options of element
|
12
|
+
# * +html_options+ - Html Options of element
|
13
|
+
#
|
14
|
+
# ==== Options
|
15
|
+
#
|
16
|
+
# You can add HTML attributes using the +html_options+.
|
17
|
+
# You can pass arguments in options attribute:
|
18
|
+
# * +state+ - State of élement with symbol value:
|
19
|
+
# (+:primary+, +:secondary+, +:info+, +:warning+, +:danger+, +:link+)
|
20
|
+
# * option_tags - Array, Object [required]
|
21
|
+
# * searchable - Boolean
|
22
|
+
# * max_options - Integer
|
23
|
+
# * selected_text_format - String
|
24
|
+
# * menu_size - Integer
|
25
|
+
# * header - String
|
26
|
+
# * actions_box - Boolean
|
27
|
+
# * show_tick - Boolean
|
28
|
+
# * show_menu_arrow - Boolean
|
29
|
+
# * dropup - Boolean
|
30
|
+
#
|
31
|
+
# ==== Signatures
|
32
|
+
#
|
33
|
+
# UiBibz::Ui::Core::DropdownSelectField.new(content, options = {}, html_options = {}).render
|
34
|
+
#
|
35
|
+
# UiBibz::Ui::Core::DropdownSelectField.new(options = {}, html_options = {}) do
|
36
|
+
# content
|
37
|
+
# end.render
|
38
|
+
#
|
39
|
+
# ==== Examples
|
40
|
+
#
|
41
|
+
# UiBibz::Ui::Core::DropdownSelectField.new('fruits', { option_tags: list_of_fruits, searchable: true }, { class: 'test' })
|
42
|
+
#
|
43
|
+
# UiBibz::Ui::Core::DropdownSelectField.new({ option_tags: list_of_fruits, actions_box: true }, { class: 'test' }) do
|
44
|
+
# 'fruits'
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# ==== Helper
|
48
|
+
#
|
49
|
+
# dropdown_select_field(content, options = {}, html_options = {})
|
50
|
+
#
|
51
|
+
class DropdownSelectField < UiBibz::Ui::Core::Component
|
52
|
+
|
53
|
+
# See UiBibz::Ui::Core::Component.initialize
|
54
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
55
|
+
super
|
56
|
+
end
|
57
|
+
|
58
|
+
# Render html tag
|
59
|
+
def render
|
60
|
+
select_tag content, options[:option_tags], html_options
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def component_html_classes
|
66
|
+
['selectpicker', show_tick, show_menu_arrow, dropup]
|
67
|
+
end
|
68
|
+
|
69
|
+
def component_html_data
|
70
|
+
searchable
|
71
|
+
max_options
|
72
|
+
selected_text_format
|
73
|
+
menu_size
|
74
|
+
style
|
75
|
+
header
|
76
|
+
actions_box
|
77
|
+
end
|
78
|
+
|
79
|
+
############################ Data html options
|
80
|
+
|
81
|
+
def max_options
|
82
|
+
add_html_data('max_options', options[:max_options]) if options[:max_options]
|
83
|
+
end
|
84
|
+
|
85
|
+
def selected_text_format
|
86
|
+
add_html_data('selected_text_format', options[:selected_text_format]) if options[:selected_text_format]
|
87
|
+
end
|
88
|
+
|
89
|
+
def searchable
|
90
|
+
add_html_data('live_search') if options[:searchable]
|
91
|
+
end
|
92
|
+
|
93
|
+
def style
|
94
|
+
add_html_data('style', "btn-#{ options[:state]}") if options[:style]
|
95
|
+
end
|
96
|
+
|
97
|
+
def menu_size
|
98
|
+
add_html_data('size', options[:menu_size]) if options[:menu_size]
|
99
|
+
end
|
100
|
+
|
101
|
+
def actions_box
|
102
|
+
add_html_data('actions_box') if options[:actions_box]
|
103
|
+
end
|
104
|
+
|
105
|
+
def header
|
106
|
+
add_html_data('header', options[:header]) if options[:header]
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
############################# Css classes
|
111
|
+
|
112
|
+
def show_tick
|
113
|
+
'show-tick' if options[:show_tick]
|
114
|
+
end
|
115
|
+
|
116
|
+
def show_menu_arrow
|
117
|
+
'show-menu-arrow' if options[:show_menu_arrow]
|
118
|
+
end
|
119
|
+
|
120
|
+
def dropup
|
121
|
+
'dropup' if options[:dropup]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -3,6 +3,7 @@ module UiBibz::Ui::Core
|
|
3
3
|
# Create a MultiSelectField
|
4
4
|
#
|
5
5
|
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
# source : http://loudev.com/
|
6
7
|
#
|
7
8
|
# ==== Attributes
|
8
9
|
#
|
@@ -85,5 +86,9 @@ module UiBibz::Ui::Core
|
|
85
86
|
add_html_data('include_select_all_option') if options[:select_all_option]
|
86
87
|
end
|
87
88
|
|
89
|
+
def state
|
90
|
+
options[:state] || 'btn-secondary'
|
91
|
+
end
|
92
|
+
|
88
93
|
end
|
89
94
|
end
|
@@ -49,11 +49,11 @@ module UiBibz::Ui::Core
|
|
49
49
|
# Render html tag
|
50
50
|
def render
|
51
51
|
if options[:append].nil? && options[:prepend].nil?
|
52
|
-
|
52
|
+
text_field_input_tag
|
53
53
|
else
|
54
54
|
content_tag :div, class: join_classes('input-group', size) do
|
55
55
|
concat content_tag :span, options[:append], class: 'input-group-addon' unless options[:append].nil?
|
56
|
-
concat
|
56
|
+
concat text_field_input_tag
|
57
57
|
concat content_tag :span, options[:prepend], class: 'input-group-addon' unless options[:prepend].nil?
|
58
58
|
end
|
59
59
|
end
|
@@ -61,6 +61,15 @@ module UiBibz::Ui::Core
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
+
# Simple_form or not
|
65
|
+
def text_field_input_tag
|
66
|
+
if options[:builder].nil?
|
67
|
+
text_field_tag content, html_options[:value], html_options
|
68
|
+
else
|
69
|
+
options[:builder].text_field content, html_options
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
64
73
|
def component_html_classes
|
65
74
|
'form-control'
|
66
75
|
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create a SurroundField
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
# Source : http://www.bootstrap-switch.org/documentation-2.html
|
7
|
+
# ==== Attributes
|
8
|
+
#
|
9
|
+
# * +content+ - Content of element
|
10
|
+
# * +options+ - Options of element
|
11
|
+
# * +html_options+ - Html Options of element
|
12
|
+
#
|
13
|
+
# ==== Options
|
14
|
+
#
|
15
|
+
# You can add HTML attributes using the +html_options+.
|
16
|
+
# You can pass arguments in options attribute:
|
17
|
+
# * +status+ - String
|
18
|
+
# * +animate+ - Boolean
|
19
|
+
# * +on_color+ - String
|
20
|
+
# * +off_color+ - String
|
21
|
+
# * +on_text+ - String
|
22
|
+
# * +off_text+ - String
|
23
|
+
# * +label_text+ - String
|
24
|
+
# * +readonly+ - Boolean
|
25
|
+
# * +checked+ - Boolean
|
26
|
+
#
|
27
|
+
# ==== Signatures
|
28
|
+
#
|
29
|
+
# UiBibz::Ui::Core::SwitchField.new(content, options = {}, html_options = {}).render
|
30
|
+
#
|
31
|
+
# UiBibz::Ui::Core::SwitchField.new(options = {}, html_options = {}) do
|
32
|
+
# content
|
33
|
+
# end.render
|
34
|
+
#
|
35
|
+
# ==== Examples
|
36
|
+
#
|
37
|
+
# switch_field 'name', { on_color: :primary }, { readonly: true }
|
38
|
+
#
|
39
|
+
# ==== Helper
|
40
|
+
#
|
41
|
+
# switch_field(options = {}, html_options = {}) do
|
42
|
+
# # content
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
class SwitchField < Component
|
46
|
+
|
47
|
+
# See UiBibz::Ui::Core::Component.initialize
|
48
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
# Render html tag
|
53
|
+
def render
|
54
|
+
if options[:builder].nil?
|
55
|
+
check_box_tag content, value, html_options[:checked], html_options
|
56
|
+
else
|
57
|
+
options[:builder].check_box(content, html_options, true, false)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def value
|
64
|
+
options[:value]
|
65
|
+
end
|
66
|
+
|
67
|
+
def component_html_classes
|
68
|
+
"switch"
|
69
|
+
end
|
70
|
+
|
71
|
+
def component_html_data
|
72
|
+
size
|
73
|
+
status
|
74
|
+
animate
|
75
|
+
left_color
|
76
|
+
right_color
|
77
|
+
left_text
|
78
|
+
right_text
|
79
|
+
middle_text
|
80
|
+
end
|
81
|
+
|
82
|
+
# '', 'mini', 'small', 'normal', 'large'
|
83
|
+
def size
|
84
|
+
add_html_data('size', matching_size[options[:size]]) unless options[:size].nil?
|
85
|
+
end
|
86
|
+
|
87
|
+
def matching_size
|
88
|
+
{ xs: 'small', md: 'normal', lg: 'large' }
|
89
|
+
end
|
90
|
+
|
91
|
+
# true, false => default : true
|
92
|
+
def animate
|
93
|
+
add_html_data('animate', options.delete(:animate)) unless options[:animate].nil?
|
94
|
+
end
|
95
|
+
|
96
|
+
# active, disabled => default : active
|
97
|
+
def status
|
98
|
+
html_options[:disabled] = true if options[:status] == 'disabled'
|
99
|
+
end
|
100
|
+
|
101
|
+
# 'primary', 'info', 'success', 'warning', 'danger', 'default' => default : default
|
102
|
+
def left_color
|
103
|
+
add_html_data('on_color', options[:left_color]) unless options[:left_color].nil?
|
104
|
+
end
|
105
|
+
|
106
|
+
# 'primary', 'info', 'success', 'warning', 'danger', 'default' => default : default
|
107
|
+
def right_color
|
108
|
+
add_html_data('off_color', options[:right_color]) unless options[:right_color].nil?
|
109
|
+
end
|
110
|
+
|
111
|
+
# String => default : "ON"
|
112
|
+
def left_text
|
113
|
+
add_html_data('on_text', options[:left_text]) unless options[:left_text].nil?
|
114
|
+
end
|
115
|
+
|
116
|
+
# String => default : "OFF"
|
117
|
+
def right_text
|
118
|
+
add_html_data('off_text', options[:right_text]) unless options[:right_text].nil?
|
119
|
+
end
|
120
|
+
|
121
|
+
# String => default : ' '
|
122
|
+
def middle_text
|
123
|
+
add_html_data('label_text', options[:middle_text]) unless options[:middle_text].nil?
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|