ui_bibz 3.0.0 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +71 -71
- data/config/locales/en.yml +3 -0
- data/config/locales/fr.yml +3 -0
- data/lib/ui_bibz.rb +1 -1
- data/lib/ui_bibz/concerns/models/searchable.rb +27 -17
- data/lib/ui_bibz/infos.rb +1 -1
- data/lib/ui_bibz/ui/concerns/card_itemable_concern.rb +1 -1
- data/lib/ui_bibz/ui/concerns/html_concern.rb +1 -1
- data/lib/ui_bibz/ui/concerns/navigation_concern.rb +1 -1
- data/lib/ui_bibz/ui/concerns/notification_concern.rb +1 -1
- data/lib/ui_bibz/ui/core/boxes/card.rb +6 -1
- data/lib/ui_bibz/ui/core/boxes/components/card_body.rb +9 -1
- data/lib/ui_bibz/ui/core/boxes/components/card_col.rb +1 -1
- data/lib/ui_bibz/ui/core/component.rb +1 -1
- data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +1 -0
- data/lib/ui_bibz/ui/core/layouts/col.rb +1 -3
- data/lib/ui_bibz/ui/core/layouts/row.rb +1 -3
- data/lib/ui_bibz/ui/core/navigations/components/navbar_form.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/components/actions.rb +3 -3
- data/lib/ui_bibz/ui/ux/tables/components/store.rb +4 -0
- data/lib/ui_bibz/ui/ux/tables/extensions/paginable.rb +0 -1
- data/lib/ui_bibz/ui/ux/tables/table_pagination.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/table_pagination_per_page.rb +2 -2
- data/lib/ui_bibz/ui/ux/tables/table_search_field.rb +1 -5
- data/test/ui/core/boxes/card_test.rb +5 -3
- data/test/ui/core/forms/selects/dropdown_select_field_test.rb +9 -0
- data/test/ui/ux/tables/table_test.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d1035c2c040919bc8d95ea88c10a9ec9d193ad0a065a2051d4bb50859f6f790
|
4
|
+
data.tar.gz: d6d98df20222b1b34dbf14cd8ef0d0ccdc9d1273b719ea91ba6f182a85d8958f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a673392058615c477d62b5b5cc9db1f5c5a7fef1fd8d37e00553c33dedd198e6f32b7b318f55b3cb7dec88c05c444442a158b93e80320f5d3eb17feeb8cd3d17
|
7
|
+
data.tar.gz: acc63ee66aab8fa6a185e57bb2f67700781c0616e3a2ada4279a1c122aaa7a35c25ae84c95d16e79bf372e1f311bc40f1adbc4956878be0e509800eac6b993b4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ui_bibz (3.0.
|
4
|
+
ui_bibz (3.0.4)
|
5
5
|
will-paginate-i18n
|
6
6
|
will_paginate (~> 3.3.0)
|
7
7
|
will_paginate-bootstrap4
|
@@ -9,60 +9,60 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actioncable (6.1.4)
|
13
|
-
actionpack (= 6.1.4)
|
14
|
-
activesupport (= 6.1.4)
|
12
|
+
actioncable (6.1.4.1)
|
13
|
+
actionpack (= 6.1.4.1)
|
14
|
+
activesupport (= 6.1.4.1)
|
15
15
|
nio4r (~> 2.0)
|
16
16
|
websocket-driver (>= 0.6.1)
|
17
|
-
actionmailbox (6.1.4)
|
18
|
-
actionpack (= 6.1.4)
|
19
|
-
activejob (= 6.1.4)
|
20
|
-
activerecord (= 6.1.4)
|
21
|
-
activestorage (= 6.1.4)
|
22
|
-
activesupport (= 6.1.4)
|
17
|
+
actionmailbox (6.1.4.1)
|
18
|
+
actionpack (= 6.1.4.1)
|
19
|
+
activejob (= 6.1.4.1)
|
20
|
+
activerecord (= 6.1.4.1)
|
21
|
+
activestorage (= 6.1.4.1)
|
22
|
+
activesupport (= 6.1.4.1)
|
23
23
|
mail (>= 2.7.1)
|
24
|
-
actionmailer (6.1.4)
|
25
|
-
actionpack (= 6.1.4)
|
26
|
-
actionview (= 6.1.4)
|
27
|
-
activejob (= 6.1.4)
|
28
|
-
activesupport (= 6.1.4)
|
24
|
+
actionmailer (6.1.4.1)
|
25
|
+
actionpack (= 6.1.4.1)
|
26
|
+
actionview (= 6.1.4.1)
|
27
|
+
activejob (= 6.1.4.1)
|
28
|
+
activesupport (= 6.1.4.1)
|
29
29
|
mail (~> 2.5, >= 2.5.4)
|
30
30
|
rails-dom-testing (~> 2.0)
|
31
|
-
actionpack (6.1.4)
|
32
|
-
actionview (= 6.1.4)
|
33
|
-
activesupport (= 6.1.4)
|
31
|
+
actionpack (6.1.4.1)
|
32
|
+
actionview (= 6.1.4.1)
|
33
|
+
activesupport (= 6.1.4.1)
|
34
34
|
rack (~> 2.0, >= 2.0.9)
|
35
35
|
rack-test (>= 0.6.3)
|
36
36
|
rails-dom-testing (~> 2.0)
|
37
37
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
38
|
-
actiontext (6.1.4)
|
39
|
-
actionpack (= 6.1.4)
|
40
|
-
activerecord (= 6.1.4)
|
41
|
-
activestorage (= 6.1.4)
|
42
|
-
activesupport (= 6.1.4)
|
38
|
+
actiontext (6.1.4.1)
|
39
|
+
actionpack (= 6.1.4.1)
|
40
|
+
activerecord (= 6.1.4.1)
|
41
|
+
activestorage (= 6.1.4.1)
|
42
|
+
activesupport (= 6.1.4.1)
|
43
43
|
nokogiri (>= 1.8.5)
|
44
|
-
actionview (6.1.4)
|
45
|
-
activesupport (= 6.1.4)
|
44
|
+
actionview (6.1.4.1)
|
45
|
+
activesupport (= 6.1.4.1)
|
46
46
|
builder (~> 3.1)
|
47
47
|
erubi (~> 1.4)
|
48
48
|
rails-dom-testing (~> 2.0)
|
49
49
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
50
|
-
activejob (6.1.4)
|
51
|
-
activesupport (= 6.1.4)
|
50
|
+
activejob (6.1.4.1)
|
51
|
+
activesupport (= 6.1.4.1)
|
52
52
|
globalid (>= 0.3.6)
|
53
|
-
activemodel (6.1.4)
|
54
|
-
activesupport (= 6.1.4)
|
55
|
-
activerecord (6.1.4)
|
56
|
-
activemodel (= 6.1.4)
|
57
|
-
activesupport (= 6.1.4)
|
58
|
-
activestorage (6.1.4)
|
59
|
-
actionpack (= 6.1.4)
|
60
|
-
activejob (= 6.1.4)
|
61
|
-
activerecord (= 6.1.4)
|
62
|
-
activesupport (= 6.1.4)
|
53
|
+
activemodel (6.1.4.1)
|
54
|
+
activesupport (= 6.1.4.1)
|
55
|
+
activerecord (6.1.4.1)
|
56
|
+
activemodel (= 6.1.4.1)
|
57
|
+
activesupport (= 6.1.4.1)
|
58
|
+
activestorage (6.1.4.1)
|
59
|
+
actionpack (= 6.1.4.1)
|
60
|
+
activejob (= 6.1.4.1)
|
61
|
+
activerecord (= 6.1.4.1)
|
62
|
+
activesupport (= 6.1.4.1)
|
63
63
|
marcel (~> 1.0.0)
|
64
64
|
mini_mime (>= 1.1.0)
|
65
|
-
activesupport (6.1.4)
|
65
|
+
activesupport (6.1.4.1)
|
66
66
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
67
67
|
i18n (>= 1.6, < 2)
|
68
68
|
minitest (>= 5.1)
|
@@ -83,9 +83,9 @@ GEM
|
|
83
83
|
factory_bot_rails (4.11.1)
|
84
84
|
factory_bot (~> 4.11.1)
|
85
85
|
railties (>= 3.0.0)
|
86
|
-
globalid (0.
|
87
|
-
activesupport (>=
|
88
|
-
haml (5.2.
|
86
|
+
globalid (0.5.2)
|
87
|
+
activesupport (>= 5.0)
|
88
|
+
haml (5.2.2)
|
89
89
|
temple (>= 0.8.0)
|
90
90
|
tilt
|
91
91
|
haml-rails (2.0.1)
|
@@ -106,19 +106,19 @@ GEM
|
|
106
106
|
rails-dom-testing (>= 1, < 3)
|
107
107
|
railties (>= 4.2.0)
|
108
108
|
thor (>= 0.14, < 2.0)
|
109
|
-
loofah (2.
|
109
|
+
loofah (2.12.0)
|
110
110
|
crass (~> 1.0.2)
|
111
111
|
nokogiri (>= 1.5.9)
|
112
112
|
mail (2.7.1)
|
113
113
|
mini_mime (>= 0.1.1)
|
114
114
|
marcel (1.0.1)
|
115
115
|
method_source (1.0.0)
|
116
|
-
mini_mime (1.1.
|
117
|
-
mini_portile2 (2.
|
116
|
+
mini_mime (1.1.1)
|
117
|
+
mini_portile2 (2.6.1)
|
118
118
|
minitest (5.14.4)
|
119
|
-
nio4r (2.5.
|
120
|
-
nokogiri (1.
|
121
|
-
mini_portile2 (~> 2.
|
119
|
+
nio4r (2.5.8)
|
120
|
+
nokogiri (1.12.3)
|
121
|
+
mini_portile2 (~> 2.6.1)
|
122
122
|
racc (~> 1.4)
|
123
123
|
overcommit (0.58.0)
|
124
124
|
childprocess (>= 0.6.3, < 5)
|
@@ -131,29 +131,29 @@ GEM
|
|
131
131
|
rack (2.2.3)
|
132
132
|
rack-test (1.1.0)
|
133
133
|
rack (>= 1.0, < 3)
|
134
|
-
rails (6.1.4)
|
135
|
-
actioncable (= 6.1.4)
|
136
|
-
actionmailbox (= 6.1.4)
|
137
|
-
actionmailer (= 6.1.4)
|
138
|
-
actionpack (= 6.1.4)
|
139
|
-
actiontext (= 6.1.4)
|
140
|
-
actionview (= 6.1.4)
|
141
|
-
activejob (= 6.1.4)
|
142
|
-
activemodel (= 6.1.4)
|
143
|
-
activerecord (= 6.1.4)
|
144
|
-
activestorage (= 6.1.4)
|
145
|
-
activesupport (= 6.1.4)
|
134
|
+
rails (6.1.4.1)
|
135
|
+
actioncable (= 6.1.4.1)
|
136
|
+
actionmailbox (= 6.1.4.1)
|
137
|
+
actionmailer (= 6.1.4.1)
|
138
|
+
actionpack (= 6.1.4.1)
|
139
|
+
actiontext (= 6.1.4.1)
|
140
|
+
actionview (= 6.1.4.1)
|
141
|
+
activejob (= 6.1.4.1)
|
142
|
+
activemodel (= 6.1.4.1)
|
143
|
+
activerecord (= 6.1.4.1)
|
144
|
+
activestorage (= 6.1.4.1)
|
145
|
+
activesupport (= 6.1.4.1)
|
146
146
|
bundler (>= 1.15.0)
|
147
|
-
railties (= 6.1.4)
|
147
|
+
railties (= 6.1.4.1)
|
148
148
|
sprockets-rails (>= 2.0.0)
|
149
149
|
rails-dom-testing (2.0.3)
|
150
150
|
activesupport (>= 4.2.0)
|
151
151
|
nokogiri (>= 1.6)
|
152
|
-
rails-html-sanitizer (1.
|
152
|
+
rails-html-sanitizer (1.4.1)
|
153
153
|
loofah (~> 2.3)
|
154
|
-
railties (6.1.4)
|
155
|
-
actionpack (= 6.1.4)
|
156
|
-
activesupport (= 6.1.4)
|
154
|
+
railties (6.1.4.1)
|
155
|
+
actionpack (= 6.1.4.1)
|
156
|
+
activesupport (= 6.1.4.1)
|
157
157
|
method_source
|
158
158
|
rake (>= 0.13)
|
159
159
|
thor (~> 1.0)
|
@@ -161,20 +161,20 @@ GEM
|
|
161
161
|
rake (13.0.6)
|
162
162
|
regexp_parser (2.1.1)
|
163
163
|
rexml (3.2.5)
|
164
|
-
rubocop (1.
|
164
|
+
rubocop (1.19.1)
|
165
165
|
parallel (~> 1.10)
|
166
166
|
parser (>= 3.0.0.0)
|
167
167
|
rainbow (>= 2.2.2, < 4.0)
|
168
168
|
regexp_parser (>= 1.8, < 3.0)
|
169
169
|
rexml
|
170
|
-
rubocop-ast (>= 1.
|
170
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
171
171
|
ruby-progressbar (~> 1.7)
|
172
172
|
unicode-display_width (>= 1.4.0, < 3.0)
|
173
|
-
rubocop-ast (1.
|
173
|
+
rubocop-ast (1.10.0)
|
174
174
|
parser (>= 3.0.1.1)
|
175
|
-
rubocop-minitest (0.
|
175
|
+
rubocop-minitest (0.15.0)
|
176
176
|
rubocop (>= 0.90, < 2.0)
|
177
|
-
rubocop-performance (1.11.
|
177
|
+
rubocop-performance (1.11.5)
|
178
178
|
rubocop (>= 1.7.0, < 2.0)
|
179
179
|
rubocop-ast (>= 0.4.0)
|
180
180
|
rubocop-rails (2.11.3)
|
@@ -182,7 +182,7 @@ GEM
|
|
182
182
|
rack (>= 1.1)
|
183
183
|
rubocop (>= 1.7.0, < 2.0)
|
184
184
|
ruby-progressbar (1.11.0)
|
185
|
-
ruby_parser (3.
|
185
|
+
ruby_parser (3.17.0)
|
186
186
|
sexp_processor (~> 4.15, >= 4.15.1)
|
187
187
|
sexp_processor (4.15.3)
|
188
188
|
simple_form (5.1.0)
|
@@ -212,7 +212,7 @@ GEM
|
|
212
212
|
websocket-extensions (>= 0.1.0)
|
213
213
|
websocket-extensions (0.1.5)
|
214
214
|
will-paginate-i18n (0.1.15)
|
215
|
-
will_paginate (3.3.
|
215
|
+
will_paginate (3.3.1)
|
216
216
|
will_paginate-bootstrap4 (0.2.2)
|
217
217
|
will_paginate (~> 3.0, >= 3.0.0)
|
218
218
|
yard (0.9.26)
|
data/config/locales/en.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/lib/ui_bibz.rb
CHANGED
@@ -16,38 +16,45 @@ module UiBibz::Concerns::Models::Searchable
|
|
16
16
|
|
17
17
|
def self.generate_parameters
|
18
18
|
{
|
19
|
-
controller: @
|
19
|
+
controller: @params[:controller],
|
20
|
+
actions_controller: @arguments[:actions_controller] || @params[:controller],
|
20
21
|
param_id: @params[:id],
|
21
22
|
params: @params,
|
22
|
-
direction: @
|
23
|
-
search: @
|
24
|
-
sort: @
|
23
|
+
direction: @tmp_params[:direction],
|
24
|
+
search: @tmp_params[:search],
|
25
|
+
sort: @tmp_params[:sort],
|
25
26
|
action: @params[:action],
|
26
27
|
column_id: @params[:column_id],
|
27
|
-
id:
|
28
|
+
id: store_id,
|
28
29
|
records: search_sort_paginate,
|
29
30
|
searchable_attributes: @searchable_attributes,
|
30
31
|
model: create_model
|
31
32
|
}
|
32
33
|
end
|
33
34
|
|
35
|
+
def self.store_id
|
36
|
+
@arguments[:store_id] || @params[:controller]
|
37
|
+
end
|
38
|
+
|
34
39
|
def self.create_model
|
35
40
|
@arguments[:model].nil? ? self : @arguments[:model].to_s.camelize.classify.constantize
|
36
41
|
end
|
37
42
|
|
38
43
|
# If there is more one table in html page
|
39
44
|
def self.initialize_params
|
40
|
-
@tmp_params = { per_page
|
45
|
+
@tmp_params = (session_store || { 'per_page' => @arguments[:per_page] || 30 }).with_indifferent_access
|
41
46
|
|
42
47
|
return unless good_store_id?
|
43
48
|
|
44
49
|
@tmp_params = {
|
45
|
-
search
|
46
|
-
per_page
|
47
|
-
page
|
48
|
-
sort
|
49
|
-
direction
|
50
|
-
}
|
50
|
+
'search' => @params[:search] || @tmp_params['search'],
|
51
|
+
'per_page' => @params[:per_page] || @tmp_params['per_page'] || @arguments[:per_page],
|
52
|
+
'page' => @params[:page],
|
53
|
+
'sort' => @params[:sort] || @tmp_params['sort'],
|
54
|
+
'direction' => @params[:direction] || @tmp_params['direction']
|
55
|
+
}.with_indifferent_access
|
56
|
+
|
57
|
+
@session[store_id] = @tmp_params
|
51
58
|
end
|
52
59
|
|
53
60
|
def self.search
|
@@ -75,15 +82,15 @@ module UiBibz::Concerns::Models::Searchable
|
|
75
82
|
|
76
83
|
def self.generate_default_sql(sql)
|
77
84
|
if sorting?
|
78
|
-
sql.paginate(page: @tmp_params[:page], per_page: @
|
85
|
+
sql.paginate(page: @tmp_params[:page], per_page: @tmp_params[:per_page])
|
79
86
|
else
|
80
|
-
sql.reorder(order_sql).paginate(page: @tmp_params[:page], per_page: @
|
87
|
+
sql.reorder(order_sql).paginate(page: @tmp_params[:page], per_page: @tmp_params[:per_page])
|
81
88
|
end
|
82
89
|
end
|
83
90
|
|
84
91
|
def self.generate_count_sql(sql)
|
85
92
|
sq = "SELECT * FROM (#{sql.group("#{table_name}.id").to_sql}) countable ORDER BY countable.count #{@tmp_params[:direction] || asc}"
|
86
|
-
paginate_by_sql(sq, page: @tmp_params[:page], per_page: @
|
93
|
+
paginate_by_sql(sq, page: @tmp_params[:page], per_page: @tmp_params[:per_page])
|
87
94
|
end
|
88
95
|
|
89
96
|
def self.generate_select_count_sort_query(sql, column_args)
|
@@ -147,13 +154,16 @@ module UiBibz::Concerns::Models::Searchable
|
|
147
154
|
end
|
148
155
|
|
149
156
|
def self.search_sort_paginate
|
150
|
-
@session[:per_page] = @tmp_params[:per_page] unless @tmp_params[:per_page].nil?
|
151
157
|
search
|
152
158
|
end
|
153
159
|
|
160
|
+
def self.session_store
|
161
|
+
@session[store_id]
|
162
|
+
end
|
163
|
+
|
154
164
|
# If there's several table in the same page
|
155
165
|
def self.good_store_id?
|
156
|
-
@
|
166
|
+
@params[:store_id].nil? ? true : store_id == @params[:store_id]
|
157
167
|
end
|
158
168
|
|
159
169
|
def self.new_search?
|
data/lib/ui_bibz/infos.rb
CHANGED
@@ -26,6 +26,7 @@ module UiBibz::Ui::Core::Boxes
|
|
26
26
|
# * text - Hash (+:size+, +:position+)
|
27
27
|
# (+:left+, +:right+, +:center+)
|
28
28
|
# * block - Boolean
|
29
|
+
# * tabbed - Boolean to use tab card
|
29
30
|
# * type - Symbol
|
30
31
|
# (+:inverse+)
|
31
32
|
#
|
@@ -108,7 +109,7 @@ module UiBibz::Ui::Core::Boxes
|
|
108
109
|
end
|
109
110
|
|
110
111
|
def component_html_classes
|
111
|
-
['card', text, type, tab_pane, outline]
|
112
|
+
['card', text, type, tab_pane, outline, tabbed]
|
112
113
|
end
|
113
114
|
|
114
115
|
def status
|
@@ -135,6 +136,10 @@ module UiBibz::Ui::Core::Boxes
|
|
135
136
|
'tab-pane' if @options[:tab]
|
136
137
|
end
|
137
138
|
|
139
|
+
def tabbed
|
140
|
+
'tab-content' if @options[:tabbed]
|
141
|
+
end
|
142
|
+
|
138
143
|
def outline
|
139
144
|
'bg-transparent' if @options[:outline]
|
140
145
|
end
|
@@ -81,7 +81,11 @@ module UiBibz::Ui::Core::Boxes::Components
|
|
81
81
|
private
|
82
82
|
|
83
83
|
def component_html_classes
|
84
|
-
['card-body', outline]
|
84
|
+
['card-body', outline, tab_pane]
|
85
|
+
end
|
86
|
+
|
87
|
+
def component_html_options
|
88
|
+
@options[:tab_pane].nil? ? {} : { id: @options[:tab_pane] }
|
85
89
|
end
|
86
90
|
|
87
91
|
def outline
|
@@ -91,5 +95,9 @@ module UiBibz::Ui::Core::Boxes::Components
|
|
91
95
|
def show
|
92
96
|
'show' if @options[:show]
|
93
97
|
end
|
98
|
+
|
99
|
+
def tab_pane
|
100
|
+
'tab-pane' if options[:tab_pane]
|
101
|
+
end
|
94
102
|
end
|
95
103
|
end
|
@@ -47,7 +47,7 @@ module UiBibz::Ui::Core::Boxes::Components
|
|
47
47
|
|
48
48
|
# See UiBibz::Ui::Core::Component.initialize
|
49
49
|
def initialize(content = nil, options = nil, html_options = nil, &block)
|
50
|
-
content =
|
50
|
+
content = { num: content } if content.is_a?(Integer)
|
51
51
|
super
|
52
52
|
@items = [@content]
|
53
53
|
end
|
@@ -148,7 +148,7 @@ module UiBibz::Ui::Core
|
|
148
148
|
# Add html data arguments
|
149
149
|
def add_html_data(name, value: true)
|
150
150
|
html_options[:data] = {} if html_options[:data].nil?
|
151
|
-
value = value.is_a?(String)
|
151
|
+
value = value.strip if value.is_a?(String)
|
152
152
|
html_options[:data].update({ name => value })
|
153
153
|
end
|
154
154
|
|
@@ -52,9 +52,7 @@ module UiBibz::Ui::Core::Layouts
|
|
52
52
|
class Col < UiBibz::Ui::Core::Component
|
53
53
|
# See UiBibz::Ui::Core::Component.initialize
|
54
54
|
def initialize(content = nil, options = nil, html_options = nil, &block)
|
55
|
-
|
56
|
-
content = content.is_a?(Integer) ? { num: content } : content
|
57
|
-
end
|
55
|
+
content = { num: content } if !block.nil? && content.is_a?(Integer)
|
58
56
|
super
|
59
57
|
end
|
60
58
|
|
@@ -50,9 +50,7 @@ module UiBibz::Ui::Core::Layouts
|
|
50
50
|
|
51
51
|
# See UiBibz::Ui::Core::Component.initialize
|
52
52
|
def initialize(content = nil, options = nil, html_options = nil, &block)
|
53
|
-
|
54
|
-
content = content.is_a?(Integer) ? { num: content } : content
|
55
|
-
end
|
53
|
+
content = { num: content } if !block.nil? && content.is_a?(Integer)
|
56
54
|
super
|
57
55
|
@items = [@content]
|
58
56
|
end
|
@@ -44,7 +44,7 @@ module UiBibz::Ui::Core::Navigations
|
|
44
44
|
include Haml::Helpers
|
45
45
|
include SimpleForm::ActionViewExtensions::FormHelper if defined?(SimpleForm)
|
46
46
|
include UiBibz::Helpers::UtilsHelper
|
47
|
-
include ActionView::Helpers
|
47
|
+
include ActionView::Helpers # ::FormHelper
|
48
48
|
|
49
49
|
attr_accessor :html_options
|
50
50
|
|
@@ -51,9 +51,9 @@ module UiBibz::Ui::Ux::Tables
|
|
51
51
|
|
52
52
|
def defaults_actions
|
53
53
|
[
|
54
|
-
UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(show_name, url: { controller: @store.
|
55
|
-
UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(edit_name, url: { controller: @store.
|
56
|
-
UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(delete_name, { glyph: 'trash', url: { controller: @store.
|
54
|
+
UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(show_name, url: { controller: @store.actions_controller, action: 'show', id: :id }, glyph: 'eye').render,
|
55
|
+
UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(edit_name, url: { controller: @store.actions_controller, action: 'edit', id: :id }, glyph: 'edit').render,
|
56
|
+
UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(delete_name, { glyph: 'trash', url: { controller: @store.actions_controller, action: 'destroy', id: :id }, link_html_options: { data: { confirm: 'Are you sure?', method: :delete } } }).render
|
57
57
|
]
|
58
58
|
end
|
59
59
|
|
@@ -15,7 +15,6 @@ module UiBibz::Ui::Ux::Tables
|
|
15
15
|
content_tag :div, @html_options do
|
16
16
|
concat UiBibz::Ui::Ux::Tables::TablePagination.new(store: @store, wrap_form: @options[:wrap_form]).render
|
17
17
|
concat UiBibz::Ui::Ux::Tables::TablePaginationPerPage.new(store: @store, wrap_form: @options[:wrap_form]).render
|
18
|
-
concat tag(:br, class: 'ui-bibz-clear')
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -39,8 +39,8 @@ module UiBibz::Ui::Ux::Tables
|
|
39
39
|
# Render html tag with boostrap pagination theme
|
40
40
|
def render
|
41
41
|
paginate_parameters = { controller: store.controller }
|
42
|
-
paginate_parameters = paginate_parameters.merge({ store_id: store.id }) unless store.id.nil?
|
43
42
|
paginate_parameters = paginate_parameters.merge(store.parameters)
|
43
|
+
paginate_parameters = paginate_parameters.merge({ store_id: store.id }) unless store.id.nil?
|
44
44
|
paginate_parameters = paginate_parameters.merge({ link_type: 'pagination' })
|
45
45
|
will_paginate(store.records, params: paginate_parameters.with_indifferent_access.reject { |k, v| default_parameters?(k) || v.blank? }, renderer: WillPaginate::ActionView::BootstrapLinkRenderer)
|
46
46
|
end
|
@@ -57,7 +57,7 @@ module UiBibz::Ui::Ux::Tables
|
|
57
57
|
content_tag :div, class: 'table-pagination-per-page' do
|
58
58
|
concat results_count_html
|
59
59
|
concat UiBibz::Utils::Internationalization.new('ui_bibz.table.pagination.per_page', default: 'Per page: ').translate
|
60
|
-
concat select_tag('per_page', options_for_select([5, 10, 20, 30, 50, 100, 200, 500], store.per_page), class: 'form-
|
60
|
+
concat select_tag('per_page', options_for_select([5, 10, 20, 30, 50, 100, 200, 500], store.per_page), class: 'form-select')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -68,7 +68,7 @@ module UiBibz::Ui::Ux::Tables
|
|
68
68
|
store.parameters.with_indifferent_access.reject { |k, v| default_parameters?(k) || v.blank? }.each do |k, v|
|
69
69
|
concat tag(:input, type: 'hidden', name: k, value: v)
|
70
70
|
end
|
71
|
-
concat select_tag('per_page', options_for_select([5, 10, 20, 30, 50, 100, 200, 500], store.per_page), class: 'form-
|
71
|
+
concat select_tag('per_page', options_for_select([5, 10, 20, 30, 50, 100, 200, 500], store.per_page), class: 'form-select')
|
72
72
|
concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # If there is more 1 table in html page
|
73
73
|
end
|
74
74
|
end
|
@@ -136,16 +136,18 @@ class CardTest < ActionView::TestCase
|
|
136
136
|
assert_equal expected, actual
|
137
137
|
end
|
138
138
|
|
139
|
-
test 'card
|
140
|
-
actual = ui_card do |c|
|
139
|
+
test 'card tab' do
|
140
|
+
actual = ui_card tabbed: true do |c|
|
141
141
|
c.header do |h|
|
142
142
|
h.tab_group do |cg|
|
143
143
|
cg.tab 'link1', url: '#link1'
|
144
144
|
cg.tab 'link2', url: '#link2'
|
145
145
|
end
|
146
146
|
end
|
147
|
+
c.body tab_pan: "link1", state: :active
|
148
|
+
c.body tab_pan: "link2"
|
147
149
|
end
|
148
|
-
expected = "<div class=\"card\"><div class=\"card-header\"><ul class=\"nav nav-tabs card-header-tabs\" role=\"tablist\"><li class=\"nav-item\"><a href=\"#link1\" class=\"nav-link\" data-bs-toggle=\"tab\" role=\"tab\">link1</a></li><li class=\"nav-item\"><a href=\"#link2\" class=\"nav-link\" data-bs-toggle=\"tab\" role=\"tab\">link2</a></li></ul></div></div>"
|
150
|
+
expected = "<div class=\"card tab-content\"><div class=\"card-header\"><ul class=\"nav nav-tabs card-header-tabs\" role=\"tablist\"><li class=\"nav-item\"><a href=\"#link1\" class=\"nav-link\" data-bs-toggle=\"tab\" role=\"tab\">link1</a></li><li class=\"nav-item\"><a href=\"#link2\" class=\"nav-link\" data-bs-toggle=\"tab\" role=\"tab\">link2</a></li></ul></div><div class=\"active card-body\"></div><div class=\"card-body\"></div></div>"
|
149
151
|
|
150
152
|
assert_equal expected, actual
|
151
153
|
end
|
@@ -12,6 +12,15 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
12
12
|
assert_equal expected, actual
|
13
13
|
end
|
14
14
|
|
15
|
+
test 'Dropdown Select Field with fuzzy search' do
|
16
|
+
options = options_for_select(Array.new(2) { |i| "option #{i}" })
|
17
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', option_tags: options, searchable: :fuzzy).render
|
18
|
+
expected = "<select name=\"example\" id=\"example\" data-enable-filtering=\"true\" data-fuzzy-search=\"true\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\"><option value=\"option 0\">option 0</option>
|
19
|
+
<option value=\"option 1\">option 1</option></select>"
|
20
|
+
|
21
|
+
assert_equal expected, actual
|
22
|
+
end
|
23
|
+
|
15
24
|
test 'Dropdown Select Field data html options' do
|
16
25
|
grouped_options = { 'North America' => [['United statuss', 'US'], 'Canada'], 'Europe' => %w[Denmark Germany France] }
|
17
26
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', { multiple: true, option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, non_selected_text: 'test', select_all_options: true, number_displayed: 2, status: :danger, n_selected_text: "items selected" }).render
|
@@ -26,14 +26,14 @@ class TableTest < ActionView::TestCase
|
|
26
26
|
|
27
27
|
test 'table search field' do
|
28
28
|
actual = UiBibz::Ui::Ux::Tables::TableSearchField.new({ store: @users }).render
|
29
|
-
expected = "<form class=\"form-table-search-field\" action=\"/users?direction=asc&page=1&per_page=2&search=Name+fr&sort=users.name_fr\" accept-charset=\"UTF-8\" method=\"get\"><div class=\"input-group input-group-sm table-search-field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-search\"></i></span><input type=\"hidden\" name=\"sort\" value=\"users.name_fr\" /><input type=\"hidden\" name=\"direction\" value=\"asc\" /><input type=\"hidden\" name=\"per_page\" value=\"2\" /><input type=\"hidden\" name=\"page\" value=\"1\" /><input type=\"hidden\" name=\"only_path\" value=\"true\" /><input type=\"hidden\" name=\"link_type\" value=\"search\" /><input type=\"search\" value=\"Name fr\" name=\"search\" class=\"form-control\" placeholder=\"Search by Name fr and Name en...\" /><button type=\"button\" class=\"btn btn-secondary input-group-btn clear-search-btn\"><i class=\"glyph fas fa-times-circle\"></i> <span class=\"visually-hidden\">Clear Search</span></button></div></form>"
|
29
|
+
expected = "<form class=\"form-table-search-field\" action=\"/users?direction=asc&page=1&per_page=2&search=Name+fr&sort=users.name_fr\" accept-charset=\"UTF-8\" method=\"get\"><div class=\"input-group input-group-sm table-search-field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-search\"></i></span><input type=\"hidden\" name=\"sort\" value=\"users.name_fr\" /><input type=\"hidden\" name=\"direction\" value=\"asc\" /><input type=\"hidden\" name=\"per_page\" value=\"2\" /><input type=\"hidden\" name=\"page\" value=\"1\" /><input type=\"hidden\" name=\"only_path\" value=\"true\" /><input type=\"hidden\" name=\"store_id\" value=\"users\" /><input type=\"hidden\" name=\"link_type\" value=\"search\" /><input type=\"search\" value=\"Name fr\" name=\"search\" class=\"form-control\" placeholder=\"Search by Name fr and Name en...\" /><button type=\"button\" class=\"btn btn-secondary input-group-btn clear-search-btn\"><i class=\"glyph fas fa-times-circle\"></i> <span class=\"visually-hidden\">Clear Search</span></button></div></form>"
|
30
30
|
|
31
31
|
assert_equal expected, actual
|
32
32
|
end
|
33
33
|
|
34
34
|
test 'table pagination' do
|
35
35
|
actual = UiBibz::Ui::Ux::Tables::TablePagination.new({ store: @users }).render
|
36
|
-
expected = "<nav class=\"pagination\"><ul class=\"pagination\" role=\"group\"><li class=\"previous page-item disabled\"><span class=\"page-link\">«</span></li> <li class=\"page-item active\"><span class=\"page-link\">1</span></li> <li class=\"page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr\">2</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=3&search=Name+fr&sort=users.name_fr\">3</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=4&search=Name+fr&sort=users.name_fr\">4</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=5&search=Name+fr&sort=users.name_fr\">5</a></li> <li class=\"page-item disabled\"><i class=\"page-link\">…</i></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=12&search=Name+fr&sort=users.name_fr\">12</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=13&search=Name+fr&sort=users.name_fr\">13</a></li> <li class=\"next page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr\">»</a></li></ul></nav>"
|
36
|
+
expected = "<nav class=\"pagination\"><ul class=\"pagination\" role=\"group\"><li class=\"previous page-item disabled\"><span class=\"page-link\">«</span></li> <li class=\"page-item active\"><span class=\"page-link\">1</span></li> <li class=\"page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr&store_id=users\">2</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=3&search=Name+fr&sort=users.name_fr&store_id=users\">3</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=4&search=Name+fr&sort=users.name_fr&store_id=users\">4</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=5&search=Name+fr&sort=users.name_fr&store_id=users\">5</a></li> <li class=\"page-item disabled\"><i class=\"page-link\">…</i></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=12&search=Name+fr&sort=users.name_fr&store_id=users\">12</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=13&search=Name+fr&sort=users.name_fr&store_id=users\">13</a></li> <li class=\"next page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr&store_id=users\">»</a></li></ul></nav>"
|
37
37
|
|
38
38
|
assert_equal expected, actual
|
39
39
|
end
|
@@ -49,7 +49,7 @@ class TableTest < ActionView::TestCase
|
|
49
49
|
test 'table sortable' do
|
50
50
|
options = { sortable: true }
|
51
51
|
actual = UiBibz::Ui::Ux::Tables::Sortable.new(@store, options).header(@store.columns.list.first)
|
52
|
-
expected = '<a class="dropup" href="/users?column_id=id&direction=asc&link_type=column&search=Name+fr&sort=users.id">Id</a>'
|
52
|
+
expected = '<a class="dropup" href="/users?column_id=id&direction=asc&link_type=column&search=Name+fr&sort=users.id&store_id=users">Id</a>'
|
53
53
|
|
54
54
|
assert_equal expected, actual
|
55
55
|
end
|
@@ -66,14 +66,14 @@ class TableTest < ActionView::TestCase
|
|
66
66
|
options = { paginable: true }
|
67
67
|
pagination = UiBibz::Ui::Ux::Tables::Paginable.new(@store, options)
|
68
68
|
actual = pagination.render if pagination.paginable?
|
69
|
-
expected = "<div><nav class=\"pagination\"><ul class=\"pagination\" role=\"group\"><li class=\"previous page-item disabled\"><span class=\"page-link\">«</span></li> <li class=\"page-item active\"><span class=\"page-link\">1</span></li> <li class=\"page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr\">2</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=3&search=Name+fr&sort=users.name_fr\">3</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=4&search=Name+fr&sort=users.name_fr\">4</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=5&search=Name+fr&sort=users.name_fr\">5</a></li> <li class=\"page-item disabled\"><i class=\"page-link\">…</i></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=12&search=Name+fr&sort=users.name_fr\">12</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=13&search=Name+fr&sort=users.name_fr\">13</a></li> <li class=\"next page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr\">»</a></li></ul></nav><form action=\"/users\" accept-charset=\"UTF-8\" method=\"get\"><div class=\"table-pagination-per-page\">Displaying User <b>1 - 2</b> of <b>25</b> in total | Per page: <input type=\"hidden\" name=\"sort\" value=\"users.name_fr\" /><input type=\"hidden\" name=\"direction\" value=\"asc\" /><input type=\"hidden\" name=\"per_page\" value=\"2\" /><input type=\"hidden\" name=\"only_path\" value=\"true\" /><select name=\"per_page\" id=\"per_page\" class=\"form-
|
69
|
+
expected = "<div><nav class=\"pagination\"><ul class=\"pagination\" role=\"group\"><li class=\"previous page-item disabled\"><span class=\"page-link\">«</span></li> <li class=\"page-item active\"><span class=\"page-link\">1</span></li> <li class=\"page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr&store_id=users\">2</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=3&search=Name+fr&sort=users.name_fr&store_id=users\">3</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=4&search=Name+fr&sort=users.name_fr&store_id=users\">4</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=5&search=Name+fr&sort=users.name_fr&store_id=users\">5</a></li> <li class=\"page-item disabled\"><i class=\"page-link\">…</i></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=12&search=Name+fr&sort=users.name_fr&store_id=users\">12</a></li> <li class=\"page-item\"><a class=\"page-link\" href=\"/users?direction=asc&page=13&search=Name+fr&sort=users.name_fr&store_id=users\">13</a></li> <li class=\"next page-item\"><a class=\"page-link\" rel=\"next\" href=\"/users?direction=asc&page=2&search=Name+fr&sort=users.name_fr&store_id=users\">»</a></li></ul></nav><form action=\"/users\" accept-charset=\"UTF-8\" method=\"get\"><div class=\"table-pagination-per-page\">Displaying User <b>1 - 2</b> of <b>25</b> in total | Per page: <input type=\"hidden\" name=\"sort\" value=\"users.name_fr\" /><input type=\"hidden\" name=\"direction\" value=\"asc\" /><input type=\"hidden\" name=\"per_page\" value=\"2\" /><input type=\"hidden\" name=\"only_path\" value=\"true\" /><select name=\"per_page\" id=\"per_page\" class=\"form-select\"><option value=\"5\">5</option>
|
70
70
|
<option value=\"10\">10</option>
|
71
71
|
<option value=\"20\">20</option>
|
72
72
|
<option value=\"30\">30</option>
|
73
73
|
<option value=\"50\">50</option>
|
74
74
|
<option value=\"100\">100</option>
|
75
75
|
<option value=\"200\">200</option>
|
76
|
-
<option value=\"500\">500</option></select
|
76
|
+
<option value=\"500\">500</option></select><input type=\"hidden\" name=\"store_id\" value=\"users\" /></div></form></div>"
|
77
77
|
|
78
78
|
assert_equal expected, actual
|
79
79
|
end
|
@@ -97,7 +97,7 @@ class TableTest < ActionView::TestCase
|
|
97
97
|
test 'table searchable' do
|
98
98
|
options = { searchable: true }
|
99
99
|
actual = UiBibz::Ui::Ux::Tables::Searchable.new(@store, options).render
|
100
|
-
expected = "<div><div class=\"title\">Users list</div><form class=\"form-table-search-field\" action=\"/users?direction=asc&page=1&per_page=2&search=Name+fr&sort=users.name_fr\" accept-charset=\"UTF-8\" method=\"get\"><div class=\"input-group input-group-sm table-search-field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-search\"></i></span><input type=\"hidden\" name=\"sort\" value=\"users.name_fr\" /><input type=\"hidden\" name=\"direction\" value=\"asc\" /><input type=\"hidden\" name=\"per_page\" value=\"2\" /><input type=\"hidden\" name=\"page\" value=\"1\" /><input type=\"hidden\" name=\"only_path\" value=\"true\" /><input type=\"hidden\" name=\"link_type\" value=\"search\" /><input type=\"search\" value=\"Name fr\" name=\"search\" class=\"form-control\" placeholder=\"Search by Name fr and Name en...\" /><button type=\"button\" class=\"btn btn-secondary input-group-btn clear-search-btn\"><i class=\"glyph fas fa-times-circle\"></i> <span class=\"visually-hidden\">Clear Search</span></button></div></form><br class=\"ui-bibz-clear\" /></div>"
|
100
|
+
expected = "<div><div class=\"title\">Users list</div><form class=\"form-table-search-field\" action=\"/users?direction=asc&page=1&per_page=2&search=Name+fr&sort=users.name_fr\" accept-charset=\"UTF-8\" method=\"get\"><div class=\"input-group input-group-sm table-search-field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-search\"></i></span><input type=\"hidden\" name=\"sort\" value=\"users.name_fr\" /><input type=\"hidden\" name=\"direction\" value=\"asc\" /><input type=\"hidden\" name=\"per_page\" value=\"2\" /><input type=\"hidden\" name=\"page\" value=\"1\" /><input type=\"hidden\" name=\"only_path\" value=\"true\" /><input type=\"hidden\" name=\"store_id\" value=\"users\" /><input type=\"hidden\" name=\"link_type\" value=\"search\" /><input type=\"search\" value=\"Name fr\" name=\"search\" class=\"form-control\" placeholder=\"Search by Name fr and Name en...\" /><button type=\"button\" class=\"btn btn-secondary input-group-btn clear-search-btn\"><i class=\"glyph fas fa-times-circle\"></i> <span class=\"visually-hidden\">Clear Search</span></button></div></form><br class=\"ui-bibz-clear\" /></div>"
|
101
101
|
|
102
102
|
assert_equal expected, actual
|
103
103
|
end
|
@@ -130,10 +130,10 @@ class TableTest < ActionView::TestCase
|
|
130
130
|
end
|
131
131
|
|
132
132
|
test 'table actionable with antoher controller' do
|
133
|
-
@users = User.table_search_pagination(params, session, {
|
133
|
+
@users = User.table_search_pagination(params, session, { actions_controller: "areas" })
|
134
134
|
@store = UiBibz::Ui::Ux::Tables::Store.new @users
|
135
135
|
|
136
|
-
assert_equal("areas", @store.
|
136
|
+
assert_equal("areas", @store.actions_controller)
|
137
137
|
end
|
138
138
|
|
139
139
|
test 'table non actionable header' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ui_bibz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thooams [Thomas HUMMEL]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|