ui_bibz 2.0.0.alpha → 2.0.0.alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,51 @@
|
|
1
|
+
module UiBibz::Ui::Ux
|
2
|
+
|
3
|
+
# Create a Thead
|
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
|
+
# * +state+ - State of élement with symbol value:
|
18
|
+
# (+:inverse+, +:default+)
|
19
|
+
#
|
20
|
+
# ==== Signatures
|
21
|
+
#
|
22
|
+
# UiBibz::Ui::Ux::Thead.new(content, options = nil, html_options = nil)
|
23
|
+
#
|
24
|
+
# UiBibz::Ui::Ux::Thead.new(options = nil, html_options = nil) do
|
25
|
+
# content
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# ==== Examples
|
29
|
+
#
|
30
|
+
# UiBibz::Ui::Ux::Thead.new(content, { state: :inverse }).render
|
31
|
+
#
|
32
|
+
class Thead < UiBibz::Ui::Core::Component
|
33
|
+
|
34
|
+
# See UiBibz::Ui::Core::Component.initialize
|
35
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
# Render html tag
|
40
|
+
def render
|
41
|
+
content_tag :thead, content, html_options
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def state
|
47
|
+
"thead-#{ @options[:state] }" unless @options[:state].nil?
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -31,7 +31,7 @@ module UiBibz::Ui::Ux
|
|
31
31
|
unless @actions.nil?
|
32
32
|
@actions.format_action.call(record) unless @actions.format_action.nil?
|
33
33
|
unless (default_actions? != true && @actions.raw_list.empty?)
|
34
|
-
UiBibz::Ui::Core::
|
34
|
+
UiBibz::Ui::Core::ButtonDropdown.new(dropdown_action_name, { position: :right, size: :xs, glyph: actions_glyph }, { class: 'dropdown-action' }).tap do |d|
|
35
35
|
actions_links(record).each do |l|
|
36
36
|
d.html l.to_s.html_safe
|
37
37
|
end
|
@@ -71,11 +71,11 @@ module UiBibz::Ui::Ux
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def name_with_caret
|
74
|
-
sort_name == sort_column && @column.id.to_s == @store.column_id.to_s ? @name + caret : @name
|
74
|
+
sort_name.to_s == sort_column.to_s && @column.id.to_s == @store.column_id.to_s ? @name + caret : @name
|
75
75
|
end
|
76
76
|
|
77
77
|
def caret
|
78
|
-
|
78
|
+
UiBibz::Ui::Core::Glyph.new("caret-#{ direction == 'desc' ? 'up' : 'down' }").render
|
79
79
|
end
|
80
80
|
|
81
81
|
def cls
|
@@ -2,6 +2,7 @@ require "ui_bibz/ui/ux/table/components/store"
|
|
2
2
|
require "ui_bibz/ui/ux/table/components/columns"
|
3
3
|
require "ui_bibz/ui/ux/table/components/column"
|
4
4
|
require "ui_bibz/ui/ux/table/components/actions"
|
5
|
+
require "ui_bibz/ui/ux/table/components/thead"
|
5
6
|
require "ui_bibz/ui/ux/table/extensions/paginable"
|
6
7
|
require "ui_bibz/ui/ux/table/extensions/paginable"
|
7
8
|
require "ui_bibz/ui/ux/table/extensions/searchable"
|
@@ -30,6 +31,18 @@ module UiBibz::Ui::Ux
|
|
30
31
|
# * +sortable+ - Boolean
|
31
32
|
# * +searchable+ - Boolean
|
32
33
|
# * +default_actions+ - Boolean
|
34
|
+
# * +state+
|
35
|
+
# (+:inverse+, +:default+, +:success+, +:primary+, +:secondary+, +:info+,
|
36
|
+
# +:danger+, +:warning+)
|
37
|
+
# * +thead+ - Hash
|
38
|
+
# (+state+)
|
39
|
+
# (+:inverse+, +:default+)
|
40
|
+
# * +bordered+ - Boolean
|
41
|
+
# * +hoverable+ - Boolean
|
42
|
+
# * +size+
|
43
|
+
# (+:sm+)
|
44
|
+
# * +responsive+ - Boolean
|
45
|
+
# * +reflow+ - Boolean
|
33
46
|
#
|
34
47
|
# ==== Signatures
|
35
48
|
#
|
@@ -148,16 +161,18 @@ module UiBibz::Ui::Ux
|
|
148
161
|
end
|
149
162
|
|
150
163
|
ths = action.header ths
|
151
|
-
concat content_tag(:tr, ths.join.html_safe)
|
164
|
+
concat Thead.new(content_tag(:tr, ths.join.html_safe), @options[:thead]).render
|
152
165
|
|
153
|
-
store.records.
|
166
|
+
trs = store.records.collect do |record|
|
154
167
|
tds = cols.collect do |col|
|
155
168
|
content_tag(:td, td_content(record, col)) unless col.hidden?
|
156
169
|
end
|
157
170
|
|
158
171
|
tds = action.body record, tds
|
159
|
-
|
172
|
+
content_tag(:tr, tds.join.html_safe)
|
160
173
|
end
|
174
|
+
|
175
|
+
concat content_tag :tbody, trs.join.html_safe
|
161
176
|
end
|
162
177
|
end
|
163
178
|
|
@@ -175,7 +190,35 @@ module UiBibz::Ui::Ux
|
|
175
190
|
private
|
176
191
|
|
177
192
|
def component_html_classes
|
178
|
-
["table",
|
193
|
+
["table", striped, bordered, hoverable, size, responsive, reflow]
|
194
|
+
end
|
195
|
+
|
196
|
+
def state
|
197
|
+
"table-#{ @options[:state] }" unless @options[:state].nil?
|
198
|
+
end
|
199
|
+
|
200
|
+
def striped
|
201
|
+
"table-striped" unless @options[:striped].nil?
|
202
|
+
end
|
203
|
+
|
204
|
+
def bordered
|
205
|
+
"table-bordered" unless @options[:bordered].nil?
|
206
|
+
end
|
207
|
+
|
208
|
+
def hoverable
|
209
|
+
"table-hoverable" unless @options[:hoverable].nil?
|
210
|
+
end
|
211
|
+
|
212
|
+
def size
|
213
|
+
"table-#{ @options[:size] }" unless @options[:size].nil?
|
214
|
+
end
|
215
|
+
|
216
|
+
def responsive
|
217
|
+
"table-responsive" unless @options[:responsive].nil?
|
218
|
+
end
|
219
|
+
|
220
|
+
def reflow
|
221
|
+
"table-reflow" unless @options[:reflow].nil?
|
179
222
|
end
|
180
223
|
|
181
224
|
end
|
@@ -22,6 +22,18 @@ module UiBibz::Ui::Ux
|
|
22
22
|
# * +actionable+ - Boolean
|
23
23
|
# * +sortable+ - Boolean
|
24
24
|
# * +searchable+ - Boolean
|
25
|
+
# * +state+
|
26
|
+
# (+:inverse+)
|
27
|
+
# * +thead+ - Hash
|
28
|
+
# (+state+)
|
29
|
+
# (+inverse+, +default+)
|
30
|
+
# * +bordered+ - Boolean
|
31
|
+
# * +hoverable+ - Boolean
|
32
|
+
# * +size+
|
33
|
+
# (+sm+)
|
34
|
+
# * +responsive+ - Boolean
|
35
|
+
# * +reflow+ - Boolean
|
36
|
+
#
|
25
37
|
#
|
26
38
|
# ==== Signatures
|
27
39
|
#
|
@@ -170,10 +182,6 @@ module UiBibz::Ui::Ux
|
|
170
182
|
content_tag :div, @table.render, class: 'card-table'
|
171
183
|
end
|
172
184
|
|
173
|
-
def panel_classes
|
174
|
-
%w(panel panel-default table-panel)
|
175
|
-
end
|
176
|
-
|
177
185
|
def search
|
178
186
|
@search ||= Searchable.new store, @options.merge({ wrap_form: false }), { class: 'card-header' }
|
179
187
|
end
|
data/lib/ui_bibz/version.rb
CHANGED
data/lib/ui_bibz.rb
CHANGED
@@ -12,36 +12,50 @@ module UiBibz
|
|
12
12
|
|
13
13
|
# Core
|
14
14
|
module Core
|
15
|
-
|
16
|
-
autoload :Breadcrumb, "ui_bibz/ui/core/breadcrumb/breadcrumb"
|
15
|
+
# Button section
|
17
16
|
autoload :Button, "ui_bibz/ui/core/button/button"
|
18
17
|
autoload :ButtonChoice, "ui_bibz/ui/core/button/button_choice"
|
19
18
|
autoload :ButtonDropdown, "ui_bibz/ui/core/button/button_dropdown"
|
20
19
|
autoload :ButtonGroup, "ui_bibz/ui/core/button/button_group"
|
21
20
|
autoload :ButtonLink, "ui_bibz/ui/core/button/button_link"
|
22
21
|
autoload :ButtonSplitDropdown, "ui_bibz/ui/core/button/button_split_dropdown"
|
22
|
+
|
23
|
+
# Card section
|
23
24
|
autoload :Card, "ui_bibz/ui/core/card/card"
|
24
25
|
autoload :CardColumn, "ui_bibz/ui/core/card/card_column"
|
25
26
|
autoload :CardDeck, "ui_bibz/ui/core/card/card_deck"
|
26
27
|
autoload :CardGroup, "ui_bibz/ui/core/card/card_group"
|
28
|
+
|
29
|
+
# Input section
|
30
|
+
autoload :AutocompleteField, "ui_bibz/ui/core/input/autocomplete_field"
|
31
|
+
autoload :DatePickerField, "ui_bibz/ui/core/input/date_picker_field"
|
32
|
+
autoload :DropdownSelectField, "ui_bibz/ui/core/input/dropdown_select_field"
|
33
|
+
autoload :MultiColumnField, "ui_bibz/ui/core/input/multi_column_field"
|
34
|
+
autoload :MultiSelectField, "ui_bibz/ui/core/input/multi_select_field"
|
35
|
+
autoload :SurroundField, "ui_bibz/ui/core/input/surround_field"
|
36
|
+
autoload :SwitchField, "ui_bibz/ui/core/input/switch_field"
|
37
|
+
|
38
|
+
# Layout section
|
39
|
+
autoload :Row, "ui_bibz/ui/core/layout/row"
|
27
40
|
autoload :Col, "ui_bibz/ui/core/layout/col"
|
28
|
-
autoload :Component, "ui_bibz/ui/core/component"
|
29
41
|
autoload :Container, "ui_bibz/ui/core/layout/container"
|
30
|
-
|
42
|
+
|
43
|
+
# Nav section
|
44
|
+
autoload :Nav, "ui_bibz/ui/core/nav/nav"
|
45
|
+
autoload :Navbar, "ui_bibz/ui/core/nav/navbar"
|
46
|
+
|
47
|
+
# Other section
|
48
|
+
autoload :Alert, "ui_bibz/ui/core/alert"
|
49
|
+
autoload :Breadcrumb, "ui_bibz/ui/core/breadcrumb/breadcrumb"
|
50
|
+
autoload :Component, "ui_bibz/ui/core/component"
|
31
51
|
autoload :Dropdown, "ui_bibz/ui/core/dropdown/dropdown"
|
32
52
|
autoload :Glyph, "ui_bibz/ui/core/glyph"
|
33
53
|
autoload :Jumbotron, "ui_bibz/ui/core/jumbotron"
|
34
54
|
autoload :Label, "ui_bibz/ui/core/label"
|
35
55
|
autoload :ListGroup, "ui_bibz/ui/core/list/list_group"
|
36
56
|
autoload :Modal, "ui_bibz/ui/core/modal/modal"
|
37
|
-
autoload :MultiSelectField, "ui_bibz/ui/core/input/multi_select_field"
|
38
|
-
autoload :MultiColumnField, "ui_bibz/ui/core/input/multi_column_field"
|
39
|
-
autoload :Nav, "ui_bibz/ui/core/nav/nav"
|
40
|
-
autoload :Navbar, "ui_bibz/ui/core/nav/navbar"
|
41
57
|
autoload :Progress, "ui_bibz/ui/core/progress"
|
42
|
-
autoload :Row, "ui_bibz/ui/core/layout/row"
|
43
58
|
autoload :Stars, "ui_bibz/ui/core/stars"
|
44
|
-
autoload :SurroundField, "ui_bibz/ui/core/input/surround_field"
|
45
59
|
autoload :Tab, "ui_bibz/ui/core/nav/tab"
|
46
60
|
end
|
47
61
|
|
data/test/ui/card_test.rb
CHANGED
@@ -28,7 +28,7 @@ class CardTest < ActionView::TestCase
|
|
28
28
|
link_to "Card link", '#', class: "card-link"
|
29
29
|
end
|
30
30
|
end
|
31
|
-
expected = "<div class=\"card\"><img src=\"/
|
31
|
+
expected = "<div class=\"card\"><img src=\"/assets/image.svg\" alt=\"Image\" /><div class=\"card-block\">test</div><ul class=\"list-group-flush list-group\"><li class=\"list-group-item\">Cras justo odio</li><li class=\"list-group-item\">Dapibas ac facilisis in</li><li class=\"list-group-item\">vestibulum at eros</li></ul><div class=\"card-block\"><a class=\"card-link\" href=\"#\">Card link</a></div></div>"
|
32
32
|
|
33
33
|
assert_equal expected, actual
|
34
34
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
include UiBibz::Helpers
|
4
|
+
class InputDropdownSelectFieldTest < ActionView::TestCase
|
5
|
+
|
6
|
+
test 'dropdowm_select_field' do
|
7
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
8
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', options_tags: options).render
|
9
|
+
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker\"></select>"
|
10
|
+
|
11
|
+
assert_equal expected, actual
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'dropdowm_select_field searchable' do
|
15
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
16
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, searchable: true }).render
|
17
|
+
expected = "<select name=\"test\" id=\"test\" data-live-search=\"true\" class=\"selectpicker\"></select>"
|
18
|
+
|
19
|
+
assert_equal expected, actual
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'dropdowm_select_field max_options' do
|
23
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
24
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, max_options: 2 }).render
|
25
|
+
expected = "<select name=\"test\" id=\"test\" data-max-options=\"2\" class=\"selectpicker\"></select>"
|
26
|
+
|
27
|
+
assert_equal expected, actual
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'dropdowm_select_field selected_text_format' do
|
31
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
32
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, selected_text_format: "count > x" }).render
|
33
|
+
expected = "<select name=\"test\" id=\"test\" data-selected-text-format=\"count > x\" class=\"selectpicker\"></select>"
|
34
|
+
|
35
|
+
assert_equal expected, actual
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'dropdowm_select_field menu_size' do
|
39
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
40
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, menu_size: 2 }).render
|
41
|
+
expected = "<select name=\"test\" id=\"test\" data-size=\"2\" class=\"selectpicker\"></select>"
|
42
|
+
|
43
|
+
assert_equal expected, actual
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'dropdowm_select_field actions_box' do
|
47
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
48
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, actions_box: true }).render
|
49
|
+
expected = "<select name=\"test\" id=\"test\" data-actions-box=\"true\" class=\"selectpicker\"></select>"
|
50
|
+
|
51
|
+
assert_equal expected, actual
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'dropdowm_select_field show_tick' do
|
55
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
56
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, show_tick: true }).render
|
57
|
+
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker show-tick\"></select>"
|
58
|
+
|
59
|
+
assert_equal expected, actual
|
60
|
+
end
|
61
|
+
|
62
|
+
test 'dropdowm_select_field show_menu_arrow' do
|
63
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
64
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, show_menu_arrow: true }).render
|
65
|
+
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker show-menu-arrow\"></select>"
|
66
|
+
|
67
|
+
assert_equal expected, actual
|
68
|
+
end
|
69
|
+
|
70
|
+
test 'dropdowm_select_field dropup' do
|
71
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
72
|
+
actual = UiBibz::Ui::Core::DropdownSelectField.new('test', { options_tags: options, dropup: true }).render
|
73
|
+
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker dropup\"></select>"
|
74
|
+
|
75
|
+
assert_equal expected, actual
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
include UiBibz::Helpers
|
4
|
+
class InputsSwitchFieldTest < ActionView::TestCase
|
5
|
+
|
6
|
+
# OK
|
7
|
+
test 'switch_field size' do
|
8
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', size: :lg).render
|
9
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-size=\"large\" class=\"switch\" />"
|
10
|
+
|
11
|
+
assert_equal expected, actual
|
12
|
+
end
|
13
|
+
|
14
|
+
# OK
|
15
|
+
test 'switch_field animate' do
|
16
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', animate: false).render
|
17
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-animate=\"false\" class=\"switch\" />"
|
18
|
+
|
19
|
+
assert_equal expected, actual
|
20
|
+
end
|
21
|
+
|
22
|
+
# OK
|
23
|
+
test 'switch_field checked' do
|
24
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', {}, checked: true).render
|
25
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" checked=\"checked\" class=\"switch\" />"
|
26
|
+
|
27
|
+
assert_equal expected, actual
|
28
|
+
end
|
29
|
+
|
30
|
+
# OK
|
31
|
+
test 'switch_field status' do
|
32
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', {}, status: "disabled").render
|
33
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" status=\"disabled\" class=\"switch\" />"
|
34
|
+
|
35
|
+
assert_equal expected, actual
|
36
|
+
end
|
37
|
+
|
38
|
+
# NON FONCTIONNEL
|
39
|
+
test 'switch_field readonly' do
|
40
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', {}, readonly: true).render
|
41
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" readonly=\"readonly\" class=\"switch\" />"
|
42
|
+
|
43
|
+
assert_equal expected, actual
|
44
|
+
end
|
45
|
+
|
46
|
+
# OK
|
47
|
+
test 'switch_field left_color' do
|
48
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', left_color: "success").render
|
49
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-color=\"success\" class=\"switch\" />"
|
50
|
+
|
51
|
+
assert_equal expected, actual
|
52
|
+
end
|
53
|
+
|
54
|
+
# OK
|
55
|
+
test 'switch_field right_color' do
|
56
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', right_color: "info").render
|
57
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-color=\"info\" class=\"switch\" />"
|
58
|
+
|
59
|
+
assert_equal expected, actual
|
60
|
+
end
|
61
|
+
|
62
|
+
# OK
|
63
|
+
test 'switch_field middle_text' do
|
64
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', middle_text: "testlabeltext").render
|
65
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-label-text=\"testlabeltext\" class=\"switch\" />"
|
66
|
+
|
67
|
+
assert_equal expected, actual
|
68
|
+
end
|
69
|
+
|
70
|
+
# OK
|
71
|
+
test 'switch_field left_text' do
|
72
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', left_text: 'testonlabel').render
|
73
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-text=\"testonlabel\" class=\"switch\" />"
|
74
|
+
|
75
|
+
assert_equal expected, actual
|
76
|
+
end
|
77
|
+
|
78
|
+
# OK
|
79
|
+
test 'switch_field right_text' do
|
80
|
+
actual = UiBibz::Ui::Core::SwitchField.new('test', right_text: "testofflabel").render
|
81
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-text=\"testofflabel\" class=\"switch\" />"
|
82
|
+
|
83
|
+
assert_equal expected, actual
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/test/ui/inputs_test.rb
CHANGED
@@ -4,8 +4,8 @@ include UiBibz::Helpers
|
|
4
4
|
class InputsTest < ActionView::TestCase
|
5
5
|
|
6
6
|
test "Date Picker Field" do
|
7
|
-
actual = UiBibz::Ui::Core::DatePickerField.new('
|
8
|
-
expected = "<div class=\"input-group input-daterange\"><span class=\"input-group-addon\">a</span><input type=\"text\" name=\"
|
7
|
+
actual = UiBibz::Ui::Core::DatePickerField.new(['date_1', 'date_2'], { append: 'a', prepend: 'b', range: 'u' }, { class: 'datepicker-test' }).render
|
8
|
+
expected = "<div class=\"input-group input-daterange\"><span class=\"input-group-addon\">a</span><input type=\"text\" name=\"date_1\" id=\"date_1\" class=\"datepicker-test date_picker form-control\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"dd/mm/yyyy\" data-date-today-btn=\"linked\" /><span class=\"input-group-addon input-group-range\">u</span><input type=\"text\" name=\"date_2\" id=\"date_2\" class=\"datepicker-test date_picker form-control\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"dd/mm/yyyy\" data-date-today-btn=\"linked\" /><span class=\"input-group-addon\">b</span></div>"
|
9
9
|
|
10
10
|
assert_equal expected, actual
|
11
11
|
end
|
@@ -40,7 +40,7 @@ class InputsTest < ActionView::TestCase
|
|
40
40
|
test "Multi Select Field" do
|
41
41
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
42
42
|
actual = UiBibz::Ui::Core::MultiSelectField.new('example', option_tags: options).render
|
43
|
-
expected = "<select name=\"example[]\" id=\"example\" class=\"btn-
|
43
|
+
expected = "<select name=\"example[]\" id=\"example\" class=\"btn-secondary btn multi-select\" multiple=\"multiple\"><option value=\"option 0\">option 0</option>
|
44
44
|
<option value=\"option 1\">option 1</option></select>"
|
45
45
|
|
46
46
|
assert_equal expected, actual
|
@@ -49,7 +49,7 @@ class InputsTest < ActionView::TestCase
|
|
49
49
|
test "Multi Select Field data html options" do
|
50
50
|
grouped_options = { 'North America' => [['United States','US'], 'Canada'], 'Europe' => ['Denmark','Germany','France'] }
|
51
51
|
actual = UiBibz::Ui::Core::MultiSelectField.new('example', { option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, select_all_option: true, state: :danger }).render
|
52
|
-
expected = "<select name=\"example[]\" id=\"example\" data-enable-clickable-opt-groups=\"true\" data-enable-collapsible-opt-groups=\"true\" data-enable-filtering=\"true\" data-include-select-all-option=\"true\" class=\"
|
52
|
+
expected = "<select name=\"example[]\" id=\"example\" data-enable-clickable-opt-groups=\"true\" data-enable-collapsible-opt-groups=\"true\" data-enable-filtering=\"true\" data-include-select-all-option=\"true\" class=\"danger btn multi-select\" multiple=\"multiple\"><optgroup label=\"North America\"><option value=\"US\">United States</option>
|
53
53
|
<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>
|
54
54
|
<option value=\"Germany\">Germany</option>
|
55
55
|
<option value=\"France\">France</option></optgroup></select>"
|
@@ -78,4 +78,12 @@ class InputsTest < ActionView::TestCase
|
|
78
78
|
assert_equal expected, actual
|
79
79
|
end
|
80
80
|
|
81
|
+
test 'autocomplete_field' do
|
82
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
83
|
+
actual = UiBibz::Ui::Core::AutocompleteField.new('test', { option_tags: options }, { id: 'test' }).render
|
84
|
+
expected = "<input type=\"text\" name=\"test\" id=\"test\" class=\"form-control\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
|
85
|
+
<option value=\"option 1\">option 1</option></datalist>"
|
86
|
+
|
87
|
+
assert_equal expected, actual
|
88
|
+
end
|
81
89
|
end
|
data/test/ui/table_test.rb
CHANGED
@@ -5,6 +5,7 @@ require "ui_bibz/ui/ux/table/extensions/searchable"
|
|
5
5
|
require "ui_bibz/ui/ux/table/extensions/sortable"
|
6
6
|
require "ui_bibz/ui/ux/table/extensions/actionable"
|
7
7
|
include UiBibz::Helpers
|
8
|
+
|
8
9
|
class TableTest < ActionView::TestCase
|
9
10
|
|
10
11
|
setup do
|
@@ -193,4 +194,19 @@ class TableTest < ActionView::TestCase
|
|
193
194
|
end
|
194
195
|
end
|
195
196
|
|
197
|
+
test 'table visual options' do
|
198
|
+
table = UiBibz::Ui::Ux::Table.new(store: @users, striped: true, state: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, reflow: true).render
|
199
|
+
actual = Nokogiri::HTML(table).xpath("//table")[0].attributes["class"].value
|
200
|
+
expected = "table-inverse table table-striped table-bordered table-hoverable table-sm table-responsive table-reflow"
|
201
|
+
|
202
|
+
assert_equal expected, actual
|
203
|
+
end
|
204
|
+
|
205
|
+
test 'table thead visual options' do
|
206
|
+
table = UiBibz::Ui::Ux::Table.new(store: @users, thead: { state: :default }).render
|
207
|
+
actual = Nokogiri::HTML(table).xpath("//thead")[0].attributes["class"].value
|
208
|
+
expected = "thead-default"
|
209
|
+
|
210
|
+
assert_equal expected, actual
|
211
|
+
end
|
196
212
|
end
|
data/ui_bibz.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.name = "ui_bibz"
|
9
9
|
s.version = UiBibz::VERSION
|
10
10
|
s.authors = ["Thooams"]
|
11
|
-
s.email = ["
|
11
|
+
s.email = ["thomas@hummel.link"]
|
12
12
|
s.homepage = "http://thooams.github.io/Ui-Bibz/"
|
13
13
|
s.summary = "A Rails Bootstrap framework..."
|
14
|
-
s.description = "A Rails
|
14
|
+
s.description = "A Rails Bootstrap framework..."
|
15
15
|
s.license = "MIT"
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib", "vendor"]
|
21
21
|
|
22
|
-
#
|
22
|
+
# Rails gems
|
23
|
+
s.add_dependency 'bundler', '>= 1.8.4'
|
23
24
|
s.add_dependency 'rails', '>= 4.2.0'
|
24
25
|
s.add_dependency 'will_paginate', '~> 3.1.0'
|
25
26
|
s.add_dependency 'will_paginate-bootstrap'
|
@@ -28,9 +29,18 @@ Gem::Specification.new do |s|
|
|
28
29
|
s.add_dependency 'haml-rails'
|
29
30
|
s.add_dependency 'sass-rails', '>= 5.0.0'
|
30
31
|
s.add_dependency 'font-awesome-sass'
|
31
|
-
s.add_dependency 'bootstrap', '
|
32
|
+
s.add_dependency 'bootstrap', '< 4.0.0.alpha3'
|
33
|
+
|
34
|
+
# Javascript gems (rails-assets.org)
|
32
35
|
s.add_dependency 'rails-assets-tether', '>= 1.1.0'
|
36
|
+
s.add_dependency 'rails-assets-bootstrap-select', '>= 1.10.0'
|
37
|
+
s.add_dependency 'rails-assets-bootstrap-datepicker', '>= 1.6.0'
|
38
|
+
|
39
|
+
# not compatible with boostrap 4
|
40
|
+
#s.add_dependency 'rails-assets-bootstrap-switch', '>= 3.3.2'
|
41
|
+
#s.add_dependency 'rails-assets-bootstrap-multiselect', '>= 0.9.13'
|
33
42
|
|
43
|
+
# Development gems
|
34
44
|
s.add_development_dependency "minitest"
|
35
45
|
s.add_development_dependency "rdoc"
|
36
46
|
s.add_development_dependency "sqlite3"
|
@@ -19,4 +19,4 @@
|
|
19
19
|
* ========================================================================
|
20
20
|
*/
|
21
21
|
|
22
|
-
.bootstrap-switch{display:inline-block;direction:ltr;cursor:pointer;border-radius:4px;border:1px solid #ccc;position:relative;text-align:left;overflow:hidden;line-height:8px;z-index:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.bootstrap-switch .bootstrap-switch-container{display:inline-block;top:0;border-radius:4px;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on,.bootstrap-switch .bootstrap-switch-label{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block!important;
|
22
|
+
.bootstrap-switch{display:inline-block;direction:ltr;cursor:pointer;border-radius:4px;border:1px solid #ccc;position:relative;text-align:left;overflow:hidden;line-height:8px;z-index:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.bootstrap-switch .bootstrap-switch-container{display:inline-block;top:0;border-radius:4px;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on,.bootstrap-switch .bootstrap-switch-label{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;cursor:pointer;display:inline-block!important;padding:6px 12px;font-size:14px;line-height:20px}.bootstrap-switch .bootstrap-switch-handle-off,.bootstrap-switch .bootstrap-switch-handle-on{text-align:center;z-index:1}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary{color:#fff;background:#337ab7}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info{color:#fff;background:#5bc0de}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success{color:#fff;background:#5cb85c}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning{background:#f0ad4e;color:#fff}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger{color:#fff;background:#d9534f}.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default,.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default{color:#000;background:#eee}.bootstrap-switch .bootstrap-switch-label{text-align:center;margin-top:-1px;margin-bottom:-1px;z-index:100;color:#333;background:#fff}.bootstrap-switch .bootstrap-switch-handle-on{border-bottom-left-radius:3px;border-top-left-radius:3px}.bootstrap-switch .bootstrap-switch-handle-off{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch input[type=radio],.bootstrap-switch input[type=checkbox]{position:absolute!important;top:0;left:0;margin:0;z-index:-1;opacity:0;filter:alpha(opacity=0)}.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label{padding:1px 5px;font-size:12px;line-height:1.5}.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label{padding:5px 10px;font-size:12px;line-height:1.5}.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label{padding:6px 16px;font-size:18px;line-height:1.3333333}.bootstrap-switch.bootstrap-switch-disabled,.bootstrap-switch.bootstrap-switch-indeterminate,.bootstrap-switch.bootstrap-switch-readonly{cursor:default!important}.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label{opacity:.5;filter:alpha(opacity=50);cursor:default!important}.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container{-webkit-transition:margin-left .5s;-o-transition:margin-left .5s;transition:margin-left .5s}.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on{border-radius:0 3px 3px 0}.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off{border-radius:3px 0 0 3px}.bootstrap-switch.bootstrap-switch-focused{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label{border-bottom-right-radius:3px;border-top-right-radius:3px}.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label,.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label{border-bottom-left-radius:3px;border-top-left-radius:3px}
|