ui_bibz 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.yardoc/checksums +49 -46
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/Gemfile.lock +69 -56
- data/README.md +156 -61
- data/doc/UiBibz/Concerns/Models/Searchable/ClassMethods.html +6 -6
- data/doc/UiBibz/Concerns/Models/Searchable.html +2 -2
- data/doc/UiBibz/Concerns/Models.html +115 -0
- data/doc/UiBibz/Concerns.html +115 -0
- data/doc/UiBibz/Helpers/MetaHelper.html +75 -9
- data/doc/UiBibz/Helpers/UiCoreHelper.html +120 -68
- data/doc/UiBibz/Helpers/UiUxHelper.html +2 -2
- data/doc/UiBibz/Helpers/UtilsHelper.html +2 -2
- data/doc/UiBibz/Helpers.html +115 -0
- data/doc/UiBibz/Rails/Engine.html +1 -1
- data/doc/UiBibz/Rails.html +1 -1
- data/doc/UiBibz/Ui/Base.html +2 -2
- data/doc/UiBibz/Ui/Core/Alert.html +26 -13
- data/doc/UiBibz/Ui/Core/Bar.html +26 -13
- data/doc/UiBibz/Ui/Core/Breadcrumb.html +32 -19
- data/doc/UiBibz/Ui/Core/BreadcrumbLink.html +26 -13
- data/doc/UiBibz/Ui/Core/Button.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonDropdown.html +31 -18
- data/doc/UiBibz/Ui/Core/ButtonGroup.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonLink.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonSplitDropdown.html +27 -14
- data/doc/UiBibz/Ui/Core/Col.html +26 -13
- data/doc/UiBibz/Ui/Core/Component.html +166 -225
- data/doc/UiBibz/Ui/Core/Dropdown.html +61 -410
- data/doc/UiBibz/Ui/Core/DropdownLink.html +373 -0
- data/doc/UiBibz/Ui/Core/DropdownList.html +26 -13
- data/doc/UiBibz/Ui/Core/Glyph.html +26 -386
- data/doc/UiBibz/Ui/Core/Jumbotron.html +26 -13
- data/doc/UiBibz/Ui/Core/Label.html +29 -15
- data/doc/UiBibz/Ui/Core/List.html +64 -25
- data/doc/UiBibz/Ui/Core/ListGroup.html +47 -21
- data/doc/UiBibz/Ui/Core/Nav.html +64 -25
- data/doc/UiBibz/Ui/Core/NavDropdown.html +29 -16
- data/doc/UiBibz/Ui/Core/NavLink.html +30 -15
- data/doc/UiBibz/Ui/Core/Navbar.html +154 -45
- data/doc/UiBibz/Ui/Core/NavbarForm.html +58 -38
- data/doc/UiBibz/Ui/Core/NavbarNav.html +7 -7
- data/doc/UiBibz/Ui/Core/NavbarText.html +26 -13
- data/doc/UiBibz/Ui/Core/Panel.html +38 -237
- data/doc/UiBibz/Ui/Core/ProgressBar.html +45 -19
- data/doc/UiBibz/Ui/Core/Row.html +26 -13
- data/doc/UiBibz/Ui/Core/Stars.html +367 -0
- data/doc/UiBibz/Ui/Core.html +16 -5
- data/doc/UiBibz/Ui/Ux/Actionable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actions.html +198 -14
- data/doc/UiBibz/Ui/Ux/Column.html +4 -4
- data/doc/UiBibz/Ui/Ux/Columns.html +42 -16
- data/doc/UiBibz/Ui/Ux/Grid.html +31 -371
- data/doc/UiBibz/Ui/Ux/Paginable.html +22 -9
- data/doc/UiBibz/Ui/Ux/Searchable.html +22 -9
- data/doc/UiBibz/Ui/Ux/Sortable.html +18 -7
- data/doc/UiBibz/Ui/Ux/Store.html +160 -56
- data/doc/UiBibz/Ui/Ux/Table.html +109 -374
- data/doc/UiBibz/Ui/Ux/TableAction.html +2 -2
- data/doc/UiBibz/Ui/Ux/TablePagination.html +33 -14
- data/doc/UiBibz/Ui/Ux/TablePaginationPerPage.html +30 -15
- data/doc/UiBibz/Ui/Ux/TablePanel.html +139 -43
- data/doc/UiBibz/Ui/Ux/TableSearchField.html +26 -13
- data/doc/UiBibz/Ui/Ux.html +15 -4
- data/doc/UiBibz/Ui.html +4 -2
- data/doc/UiBibz/Utils/Internationalization.html +1 -1
- data/doc/UiBibz/Utils.html +1 -1
- data/doc/UiBibz.html +5 -5
- data/doc/_index.html +50 -7
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +155 -63
- data/doc/images/stars.png +0 -0
- data/doc/index.html +155 -63
- data/doc/method_list.html +278 -398
- data/doc/top-level-namespace.html +1 -1
- data/lib/ui_bibz/concerns/models/searchable.rb +36 -13
- data/lib/ui_bibz/helpers/meta_helper.rb +22 -3
- data/lib/ui_bibz/helpers/ui_core_helper.rb +4 -0
- data/lib/ui_bibz/ui/core/alert.rb +2 -0
- data/lib/ui_bibz/ui/core/breadcrumb/breadcrumb.rb +3 -0
- data/lib/ui_bibz/ui/core/breadcrumb/components/breadcrumb_link.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_dropdown.rb +6 -4
- data/lib/ui_bibz/ui/core/button/button_group.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_link.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_split_dropdown.rb +2 -0
- data/lib/ui_bibz/ui/core/col.rb +2 -0
- data/lib/ui_bibz/ui/core/component.rb +23 -25
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb +57 -0
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_list.rb +2 -0
- data/lib/ui_bibz/ui/core/dropdown/dropdown.rb +22 -9
- data/lib/ui_bibz/ui/core/glyph.rb +10 -0
- data/lib/ui_bibz/ui/core/jumbotron.rb +2 -0
- data/lib/ui_bibz/ui/core/label.rb +3 -0
- data/lib/ui_bibz/ui/core/list/components/list.rb +4 -0
- data/lib/ui_bibz/ui/core/list/list_group.rb +4 -0
- data/lib/ui_bibz/ui/core/nav/components/nav_dropdown.rb +4 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_link.rb +4 -1
- data/lib/ui_bibz/ui/core/nav/components/navbar_form.rb +39 -3
- data/lib/ui_bibz/ui/core/nav/components/navbar_nav.rb +1 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_text.rb +8 -0
- data/lib/ui_bibz/ui/core/nav/nav.rb +6 -0
- data/lib/ui_bibz/ui/core/nav/navbar.rb +31 -4
- data/lib/ui_bibz/ui/core/panel.rb +7 -5
- data/lib/ui_bibz/ui/core/progress_bar/components/bar.rb +2 -0
- data/lib/ui_bibz/ui/core/progress_bar/progress_bar.rb +4 -0
- data/lib/ui_bibz/ui/core/row.rb +2 -0
- data/lib/ui_bibz/ui/core/stars.rb +88 -0
- data/lib/ui_bibz/ui/ux/grid.rb +4 -0
- data/lib/ui_bibz/ui/ux/table/components/actions.rb +17 -2
- data/lib/ui_bibz/ui/ux/table/components/column.rb +2 -2
- data/lib/ui_bibz/ui/ux/table/components/columns.rb +4 -2
- data/lib/ui_bibz/ui/ux/table/components/store.rb +10 -1
- data/lib/ui_bibz/ui/ux/table/extensions/actionable.rb +3 -1
- data/lib/ui_bibz/ui/ux/table/extensions/paginable.rb +1 -0
- data/lib/ui_bibz/ui/ux/table/extensions/searchable.rb +1 -0
- data/lib/ui_bibz/ui/ux/table/extensions/sortable.rb +8 -2
- data/lib/ui_bibz/ui/ux/table/table.rb +19 -8
- data/lib/ui_bibz/ui/ux/table/table_pagination.rb +8 -1
- data/lib/ui_bibz/ui/ux/table/table_pagination_per_page.rb +10 -2
- data/lib/ui_bibz/ui/ux/table/table_panel.rb +28 -13
- data/lib/ui_bibz/ui/ux/table/table_search_field.rb +9 -1
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +1 -0
- data/test/test_helper.rb +5 -0
- data/test/ui/dropdown_test.rb +4 -4
- data/test/ui/stars_test.rb +42 -0
- data/test/ui/table_test.rb +25 -6
- data/ui_bibz.gemspec +4 -1
- data/vendor/assets/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.svg +640 -0
- data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/javascripts/bootstrap-datepicker.min.js +8 -0
- data/vendor/assets/javascripts/bootstrap-select.min.js +8 -0
- data/vendor/assets/javascripts/bootstrap-switch.min.js +22 -0
- data/vendor/assets/javascripts/bootstrap.min.js +7 -0
- data/vendor/assets/javascripts/jquery-2.1.4.min.js +4 -0
- data/vendor/assets/javascripts/ui_bibz.js.coffee +8 -0
- data/vendor/assets/stylesheets/bootstrap-datepicker3.min.css +8 -0
- data/vendor/assets/stylesheets/bootstrap-select.min.css +6 -0
- data/vendor/assets/stylesheets/bootstrap-switch.min.css +22 -0
- data/vendor/assets/stylesheets/bootstrap-theme.min.css +5 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +5 -0
- data/vendor/assets/stylesheets/font-awesome.min.css +4 -0
- data/vendor/assets/stylesheets/ui_bibz.sass +23 -0
- metadata +71 -2
@@ -25,9 +25,10 @@ module UiBibz::Ui::Ux
|
|
25
25
|
# You can pass arguments in options attribute:
|
26
26
|
# * +store+ - Store generate by '+table_search_pagination+' method
|
27
27
|
# * +url+ - String
|
28
|
-
# * tap - Boolean
|
29
|
-
# *
|
30
|
-
# *
|
28
|
+
# * +tap+ - Boolean
|
29
|
+
# * +actionable+ - Boolean
|
30
|
+
# * +sortable+ - Boolean
|
31
|
+
# * +searchable+ - Boolean
|
31
32
|
#
|
32
33
|
# ==== Signatures
|
33
34
|
#
|
@@ -35,7 +36,7 @@ module UiBibz::Ui::Ux
|
|
35
36
|
#
|
36
37
|
# UiBibz::Ui::Ux::Table.new(store: @store, tap: true) do |t|
|
37
38
|
# t.columns do |c|
|
38
|
-
# c.column
|
39
|
+
# c.column :id, name: '#'
|
39
40
|
# end
|
40
41
|
# t.actions do |a|
|
41
42
|
# a.action '', url: url, glyph: ''
|
@@ -48,10 +49,10 @@ module UiBibz::Ui::Ux
|
|
48
49
|
#
|
49
50
|
# UiBibz::Ui::Ux::Table.new(store: @users).tap do |t|
|
50
51
|
# t.columns do |c|
|
51
|
-
# c.column
|
52
|
-
# c.column '
|
53
|
-
# c.column
|
54
|
-
# c.column
|
52
|
+
# c.column :id, { name: '#' }
|
53
|
+
# c.column :name_fr', { link: edit_user_path(:id), order: 2 }
|
54
|
+
# c.column :name_en'
|
55
|
+
# c.column :status_id, { name: 'Status', format: lambda{ |records, record| "Test #{ record.id}"} }
|
55
56
|
# end
|
56
57
|
# t.actions do |a|
|
57
58
|
# a.action 'toto', url: users_path(:id), glyph: 'eye'
|
@@ -82,24 +83,34 @@ module UiBibz::Ui::Ux
|
|
82
83
|
|
83
84
|
attr_accessor :columns
|
84
85
|
|
86
|
+
# See UiBibz::Ui::Core::Component.initialize
|
85
87
|
def initialize content = nil, options = nil, html_options = nil, &block
|
86
88
|
super
|
87
89
|
@columns = Columns.new
|
88
90
|
@actions = Actions.new store
|
89
91
|
end
|
90
92
|
|
93
|
+
# Add table columns items
|
91
94
|
def columns &block
|
92
95
|
@columns.tap(&block)
|
93
96
|
end
|
94
97
|
|
98
|
+
# Add table actions items
|
95
99
|
def actions &block
|
96
100
|
@actions.tap(&block)
|
97
101
|
end
|
98
102
|
|
103
|
+
# for test
|
104
|
+
def actions_list
|
105
|
+
@actions
|
106
|
+
end
|
107
|
+
|
108
|
+
# Render html tag
|
99
109
|
def render
|
100
110
|
table_html
|
101
111
|
end
|
102
112
|
|
113
|
+
# Store must be generated by *table_search_pagination* method
|
103
114
|
def store
|
104
115
|
@store ||= if @options[:store].nil?
|
105
116
|
raise 'Store is nil!'
|
@@ -27,16 +27,23 @@ module UiBibz::Ui::Ux
|
|
27
27
|
class TablePagination < UiBibz::Ui::Base
|
28
28
|
include WillPaginate::ActionView
|
29
29
|
|
30
|
+
# Initialize pagination with component item
|
31
|
+
# pagination require WillPaginate gem
|
30
32
|
def initialize options = nil, html_options = nil
|
31
33
|
@pagination = UiBibz::Ui::Core::Component.new nil, options, html_options
|
32
34
|
end
|
33
35
|
|
36
|
+
# Render html tag with boostrap pagination theme
|
34
37
|
def render
|
35
|
-
|
38
|
+
paginate_parameters = { controller: store.controller }
|
39
|
+
paginate_parameters = paginate_parameters.merge({ store_id: store.id }) unless store.id.nil?
|
40
|
+
will_paginate(store.records, params: paginate_parameters, renderer: BootstrapPagination::Rails)
|
36
41
|
end
|
37
42
|
|
38
43
|
private
|
39
44
|
|
45
|
+
|
46
|
+
# Store must be generated by *table_search_pagination* method
|
40
47
|
def store
|
41
48
|
@store ||= if @pagination.options[:store].nil?
|
42
49
|
raise 'Store is nil!'
|
@@ -25,13 +25,16 @@ module UiBibz::Ui::Ux
|
|
25
25
|
class TablePaginationPerPage < UiBibz::Ui::Base
|
26
26
|
include WillPaginate::ActionView
|
27
27
|
|
28
|
+
# Initialize per_page_field with component item
|
29
|
+
# per_page_field require WillPaginate gem
|
28
30
|
def initialize options = nil, html_options = nil
|
29
31
|
@per_page_field = UiBibz::Ui::Core::Component.new nil, options, html_options
|
30
32
|
end
|
31
33
|
|
34
|
+
# Render html tag
|
32
35
|
def render
|
33
36
|
if @per_page_field.options[:wrap_form] != false
|
34
|
-
form_tag(url_for(
|
37
|
+
form_tag(url_for(url_parameters), method: :get) do
|
35
38
|
per_page_html
|
36
39
|
end
|
37
40
|
else
|
@@ -51,11 +54,16 @@ module UiBibz::Ui::Ux
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
57
|
+
def url_parameters
|
58
|
+
{ controller: store.controller, action: store.action, id: store.param_id }
|
59
|
+
end
|
60
|
+
|
54
61
|
def per_page_html
|
55
62
|
content_tag :div, class: 'table-pagination-per-page' do
|
56
63
|
concat results_count_html
|
57
64
|
concat UiBibz::Utils::Internationalization.new("ui_bibz.table.pagination.per_page", default: "Per page: ").translate
|
58
|
-
concat select_tag('per_page', options_for_select([
|
65
|
+
concat select_tag('per_page', options_for_select([5, 10, 20, 30, 50, 100, 200, 500], store.per_page), class: 'form-control')
|
66
|
+
concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # If there is more 1 table in html page
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
@@ -16,9 +16,11 @@ module UiBibz::Ui::Ux
|
|
16
16
|
# You can pass arguments in options attribute:
|
17
17
|
# * +store+ - Store generate by '+table_search_pagination+' method
|
18
18
|
# * +url+ - String
|
19
|
-
# * tap - Boolean
|
20
|
-
# *
|
21
|
-
#
|
19
|
+
# * +tap+ - Boolean
|
20
|
+
# * +table_options+ - Hash
|
21
|
+
# * +actionable+ - Boolean
|
22
|
+
# * +sortable+ - Boolean
|
23
|
+
# * +searchable+ - Boolean
|
22
24
|
#
|
23
25
|
# ==== Signatures
|
24
26
|
#
|
@@ -35,15 +37,15 @@ module UiBibz::Ui::Ux
|
|
35
37
|
#
|
36
38
|
# ==== Examples
|
37
39
|
#
|
38
|
-
# UiBibz::Ui::Ux::TablePanel.new(store: @users,
|
40
|
+
# UiBibz::Ui::Ux::TablePanel.new(store: @users, table_options: { actionable: false }).render
|
39
41
|
#
|
40
42
|
# UiBibz::Ui::Ux::TablePanel.new(store: @users).tap do |t|
|
41
43
|
# t.header 'My Table panel'
|
42
44
|
# t.columns do |c|
|
43
|
-
# c.column
|
44
|
-
# c.column
|
45
|
-
# c.column
|
46
|
-
# c.column
|
45
|
+
# c.column :id, { name: '# }, { class: 'column-id' }
|
46
|
+
# c.column :name_fr, { name: 'Name FR', link: edit_user_path(:id), order: 2 }
|
47
|
+
# c.column :name_en
|
48
|
+
# c.column :status_id, { name: 'Status', format: lambda{ |records, record| "Test #{ record.id}"} }
|
47
49
|
# end
|
48
50
|
# t.actions do |a|
|
49
51
|
# a.action 'toto', url: users_path(:id), glyph: 'eye'
|
@@ -92,6 +94,7 @@ module UiBibz::Ui::Ux
|
|
92
94
|
|
93
95
|
attr_accessor :columns
|
94
96
|
|
97
|
+
# See UiBibz::Ui::Core::Component.initialize
|
95
98
|
def initialize content = nil, options = nil, html_options = nil, &block
|
96
99
|
super
|
97
100
|
@store = @options.delete(:store) if @options[:store]
|
@@ -99,30 +102,42 @@ module UiBibz::Ui::Ux
|
|
99
102
|
@table = UiBibz::Ui::Ux::Table.new(table_options, @options[:table_html_options])
|
100
103
|
end
|
101
104
|
|
105
|
+
# Render html tag
|
102
106
|
def render
|
103
107
|
initialize_header
|
104
108
|
initialize_footer
|
105
109
|
|
106
110
|
content_tag :div, class_and_html_options(panel_classes) do |f|
|
107
|
-
form_tag(url_for(
|
108
|
-
concat(header_html)
|
109
|
-
concat(body_html)
|
110
|
-
concat(table_html)
|
111
|
-
concat(footer_html)
|
111
|
+
form_tag(url_for(url_parameters), method: :get) do
|
112
|
+
concat(header_html) unless @header.nil?
|
113
|
+
concat(body_html) unless @body.nil?
|
114
|
+
concat(table_html) unless @store.nil?
|
115
|
+
concat(footer_html) unless @footer.nil?
|
112
116
|
end
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
120
|
+
# Add table columns item
|
116
121
|
def columns &block
|
117
122
|
@table.columns &block
|
118
123
|
end
|
119
124
|
|
125
|
+
# Add table actions item
|
120
126
|
def actions &block
|
121
127
|
@table.actions &block
|
122
128
|
end
|
123
129
|
|
130
|
+
# for test
|
131
|
+
def actions_list
|
132
|
+
@table.actions_list
|
133
|
+
end
|
134
|
+
|
124
135
|
private
|
125
136
|
|
137
|
+
def url_parameters
|
138
|
+
{ controller: @store.controller, action: @store.action, id: @store.param_id }
|
139
|
+
end
|
140
|
+
|
126
141
|
def table_html
|
127
142
|
content_tag :div, @table.render, class: 'panel-table'
|
128
143
|
end
|
@@ -2,13 +2,15 @@ require "ui_bibz/ui/ux/table/components/store"
|
|
2
2
|
module UiBibz::Ui::Ux
|
3
3
|
class TableSearchField < UiBibz::Ui::Base
|
4
4
|
|
5
|
+
# Initialize search_field with component item
|
5
6
|
def initialize options = nil, html_options = nil
|
6
7
|
@search_field = UiBibz::Ui::Core::Component.new nil, options, html_options
|
7
8
|
end
|
8
9
|
|
10
|
+
# Render html tag
|
9
11
|
def render
|
10
12
|
if @search_field.options[:wrap_form] != false
|
11
|
-
form_tag(url_for(
|
13
|
+
form_tag(url_for(url_parameters), method: :get, class: 'form-table-search-field') do
|
12
14
|
search_field_html
|
13
15
|
end
|
14
16
|
else
|
@@ -18,6 +20,11 @@ module UiBibz::Ui::Ux
|
|
18
20
|
|
19
21
|
private
|
20
22
|
|
23
|
+
def url_parameters
|
24
|
+
{ controller: store.controller, action: store.action, id: store.param_id }
|
25
|
+
end
|
26
|
+
|
27
|
+
# Store must be generated by *table_search_pagination* method
|
21
28
|
def store
|
22
29
|
@store ||= if @search_field.options[:store].nil?
|
23
30
|
raise 'Store is nil!'
|
@@ -32,6 +39,7 @@ module UiBibz::Ui::Ux
|
|
32
39
|
content_tag :div, @search_field.class_and_html_options(div_class) do
|
33
40
|
concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('search').render, class: 'input-group-addon')
|
34
41
|
concat tag(:input, type: 'search', value: store.search, name: 'search', class: 'form-control', placeholder: search_placeholder_field)
|
42
|
+
concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # if there is more one table in html page
|
35
43
|
concat content_tag(:span, UiBibz::Ui::Core::Glyph.new('times-circle').render, class: 'clear-search-btn input-group-addon')
|
36
44
|
end
|
37
45
|
end
|
data/lib/ui_bibz/version.rb
CHANGED
data/lib/ui_bibz.rb
CHANGED
@@ -31,6 +31,7 @@ module UiBibz
|
|
31
31
|
autoload :Panel, "ui_bibz/ui/core/panel"
|
32
32
|
autoload :ProgressBar, "ui_bibz/ui/core/progress_bar/progress_bar"
|
33
33
|
autoload :Row, "ui_bibz/ui/core/row"
|
34
|
+
autoload :Stars, "ui_bibz/ui/core/stars"
|
34
35
|
autoload :Tab, "ui_bibz/ui/core/nav/tab"
|
35
36
|
end
|
36
37
|
|
data/test/test_helper.rb
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
require "codeclimate-test-reporter"
|
3
3
|
CodeClimate::TestReporter.start
|
4
4
|
|
5
|
+
#require 'color_pound_spec_reporter'
|
6
|
+
|
7
|
+
#Minitest::Reporters.use! [ColorPoundSpecReporter.new]
|
8
|
+
require 'minitest/line/describe_track'
|
9
|
+
|
5
10
|
# Configure Rails Environment
|
6
11
|
ENV["RAILS_ENV"] = "test"
|
7
12
|
|
data/test/ui/dropdown_test.rb
CHANGED
@@ -4,13 +4,13 @@ class DropdownTest < ActionView::TestCase
|
|
4
4
|
|
5
5
|
test 'Dropdown' do
|
6
6
|
actual = UiBibz::Ui::Core::Dropdown.new("Dropdown", type: :dropup, state: :success).tap do |d|
|
7
|
-
d.
|
7
|
+
d.link 'Link 1', url: '#link1', glyph: 'eye'
|
8
8
|
d.list 'header', type: :header
|
9
|
-
d.
|
9
|
+
d.link 'Link 2', url: '#link2'
|
10
10
|
d.list '---'
|
11
|
-
d.
|
11
|
+
d.link 'Link3', url: '#link3'
|
12
12
|
end.render
|
13
|
-
expected = "<div class=\"dropup\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-expanded=\"false\">Dropdown <span class=\"caret\"></span></button><ul class=\"dropdown-menu dropdown-menu-left\" role=\"menu\"><li role=\"presentation\">
|
13
|
+
expected = "<div class=\"dropup\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-expanded=\"false\">Dropdown <span class=\"caret\"></span></button><ul class=\"dropdown-menu dropdown-menu-left\" role=\"menu\"><li role=\"presentation\"><a href=\"#link1\"><i class=\"glyph fa fa-eye\"></i> Link 1</a></li><li class=\"dropdown-header\" role=\"presentation\">header</li><li role=\"presentation\"><a href=\"#link2\">Link 2</a></li><li class=\"divider\" role=\"presentation\"></li><li role=\"presentation\"><a href=\"#link3\">Link3</a></li></ul></div>"
|
14
14
|
|
15
15
|
assert_equal expected, actual
|
16
16
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
include UiBibz::Helpers
|
4
|
+
class StarsTest < ActionView::TestCase
|
5
|
+
|
6
|
+
test "stars with 1" do
|
7
|
+
actual = UiBibz::Ui::Core::Stars.new(1).render
|
8
|
+
expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i></span>"
|
9
|
+
assert_equal expected, actual
|
10
|
+
end
|
11
|
+
|
12
|
+
test "stars with 2.1" do
|
13
|
+
actual = UiBibz::Ui::Core::Stars.new(2.1).render
|
14
|
+
expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-half-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i></span>"
|
15
|
+
assert_equal expected, actual
|
16
|
+
end
|
17
|
+
|
18
|
+
test "stars with 3.6 with state danger" do
|
19
|
+
actual = UiBibz::Ui::Core::Stars.new(3.6, { state: :danger }).render
|
20
|
+
expected = "<span class=\"stars-notation\"><i class=\"glyph-danger glyph fa fa-star\"></i> <i class=\"glyph-danger glyph fa fa-star\"></i> <i class=\"glyph-danger glyph fa fa-star\"></i> <i class=\"glyph-danger glyph fa fa-star-half-o\"></i> <i class=\"glyph-danger glyph fa fa-star-o\"></i></span>"
|
21
|
+
assert_equal expected, actual
|
22
|
+
end
|
23
|
+
|
24
|
+
test "stars with 4.9" do
|
25
|
+
actual = UiBibz::Ui::Core::Stars.new(4.9).render
|
26
|
+
expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-half-o\"></i></span>"
|
27
|
+
assert_equal expected, actual
|
28
|
+
end
|
29
|
+
|
30
|
+
test "stars with 5" do
|
31
|
+
actual = UiBibz::Ui::Core::Stars.new(5).render
|
32
|
+
expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i></span>"
|
33
|
+
assert_equal expected, actual
|
34
|
+
end
|
35
|
+
|
36
|
+
test "stars with number options 11.2" do
|
37
|
+
actual = UiBibz::Ui::Core::Stars.new(2.5, { num: 11.2 }).render
|
38
|
+
expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-half-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i></span>"
|
39
|
+
assert_equal expected, actual
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/test/ui/table_test.rb
CHANGED
@@ -65,9 +65,14 @@ class TableTest < ActionView::TestCase
|
|
65
65
|
options = { paginable: true }
|
66
66
|
pagination = UiBibz::Ui::Ux::Paginable.new(@store, options)
|
67
67
|
actual = pagination.render if pagination.paginable?
|
68
|
-
expected = "<div><ul class=\"pagination pagination\"><li class=\"prev disabled\"><span>← Previous</span></li> <li class=\"active\"><span>1</span></li> <li><a rel=\"next\" href=\"/users?page=2\">2</a></li> <li><a href=\"/users?page=3\">3</a></li> <li><a href=\"/users?page=4\">4</a></li> <li><a href=\"/users?page=5\">5</a></li> <li><a href=\"/users?page=6\">6</a></li> <li><a href=\"/users?page=7\">7</a></li> <li><a href=\"/users?page=8\">8</a></li> <li><a href=\"/users?page=9\">9</a></li> <li class=\"disabled\"><span>…</span></li> <li><a href=\"/users?page=12\">12</a></li> <li><a href=\"/users?page=13\">13</a></li> <li class=\"next\"><a rel=\"next\" href=\"/users?page=2\">Next →</a></li></ul><form action=\"/users\" accept-charset=\"UTF-8\" method=\"get\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><div class=\"table-pagination-per-page\">Displaying User <b>1 - 2</b> of <b>25</b> in total | Per page: <select name=\"per_page\" id=\"per_page\" class=\"form-control\"><option value=\"
|
68
|
+
expected = "<div><ul class=\"pagination pagination\"><li class=\"prev disabled\"><span>← Previous</span></li> <li class=\"active\"><span>1</span></li> <li><a rel=\"next\" href=\"/users?page=2\">2</a></li> <li><a href=\"/users?page=3\">3</a></li> <li><a href=\"/users?page=4\">4</a></li> <li><a href=\"/users?page=5\">5</a></li> <li><a href=\"/users?page=6\">6</a></li> <li><a href=\"/users?page=7\">7</a></li> <li><a href=\"/users?page=8\">8</a></li> <li><a href=\"/users?page=9\">9</a></li> <li class=\"disabled\"><span>…</span></li> <li><a href=\"/users?page=12\">12</a></li> <li><a href=\"/users?page=13\">13</a></li> <li class=\"next\"><a rel=\"next\" href=\"/users?page=2\">Next →</a></li></ul><form action=\"/users\" accept-charset=\"UTF-8\" method=\"get\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><div class=\"table-pagination-per-page\">Displaying User <b>1 - 2</b> of <b>25</b> in total | Per page: <select name=\"per_page\" id=\"per_page\" class=\"form-control\"><option value=\"5\">5</option>
|
69
|
+
<option value=\"10\">10</option>
|
70
|
+
<option value=\"20\">20</option>
|
71
|
+
<option value=\"30\">30</option>
|
69
72
|
<option value=\"50\">50</option>
|
70
|
-
<option value=\"100\">100</option
|
73
|
+
<option value=\"100\">100</option>
|
74
|
+
<option value=\"200\">200</option>
|
75
|
+
<option value=\"500\">500</option></select></div></form><br class=\"ui-bibz-clear\" /></div>"
|
71
76
|
|
72
77
|
assert_equal expected, actual
|
73
78
|
end
|
@@ -161,10 +166,10 @@ class TableTest < ActionView::TestCase
|
|
161
166
|
'Test body'
|
162
167
|
end
|
163
168
|
pane.columns do |c|
|
164
|
-
c.column(
|
165
|
-
c.column(
|
166
|
-
c.column(
|
167
|
-
c.column(
|
169
|
+
c.column(:id, { name: '#' })
|
170
|
+
c.column(:name_fr, { name: 'Name fr', link: edit_user_path(:id), order: 2 })
|
171
|
+
c.column(:name_en, { name: 'Name en', order: 1 })
|
172
|
+
c.column(:name_en, { name: 'Name en', format: lambda{ |records, record| "name #{ record.id}"}})
|
168
173
|
end
|
169
174
|
pane.actions do |a|
|
170
175
|
a.action 'toto', url: users_path(:id), glyph: 'eye'
|
@@ -174,4 +179,18 @@ class TableTest < ActionView::TestCase
|
|
174
179
|
end.render
|
175
180
|
end
|
176
181
|
|
182
|
+
test 'format action' do
|
183
|
+
actual = UiBibz::Ui::Ux::TablePanel.new(store: @users, tap: true).tap do |pane|
|
184
|
+
pane.columns do |cls|
|
185
|
+
cls.column :id, name: '#'
|
186
|
+
end
|
187
|
+
pane.actions do |acs|
|
188
|
+
acs.format do |record|
|
189
|
+
acs.action 'Action statique', url: '#'
|
190
|
+
acs.action "Action dynamique #{record.id}", url: '#'
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
177
196
|
end
|
data/ui_bibz.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
-
s.require_paths = ["lib"]
|
20
|
+
s.require_paths = ["lib", "vendor"]
|
21
21
|
|
22
22
|
# rails
|
23
23
|
s.add_dependency 'rails', '~> 4.2.0'
|
@@ -29,6 +29,9 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency 'sass-rails', '~> 5.0.1'
|
30
30
|
|
31
31
|
s.add_development_dependency "minitest"
|
32
|
+
s.add_development_dependency "minitest-line"
|
33
|
+
s.add_development_dependency "minitest-reporters"
|
34
|
+
s.add_development_dependency "color_pound_spec_reporter"
|
32
35
|
s.add_development_dependency "rdoc"
|
33
36
|
s.add_development_dependency "sqlite3"
|
34
37
|
s.add_development_dependency "factory_girl_rails", "~> 4.0"
|
Binary file
|
Binary file
|