Description:
DRY problem select
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r874:8ff5fd21c79c - - 12 files changed: 120 inserted, 95 deleted
@@ -0,0 +1,23 | |||
|
1 | + .card.border-info.mb-2 | |
|
2 | + .card-header.text-bg-info.border-info | |
|
3 | + Select a Task | |
|
4 | + .card-body | |
|
5 | + .row | |
|
6 | + .col-6 | |
|
7 | + = select 'submission', | |
|
8 | + 'problem_id', | |
|
9 | + problems.collect {|p| ["[#{p.name}] #{p.full_name}", send(target_url_method,p.id)]}, | |
|
10 | + { selected: (selected_problem ? problem_submissions_url(selected_problem) : -1) }, | |
|
11 | + { class: 'select2 form-control'} | |
|
12 | + .col-6 | |
|
13 | + %a.btn.btn-primary.go-button#problem_go{data: {source: '#submission_problem_id'}} Go | |
|
14 | + :javascript | |
|
15 | + $(".go-button").on('click', function(event) { | |
|
16 | + var link, url; | |
|
17 | + link = $(this).attr("data-source"); | |
|
18 | + url = $(link).val(); | |
|
19 | + if (url) { | |
|
20 | + window.location.href = url; | |
|
21 | + } | |
|
22 | + }); | |
|
23 | + |
@@ -1,60 +1,59 | |||
|
1 | 1 | source 'https://rubygems.org' |
|
2 | 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } |
|
3 | 3 | |
|
4 | 4 | ruby '3.1.2' |
|
5 | 5 | |
|
6 | 6 | #rails |
|
7 | 7 | gem 'rails', '~>7.0' |
|
8 | 8 | |
|
9 | 9 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] |
|
10 | 10 | gem "sprockets-rails" |
|
11 | 11 | |
|
12 | - gem 'activerecord-session_store' | |
|
13 | 12 | gem 'puma' |
|
14 | 13 | |
|
15 | 14 | # Reduces boot times through caching; required in config/boot.rb |
|
16 | 15 | gem 'bootsnap', require: false |
|
17 | 16 | |
|
18 | 17 | # Bundle edge Rails instead: |
|
19 | 18 | # gem 'rails', :git => 'git://github.com/rails/rails.git' |
|
20 | 19 | |
|
21 | 20 | #---------------- database --------------------- |
|
22 | 21 | #the database |
|
23 | 22 | gem 'mysql2' |
|
24 | 23 | #for testing |
|
25 | 24 | gem 'sqlite3' |
|
26 | 25 | #gem 'rails-controller-testing' |
|
27 | 26 | #for dumping database into yaml |
|
28 | 27 | #gem 'yaml_db' |
|
29 | 28 | |
|
30 | 29 | |
|
31 | 30 | #------------- assset pipeline ----------------- |
|
32 | 31 | # Gems used only for assets and not required |
|
33 | 32 | # in production environments by default. |
|
34 | 33 | #sass-rails is depricated |
|
35 | 34 | #gem 'sass-rails' |
|
36 | 35 | gem 'sassc-rails' |
|
37 | 36 | gem 'coffee-rails' |
|
38 | 37 | gem 'material_icons' |
|
39 | 38 | |
|
40 | 39 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes |
|
41 | 40 | # gem 'therubyracer', :platforms => :ruby |
|
42 | 41 | |
|
43 | 42 | gem "importmap-rails", "~> 1.1" |
|
44 | 43 | # gem 'uglifier' |
|
45 | 44 | |
|
46 | 45 | gem 'haml' |
|
47 | 46 | gem 'haml-rails' |
|
48 | 47 | |
|
49 | 48 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks |
|
50 | 49 | #gem 'turbolinks', '~> 5' |
|
51 | 50 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder |
|
52 | 51 | gem 'jbuilder' |
|
53 | 52 | |
|
54 | 53 | |
|
55 | 54 | #in-place editor |
|
56 | 55 | gem 'best_in_place', git: "https://github.com/mmotherwell/best_in_place" |
|
57 | 56 | |
|
58 | 57 | # jquery addition |
|
59 | 58 | gem 'jquery-rails' |
|
60 | 59 | #gem 'jquery-ui-rails' |
@@ -21,207 +21,199 | |||
|
21 | 21 | actionmailbox (7.0.4) |
|
22 | 22 | actionpack (= 7.0.4) |
|
23 | 23 | activejob (= 7.0.4) |
|
24 | 24 | activerecord (= 7.0.4) |
|
25 | 25 | activestorage (= 7.0.4) |
|
26 | 26 | activesupport (= 7.0.4) |
|
27 | 27 | mail (>= 2.7.1) |
|
28 | 28 | net-imap |
|
29 | 29 | net-pop |
|
30 | 30 | net-smtp |
|
31 | 31 | actionmailer (7.0.4) |
|
32 | 32 | actionpack (= 7.0.4) |
|
33 | 33 | actionview (= 7.0.4) |
|
34 | 34 | activejob (= 7.0.4) |
|
35 | 35 | activesupport (= 7.0.4) |
|
36 | 36 | mail (~> 2.5, >= 2.5.4) |
|
37 | 37 | net-imap |
|
38 | 38 | net-pop |
|
39 | 39 | net-smtp |
|
40 | 40 | rails-dom-testing (~> 2.0) |
|
41 | 41 | actionpack (7.0.4) |
|
42 | 42 | actionview (= 7.0.4) |
|
43 | 43 | activesupport (= 7.0.4) |
|
44 | 44 | rack (~> 2.0, >= 2.2.0) |
|
45 | 45 | rack-test (>= 0.6.3) |
|
46 | 46 | rails-dom-testing (~> 2.0) |
|
47 | 47 | rails-html-sanitizer (~> 1.0, >= 1.2.0) |
|
48 | 48 | actiontext (7.0.4) |
|
49 | 49 | actionpack (= 7.0.4) |
|
50 | 50 | activerecord (= 7.0.4) |
|
51 | 51 | activestorage (= 7.0.4) |
|
52 | 52 | activesupport (= 7.0.4) |
|
53 | 53 | globalid (>= 0.6.0) |
|
54 | 54 | nokogiri (>= 1.8.5) |
|
55 | 55 | actionview (7.0.4) |
|
56 | 56 | activesupport (= 7.0.4) |
|
57 | 57 | builder (~> 3.1) |
|
58 | 58 | erubi (~> 1.4) |
|
59 | 59 | rails-dom-testing (~> 2.0) |
|
60 | 60 | rails-html-sanitizer (~> 1.1, >= 1.2.0) |
|
61 | 61 | activejob (7.0.4) |
|
62 | 62 | activesupport (= 7.0.4) |
|
63 | 63 | globalid (>= 0.3.6) |
|
64 | 64 | activemodel (7.0.4) |
|
65 | 65 | activesupport (= 7.0.4) |
|
66 | 66 | activerecord (7.0.4) |
|
67 | 67 | activemodel (= 7.0.4) |
|
68 | 68 | activesupport (= 7.0.4) |
|
69 | - activerecord-session_store (2.0.0) | |
|
70 | - actionpack (>= 5.2.4.1) | |
|
71 | - activerecord (>= 5.2.4.1) | |
|
72 | - multi_json (~> 1.11, >= 1.11.2) | |
|
73 | - rack (>= 2.0.8, < 3) | |
|
74 | - railties (>= 5.2.4.1) | |
|
75 | 69 | activestorage (7.0.4) |
|
76 | 70 | actionpack (= 7.0.4) |
|
77 | 71 | activejob (= 7.0.4) |
|
78 | 72 | activerecord (= 7.0.4) |
|
79 | 73 | activesupport (= 7.0.4) |
|
80 | 74 | marcel (~> 1.0) |
|
81 | 75 | mini_mime (>= 1.1.0) |
|
82 | 76 | activesupport (7.0.4) |
|
83 | 77 | concurrent-ruby (~> 1.0, >= 1.0.2) |
|
84 | 78 | i18n (>= 1.6, < 2) |
|
85 | 79 | minitest (>= 5.1) |
|
86 | 80 | tzinfo (~> 2.0) |
|
87 | 81 | addressable (2.8.1) |
|
88 | 82 | public_suffix (>= 2.0.2, < 6.0) |
|
89 | 83 | ansi (1.5.0) |
|
90 | 84 | autoprefixer-rails (10.4.7.0) |
|
91 | 85 | execjs (~> 2) |
|
92 | 86 | bindex (0.8.1) |
|
93 | 87 | bootsnap (1.13.0) |
|
94 | 88 | msgpack (~> 1.2) |
|
95 | 89 | bootstrap (5.2.1) |
|
96 | 90 | autoprefixer-rails (>= 9.1.0) |
|
97 | 91 | popper_js (>= 2.11.6, < 3) |
|
98 | 92 | sassc-rails (>= 2.0.0) |
|
99 | 93 | builder (3.2.4) |
|
100 | 94 | byebug (11.1.3) |
|
101 | 95 | capybara (3.37.1) |
|
102 | 96 | addressable |
|
103 | 97 | matrix |
|
104 | 98 | mini_mime (>= 0.1.3) |
|
105 | 99 | nokogiri (~> 1.8) |
|
106 | 100 | rack (>= 1.6.0) |
|
107 | 101 | rack-test (>= 0.6.3) |
|
108 | 102 | regexp_parser (>= 1.5, < 3.0) |
|
109 | 103 | xpath (~> 3.2) |
|
110 | 104 | childprocess (4.1.0) |
|
111 | 105 | coffee-rails (5.0.0) |
|
112 | 106 | coffee-script (>= 2.2.0) |
|
113 | 107 | railties (>= 5.2.0) |
|
114 | 108 | coffee-script (2.4.1) |
|
115 | 109 | coffee-script-source |
|
116 | 110 | execjs |
|
117 | 111 | coffee-script-source (1.12.2) |
|
118 | 112 | concurrent-ruby (1.1.10) |
|
119 | 113 | crass (1.0.6) |
|
120 | 114 | digest (3.1.0) |
|
121 | 115 | erubi (1.11.0) |
|
122 | 116 | erubis (2.7.0) |
|
123 | 117 | execjs (2.8.1) |
|
124 | 118 | ffi (1.15.5) |
|
125 | 119 | fuzzy-string-match (1.0.1) |
|
126 | 120 | RubyInline (>= 3.8.6) |
|
127 | 121 | globalid (1.0.0) |
|
128 | 122 | activesupport (>= 5.0) |
|
129 | 123 | haml (5.2.2) |
|
130 | 124 | temple (>= 0.8.0) |
|
131 | 125 | tilt |
|
132 | 126 | haml-rails (2.0.1) |
|
133 | 127 | actionpack (>= 5.1) |
|
134 | 128 | activesupport (>= 5.1) |
|
135 | 129 | haml (>= 4.0.6, < 6.0) |
|
136 | 130 | html2haml (>= 1.0.1) |
|
137 | 131 | railties (>= 5.1) |
|
138 | 132 | html2haml (2.2.0) |
|
139 | 133 | erubis (~> 2.7.0) |
|
140 | 134 | haml (>= 4.0, < 6) |
|
141 | 135 | nokogiri (>= 1.6.0) |
|
142 | 136 | ruby_parser (~> 3.5) |
|
143 | 137 | i18n (1.12.0) |
|
144 | 138 | concurrent-ruby (~> 1.0) |
|
145 | 139 | importmap-rails (1.1.5) |
|
146 | 140 | actionpack (>= 6.0.0) |
|
147 | 141 | railties (>= 6.0.0) |
|
148 | - in_place_editing (1.2.0) | |
|
149 | 142 | jbuilder (2.11.5) |
|
150 | 143 | actionview (>= 5.0.0) |
|
151 | 144 | activesupport (>= 5.0.0) |
|
152 | 145 | jquery-rails (4.5.0) |
|
153 | 146 | rails-dom-testing (>= 1, < 3) |
|
154 | 147 | railties (>= 4.2.0) |
|
155 | 148 | thor (>= 0.14, < 2.0) |
|
156 | 149 | listen (3.0.8) |
|
157 | 150 | rb-fsevent (~> 0.9, >= 0.9.4) |
|
158 | 151 | rb-inotify (~> 0.9, >= 0.9.7) |
|
159 | 152 | loofah (2.19.0) |
|
160 | 153 | crass (~> 1.0.2) |
|
161 | 154 | nokogiri (>= 1.5.9) |
|
162 | 155 | mail (2.7.1) |
|
163 | 156 | mini_mime (>= 0.1.1) |
|
164 | 157 | marcel (1.0.2) |
|
165 | 158 | material_icons (2.2.1) |
|
166 | 159 | railties (>= 3.2) |
|
167 | 160 | matrix (0.4.2) |
|
168 | 161 | method_source (1.0.0) |
|
169 | 162 | mini_mime (1.1.2) |
|
170 | 163 | minitest (5.16.3) |
|
171 | 164 | minitest-reporters (1.5.0) |
|
172 | 165 | ansi |
|
173 | 166 | builder |
|
174 | 167 | minitest (>= 5.0) |
|
175 | 168 | ruby-progressbar |
|
176 | 169 | momentjs-rails (2.29.4.1) |
|
177 | 170 | railties (>= 3.1) |
|
178 | 171 | msgpack (1.5.6) |
|
179 | - multi_json (1.15.0) | |
|
180 | 172 | mysql2 (0.5.4) |
|
181 | 173 | net-imap (0.2.3) |
|
182 | 174 | digest |
|
183 | 175 | net-protocol |
|
184 | 176 | strscan |
|
185 | 177 | net-pop (0.1.1) |
|
186 | 178 | digest |
|
187 | 179 | net-protocol |
|
188 | 180 | timeout |
|
189 | 181 | net-protocol (0.1.3) |
|
190 | 182 | timeout |
|
191 | 183 | net-smtp (0.3.1) |
|
192 | 184 | digest |
|
193 | 185 | net-protocol |
|
194 | 186 | timeout |
|
195 | 187 | nio4r (2.5.8) |
|
196 | 188 | nokogiri (1.13.8-x86_64-linux) |
|
197 | 189 | racc (~> 1.4) |
|
198 | 190 | popper_js (2.11.6) |
|
199 | 191 | public_suffix (5.0.0) |
|
200 | 192 | puma (5.6.5) |
|
201 | 193 | nio4r (~> 2.0) |
|
202 | 194 | racc (1.6.0) |
|
203 | 195 | rack (2.2.4) |
|
204 | 196 | rack-test (2.0.2) |
|
205 | 197 | rack (>= 1.3) |
|
206 | 198 | rails (7.0.4) |
|
207 | 199 | actioncable (= 7.0.4) |
|
208 | 200 | actionmailbox (= 7.0.4) |
|
209 | 201 | actionmailer (= 7.0.4) |
|
210 | 202 | actionpack (= 7.0.4) |
|
211 | 203 | actiontext (= 7.0.4) |
|
212 | 204 | actionview (= 7.0.4) |
|
213 | 205 | activejob (= 7.0.4) |
|
214 | 206 | activemodel (= 7.0.4) |
|
215 | 207 | activerecord (= 7.0.4) |
|
216 | 208 | activestorage (= 7.0.4) |
|
217 | 209 | activesupport (= 7.0.4) |
|
218 | 210 | bundler (>= 1.15.0) |
|
219 | 211 | railties (= 7.0.4) |
|
220 | 212 | rails-dom-testing (2.0.3) |
|
221 | 213 | activesupport (>= 4.2.0) |
|
222 | 214 | nokogiri (>= 1.6) |
|
223 | 215 | rails-html-sanitizer (1.4.3) |
|
224 | 216 | loofah (~> 2.3) |
|
225 | 217 | railties (7.0.4) |
|
226 | 218 | actionpack (= 7.0.4) |
|
227 | 219 | activesupport (= 7.0.4) |
@@ -254,87 +246,85 | |||
|
254 | 246 | rexml (~> 3.2, >= 3.2.5) |
|
255 | 247 | rubyzip (>= 1.2.2, < 3.0) |
|
256 | 248 | websocket (~> 1.0) |
|
257 | 249 | sexp_processor (4.16.1) |
|
258 | 250 | simple_form (5.1.0) |
|
259 | 251 | actionpack (>= 5.2) |
|
260 | 252 | activemodel (>= 5.2) |
|
261 | 253 | spring (2.1.1) |
|
262 | 254 | spring-watcher-listen (2.0.1) |
|
263 | 255 | listen (>= 2.7, < 4.0) |
|
264 | 256 | spring (>= 1.2, < 3.0) |
|
265 | 257 | sprockets (4.1.1) |
|
266 | 258 | concurrent-ruby (~> 1.0) |
|
267 | 259 | rack (> 1, < 3) |
|
268 | 260 | sprockets-rails (3.4.2) |
|
269 | 261 | actionpack (>= 5.2) |
|
270 | 262 | activesupport (>= 5.2) |
|
271 | 263 | sprockets (>= 3.0.0) |
|
272 | 264 | sqlite3 (1.5.0-x86_64-linux) |
|
273 | 265 | strscan (3.0.4) |
|
274 | 266 | temple (0.8.2) |
|
275 | 267 | thor (1.2.1) |
|
276 | 268 | tilt (2.0.11) |
|
277 | 269 | timeout (0.3.0) |
|
278 | 270 | tzinfo (2.0.5) |
|
279 | 271 | concurrent-ruby (~> 1.0) |
|
280 | 272 | web-console (4.2.0) |
|
281 | 273 | actionview (>= 6.0.0) |
|
282 | 274 | activemodel (>= 6.0.0) |
|
283 | 275 | bindex (>= 0.4.0) |
|
284 | 276 | railties (>= 6.0.0) |
|
285 | 277 | webdrivers (5.1.0) |
|
286 | 278 | nokogiri (~> 1.6) |
|
287 | 279 | rubyzip (>= 1.3.0) |
|
288 | 280 | selenium-webdriver (~> 4.0) |
|
289 | 281 | websocket (1.2.9) |
|
290 | 282 | websocket-driver (0.7.5) |
|
291 | 283 | websocket-extensions (>= 0.1.0) |
|
292 | 284 | websocket-extensions (0.1.5) |
|
293 | 285 | xpath (3.2.0) |
|
294 | 286 | nokogiri (~> 1.8) |
|
295 | 287 | zeitwerk (2.6.0) |
|
296 | 288 | |
|
297 | 289 | PLATFORMS |
|
298 | 290 | x86_64-linux |
|
299 | 291 | |
|
300 | 292 | DEPENDENCIES |
|
301 | 293 | ace-rails-ap |
|
302 | - activerecord-session_store | |
|
303 | 294 | best_in_place! |
|
304 | 295 | bootsnap |
|
305 | 296 | bootstrap (~> 5.2) |
|
306 | 297 | byebug |
|
307 | 298 | capybara |
|
308 | 299 | coffee-rails |
|
309 | 300 | fuzzy-string-match |
|
310 | 301 | haml |
|
311 | 302 | haml-rails |
|
312 | 303 | importmap-rails (~> 1.1) |
|
313 | - in_place_editing | |
|
314 | 304 | jbuilder |
|
315 | 305 | jquery-rails |
|
316 | 306 | listen (>= 3.0.5, < 3.2) |
|
317 | 307 | |
|
318 | 308 | material_icons |
|
319 | 309 | minitest-reporters |
|
320 | 310 | momentjs-rails |
|
321 | 311 | mysql2 |
|
322 | 312 | puma |
|
323 | 313 | rails (~> 7.0) |
|
324 | 314 | rdiscount |
|
325 | 315 | rouge |
|
326 | 316 | sassc-rails |
|
327 | 317 | selenium-webdriver |
|
328 | 318 | simple_form |
|
329 | 319 | spring |
|
330 | 320 | spring-watcher-listen (~> 2.0.0) |
|
331 | 321 | sprockets-rails |
|
332 | 322 | sqlite3 |
|
333 | 323 | web-console (>= 3.3.0) |
|
334 | 324 | webdrivers |
|
335 | 325 | |
|
336 | 326 | RUBY VERSION |
|
337 | 327 | ruby 3.1.2p20 |
|
338 | 328 | |
|
339 | 329 | BUNDLED WITH |
|
340 | 330 | 2.3.22 |
@@ -1,56 +1,48 | |||
|
1 | 1 | $(document).on('change', '.btn-file :file', function() { |
|
2 | 2 | var input, label, numFiles; |
|
3 | 3 | input = $(this); |
|
4 | 4 | numFiles = input.get(0).files ? input.get(0).files.length : 1; |
|
5 | 5 | label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); |
|
6 | 6 | input.trigger('fileselect', [numFiles, label]); |
|
7 | 7 | }); |
|
8 | 8 | |
|
9 | 9 | $(function() { |
|
10 | 10 | var e; |
|
11 | 11 | $(".select2").select2({ |
|
12 | 12 | theme: "bootstrap-5", |
|
13 | 13 | //selectionCssClass: "select2--small", |
|
14 | 14 | //dropdownCssClass: "select2--small", |
|
15 | 15 | }); |
|
16 | 16 | |
|
17 | 17 | $('.btn-file :file').on('fileselect', function(event, numFiles, label) { |
|
18 | 18 | var input, log; |
|
19 | 19 | input = $(this).parents('.input-group').find(':text'); |
|
20 | 20 | log = numFiles > 1 ? numFiles + ' files selected' : label; |
|
21 | 21 | if (input.length) { |
|
22 | 22 | input.val(log); |
|
23 | 23 | } else { |
|
24 | 24 | if (log) { |
|
25 | 25 | alert(log); |
|
26 | 26 | } |
|
27 | 27 | } |
|
28 | 28 | }); |
|
29 | - $(".go-button").on('click', function(event) { | |
|
30 | - var link, url; | |
|
31 | - link = $(this).attr("data-source"); | |
|
32 | - url = $(link).val(); | |
|
33 | - if (url) { | |
|
34 | - window.location.href = url; | |
|
35 | - } | |
|
36 | - }); | |
|
37 | 29 | $('.ajax-toggle').on('click', function(event) { |
|
38 | 30 | var target; |
|
39 | 31 | target = $(event.target); |
|
40 | 32 | target.removeClass('btn-default'); |
|
41 | 33 | target.removeClass('btn-success'); |
|
42 | 34 | target.addClass('btn-warning'); |
|
43 | 35 | target.text('...'); |
|
44 | 36 | }); |
|
45 | 37 | if ($("#editor").length > 0) { |
|
46 | 38 | e = ace.edit("editor"); |
|
47 | 39 | e.setTheme('ace/theme/merbivore'); |
|
48 | 40 | e.getSession().setTabSize(2); |
|
49 | 41 | e.getSession().setUseSoftTabs(true); |
|
50 | 42 | } |
|
51 | 43 | |
|
52 | 44 | //jQuery(".best_in_place").best_in_place(); |
|
53 | 45 | }); |
|
54 | 46 | |
|
55 | 47 | // --- |
|
56 | 48 | // generated by coffee-script 1.9.2 |
@@ -1,33 +1,34 | |||
|
1 | 1 | <!DOCTYPE html> |
|
2 | 2 | %html |
|
3 | 3 | %head |
|
4 | 4 | %title= GraderConfiguration['contest.name'] |
|
5 | 5 | = stylesheet_link_tag "application", params[:controller], :media => "all" |
|
6 | 6 | = csrf_meta_tags |
|
7 | 7 | = csp_meta_tag |
|
8 | 8 | = javascript_include_tag :my_app |
|
9 | 9 | -# = javascript_import_module_tag('prepend_jquery') |
|
10 | 10 | = javascript_importmap_tags |
|
11 | 11 | = content_for :header |
|
12 | 12 | = yield :head |
|
13 | 13 | -# %link{href:"https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css",rel:"stylesheet",integrity:"sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT",crossorigin:"anonymous"} |
|
14 | 14 | -# %script{src:"https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js",integrity:"sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3",crossorigin:"anonymous"} |
|
15 | 15 | -# %script{src:"https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js",integrity:"sha384-7VPbUDkoPSGFnVtYi0QogXtr74QeVeeIs99Qfg5YCF+TidwNdjvaKZX19NZ/e6oz",crossorigin:"anonymous"} |
|
16 | 16 | |
|
17 | 17 | <link rel="preconnect" href="https://fonts.googleapis.com"> |
|
18 | 18 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
|
19 | 19 | -# |
|
20 | 20 | <link href="https://fonts.googleapis.com/css2?family=Bai+Jamjuree:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&family=Krub:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&family=Sarabun:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&display=swap" rel="stylesheet"> |
|
21 | 21 | <link href="https://fonts.googleapis.com/css2?family=Mitr:ital,wght@0,300;1,300&family=Kodchasan:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&family=Noto+Serif+Thai:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&family=Noto+Sans+Thai:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&display=swap" rel="stylesheet"> |
|
22 | 22 | <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+Thai:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&family=Noto+Sans+Thai:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&display=swap" rel="stylesheet"> |
|
23 | 23 | <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+Thai:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&display=swap" rel="stylesheet"> |
|
24 | 24 | <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&display=swap" rel="stylesheet"> |
|
25 | 25 | <link href="https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&display=swap" rel="stylesheet"> |
|
26 | 26 | |
|
27 | 27 | %body |
|
28 | 28 | - unless local_assigns[:skip_header] |
|
29 | 29 | = render 'layouts/header' |
|
30 | 30 | |
|
31 | 31 | /= content_tag(:p,flash[:notice],class: 'alert alert-success') if flash[:notice]!=nil |
|
32 | + .container-fluid | |
|
32 | 33 | = flash_messages |
|
33 | 34 | = yield |
@@ -1,43 +1,88 | |||
|
1 | - %b= GraderConfiguration['ui.front.welcome_message'] | |
|
1 | + | |
|
2 | + .card | |
|
3 | + .card-body | |
|
4 | + .card-title | |
|
5 | + %h3= GraderConfiguration['ui.front.welcome_message'] | |
|
6 | + - if !@hidelogin | |
|
7 | + .card-subtitle=t 'login.message' | |
|
8 | + | |
|
9 | + - if flash[:notice] | |
|
10 | + %hr/ | |
|
11 | + %b= flash[:notice] | |
|
12 | + %hr/ | |
|
13 | + | |
|
14 | + .card | |
|
15 | + .card-body{ style: "background: #eeeeff;"} | |
|
16 | + = form_with url: login_login_path do |f| | |
|
17 | + .mb-3 | |
|
18 | + = f.label :login, "Login", class: 'form-label' | |
|
19 | + = f.text_field :login, class: 'form-control' | |
|
20 | + .mb-3 | |
|
21 | + = f.label :password, "Password", class: 'form-label' | |
|
22 | + = f.password_field :password, class: 'form-control' | |
|
23 | + - unless GraderConfiguration['right.bypass_agreement'] | |
|
24 | + .col-sm-offset-3.col-sm-9 | |
|
25 | + .checkbox | |
|
26 | + %label | |
|
27 | + = check_box_tag 'accept_agree' | |
|
28 | + ยอมรับข้อตกลงการใช้งาน | |
|
29 | + .mb-3 | |
|
30 | + .col-sm-offset-3.col-sm-9 | |
|
31 | + = submit_tag t('login.login_submit'), class: 'btn btn-primary' | |
|
32 | + - else | |
|
33 | + Login is not possible right now | |
|
34 | + | |
|
35 | + %br/ | |
|
36 | + | |
|
37 | + - if GraderConfiguration['system.online_registration'] | |
|
38 | + =t 'login.participation' | |
|
39 | + %b | |
|
40 | + = "#{t 'login.please'} " | |
|
41 | + = link_to "#{t 'login.register'}", :controller => :users, :action => :new | |
|
42 | + %br/ | |
|
43 | + = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget | |
|
44 | + -# | |
|
2 | 45 |
|
|
3 | 46 | |
|
4 | 47 |
|
|
5 | 48 | =t 'login.message' |
|
6 | 49 | %br/ |
|
7 | 50 | %br/ |
|
8 | 51 | |
|
9 | 52 | - if flash[:notice] |
|
10 | 53 | %hr/ |
|
11 | 54 | %b= flash[:notice] |
|
12 | 55 | %hr/ |
|
13 | 56 | |
|
14 | 57 | %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"} |
|
15 | 58 | = form_tag login_login_path, {class: 'form-horizontal'} do |
|
16 | 59 | .form-group |
|
17 | 60 | =label_tag :login, "Login",class: 'col-sm-3 control-label' |
|
18 | 61 | .col-sm-9 |
|
19 | 62 | =text_field_tag :login, nil, class: 'form-control' |
|
20 | 63 | .form-group |
|
21 | 64 | =label_tag :password, "Password", class: 'col-sm-3 control-label' |
|
22 | 65 | .col-sm-9 |
|
23 | 66 | =password_field_tag :password, nil, class: 'form-control' |
|
24 | 67 | - unless GraderConfiguration['right.bypass_agreement'] |
|
25 | 68 | .form-group |
|
26 | 69 | .col-sm-offset-3.col-sm-9 |
|
27 | 70 | .checkbox |
|
28 | 71 | %label |
|
29 | 72 | = check_box_tag 'accept_agree' |
|
30 | 73 | ยอมรับข้อตกลงการใช้งาน |
|
31 | 74 | |
|
32 | 75 | .form-group |
|
33 | 76 | .col-sm-offset-3.col-sm-9 |
|
34 | 77 | = submit_tag t('login.login_submit'), class: 'btn btn-primary' |
|
78 | + - else | |
|
79 | + | |
|
35 | 80 |
|
|
36 | 81 | |
|
37 | 82 |
|
|
38 | 83 | =t 'login.participation' |
|
39 | 84 | %b |
|
40 | 85 | = "#{t 'login.please'} " |
|
41 | 86 | = link_to "#{t 'login.register'}", :controller => :users, :action => :new |
|
42 | 87 | %br/ |
|
43 | 88 | = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget |
@@ -1,97 +1,96 | |||
|
1 | 1 | :css |
|
2 | 2 | .hof_user { color: orangered; font-style: italic; } |
|
3 | 3 | .hof_language { color: green; font-style: italic; } |
|
4 | 4 | .hof_value { color: deeppink;font-style: italic; } |
|
5 | 5 | .info_param { font-weight: bold;text-align: right; } |
|
6 | 6 | .tooltip { |
|
7 | 7 | font-family: Verdana,sans-serif; |
|
8 | 8 | font-weight: normal; |
|
9 | 9 | text-align: left; |
|
10 | 10 | font-size: 1.0em; |
|
11 | 11 | color: black; |
|
12 | 12 | line-height: 1.1; |
|
13 | 13 | display: none; |
|
14 | 14 | min-width: 20em; |
|
15 | 15 | position: absolute; |
|
16 | 16 | left: 25px; |
|
17 | 17 | bottom: 5px; |
|
18 | 18 | border: 1px solid; |
|
19 | 19 | padding: 5px; |
|
20 | 20 | background-color: #FFF; |
|
21 | 21 | word-wrap: break-word; |
|
22 | 22 | z-index: 9999; |
|
23 | 23 | overflow: auto; |
|
24 | 24 | } |
|
25 | 25 | |
|
26 | 26 | |
|
27 | - .container-fluid | |
|
28 | - .row | |
|
27 | + .row.mb-3 | |
|
29 | 28 |
|
|
30 | 29 |
|
|
31 | 30 |
|
|
32 | 31 |
|
|
33 | 32 |
|
|
34 | 33 | |
|
35 | 34 |
|
|
36 | 35 |
|
|
37 | 36 |
|
|
38 | 37 |
|
|
39 | 38 |
|
|
40 | 39 |
|
|
41 | 40 |
|
|
42 | 41 |
|
|
43 | 42 |
|
|
44 | 43 |
|
|
45 | 44 |
|
|
46 | 45 |
|
|
47 | 46 |
|
|
48 | 47 |
|
|
49 | - .row | |
|
48 | + .row.mb-3 | |
|
50 | 49 |
|
|
51 | 50 |
|
|
52 | 51 |
|
|
53 | 52 |
|
|
54 | 53 | %table.table.table-hover |
|
55 | 54 | %thead |
|
56 | 55 | %tr |
|
57 | 56 | %th #Sub (lang) |
|
58 | 57 | %th Author |
|
59 | 58 | %tbody |
|
60 | 59 | - @model_subs.each do |sub| |
|
61 | 60 | %tr |
|
62 | 61 | %td |
|
63 | 62 | = link_to "##{sub.id}", submission_path(sub) |
|
64 | 63 | = "(#{sub.language.pretty_name})" |
|
65 | 64 | %td= sub.user.full_name |
|
66 | 65 |
|
|
67 | 66 |
|
|
68 | 67 |
|
|
69 | 68 |
|
|
70 | 69 |
|
|
71 | 70 | %table.table.table-hover |
|
72 | 71 | %thead |
|
73 | 72 | %tr |
|
74 | 73 | %th Language |
|
75 | 74 | %th Best runtime (ms) |
|
76 | 75 | %th Best memory (kbytes) |
|
77 | 76 | %th Shortest Code (bytes) |
|
78 | 77 | %th First solver |
|
79 | 78 | %tbody |
|
80 | 79 | %tr.bg-warning |
|
81 | 80 | %td |
|
82 | 81 | Overall |
|
83 | 82 | %td |
|
84 | 83 | by #{link_to @best[:runtime][:user], stat_user_path(@best[:runtime][:user_id])} |
|
85 | 84 | %br |
|
86 | 85 | using <span class="text-success">#{@best[:runtime][:lang]}</span> |
|
87 | 86 | %br |
|
88 | 87 | with <span class="text-success">#{@best[:runtime][:value] * 1000} milliseconds</span> |
|
89 | 88 | %br= link_to "#" + @best[:runtime][:sub_id].to_s, submission_path(@best[:runtime][:sub_id]) |
|
90 | 89 | %td |
|
91 | 90 | by #{link_to @best[:memory][:user], stat_user_path(@best[:memory][:user_id])} |
|
92 | 91 | %br |
|
93 | 92 | using <span class="text-success">#{@best[:memory][:lang]}</span> |
|
94 | 93 | %br |
|
95 | 94 | with <span class="text-success">#{number_with_delimiter(@best[:memory][:value])} kbytes </span> |
|
96 | 95 | %br= link_to "#" + @best[:memory][:sub_id].to_s, submission_path(@best[:memory][:sub_id]) |
|
97 | 96 | %td |
@@ -1,30 +1,20 | |||
|
1 | 1 | |
|
2 | 2 | /- if params[:id] |
|
3 | 3 | / %h1 Tasks Hall of Fame |
|
4 | 4 | / = link_to('[back to All-Time Hall of Fame]', action: 'problem_hof', id: nil ) |
|
5 | 5 | /- else |
|
6 | 6 | / %h1 All-Time Hall of Fame |
|
7 | 7 | |
|
8 | - .panel.panel-info | |
|
9 | - .panel-heading | |
|
10 | - Select Task | |
|
11 | - .panel-body | |
|
12 | - .form-inline | |
|
13 | - = select 'report', | |
|
14 | - 'problem_id', | |
|
15 | - @problems.collect {|p| ["[#{p.name}] #{p.full_name}", problem_hof_report_path(p)]}, | |
|
16 | - {:selected => problem_hof_report_path(@problem)}, | |
|
17 | - { class: 'select2 form-control' } | |
|
18 | - %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: "#report_problem_id"}} Go | |
|
19 | - | |
|
8 | + .row.mb-5 | |
|
9 | + .col-md-6 | |
|
10 | + = render 'problem_chooser', {problems: @problems, selected_problem: @problem, target_url_method: :problem_hof_report_path} | |
|
20 | 11 | |
|
21 | 12 | - unless params[:id] |
|
22 | - /=render partial: 'all_time_hof' | |
|
23 | 13 | Please select a problem. |
|
24 | 14 | - else |
|
25 | - %h1 | |
|
15 | + %h1.mt-3 | |
|
26 | 16 | [#{Problem.find(params[:id]).name}] #{Problem.find(params[:id]).full_name} |
|
27 | 17 | - if @current_user.has_role?('ta') |
|
28 | 18 | %a{href:stat_problem_path(@problem)} (stat) |
|
29 | 19 | =render partial: 'task_hof' |
|
30 | 20 |
@@ -1,31 +1,19 | |||
|
1 | - .card.border-info.mb-2 | |
|
2 | - .card-header.text-bg-info.border-info | |
|
3 | - Select Problems | |
|
4 | - .card-body | |
|
5 | - .row | |
|
6 | - .col-6 | |
|
7 | - = select 'submission', | |
|
8 | - 'problem_id', | |
|
9 | - @problems.collect {|p| ["[#{p.name}] #{p.full_name}", problem_submissions_url(p.id)]}, | |
|
10 | - { selected: (@problem ? problem_submissions_url(@problem) : -1) }, | |
|
11 | - { class: 'select2 form-control'} | |
|
12 | - .col-6 | |
|
13 | - %a.btn.btn-primary.go-button#problem_go{data: {source: '#submission_problem_id'}} Go | |
|
1 | + = render 'problem_chooser', {problems: @problems, selected_problem: @problem, target_url_method: :problem_submissions_path} | |
|
14 | 2 | |
|
15 | 3 | - if @problem!=nil |
|
16 | 4 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
17 | 5 | |
|
18 | 6 | - if @submissions!=nil |
|
19 | 7 | - if @submissions.length>0 |
|
20 | 8 | %table.table |
|
21 | 9 | %thead |
|
22 | 10 | %th No. |
|
23 | 11 | %th.text-right # |
|
24 | 12 | %th At |
|
25 | 13 | %th Source |
|
26 | 14 | %th Result |
|
27 | 15 | %th{:width => "300px"} Compiler message |
|
28 | 16 | %th |
|
29 | 17 | = render :partial => 'submission', :collection => @submissions |
|
30 | 18 | - else |
|
31 | 19 | No submission |
@@ -1,71 +1,71 | |||
|
1 | 1 | %h1 Users |
|
2 | 2 | |
|
3 | - .panel.panel-primary | |
|
4 | - .panel-title.panel-heading | |
|
3 | + .card.border-primary | |
|
4 | + .card-header.text-bg-primary.border-primary | |
|
5 | 5 | Quick Add |
|
6 |
- . |
|
|
7 | - = form_tag( {method: 'post'}, {class: 'form-inline'}) do | |
|
8 |
- . |
|
|
9 |
- = label |
|
|
10 |
- = text_field |
|
|
6 | + .card-body | |
|
7 | + = form_with url: 'asd', class: 'row row-cols-lg-auto g-3 align-items-center' do |f| | |
|
8 | + .col-12 | |
|
9 | + = f.label 'user_login', 'Login' | |
|
10 | + = f.text_field 'login', :size => 10,class: 'form-control' | |
|
11 | 11 | .form-group |
|
12 |
- = label |
|
|
13 |
- = text_field |
|
|
12 | + = f.label 'user_full_name', 'Full Name' | |
|
13 | + = f.text_field 'full_name', :size => 10,class: 'form-control' | |
|
14 | 14 | .form-group |
|
15 |
- = label |
|
|
16 |
- = text_field |
|
|
15 | + = f.label 'user_password', 'Password' | |
|
16 | + = f.text_field 'password', :size => 10,class: 'form-control' | |
|
17 | 17 | .form-group |
|
18 |
- = label |
|
|
19 |
- = text_field |
|
|
18 | + = f.label 'user_password_confirmation', 'Confirm' | |
|
19 | + = f.text_field 'password_confirmation', :size => 10,class: 'form-control' | |
|
20 | 20 | .form-group |
|
21 |
- = label |
|
|
22 |
- = text_field |
|
|
23 | - =submit_tag "Create", class: 'btn btn-primary' | |
|
21 | + = f.label 'user_email', 'email' | |
|
22 | + = f.text_field 'email', :size => 10,class: 'form-control' | |
|
23 | + =submit_tag "Create", class: 'btn btn-primary align-items-bottom' | |
|
24 | 24 | |
|
25 | 25 | .panel.panel-primary |
|
26 | 26 | .panel-title.panel-heading |
|
27 | 27 | Import from site management |
|
28 | 28 | .panel-body |
|
29 | 29 | = form_tag({:action => 'import'}, :multipart => true,class: 'form form-inline') do |
|
30 | 30 | .form-group |
|
31 | 31 | = label_tag :file, 'File:' |
|
32 | 32 | .input-group |
|
33 | 33 | %span.input-group-btn |
|
34 | 34 | %span.btn.btn-default.btn-file |
|
35 | 35 | Browse |
|
36 | 36 | = file_field_tag 'file' |
|
37 | 37 | = text_field_tag '' , nil, {readonly: true, class: 'form-control'} |
|
38 | 38 | = submit_tag 'Submit', class: 'btn btn-default' |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | %p |
|
42 | 42 | = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '} |
|
43 | 43 | = link_to '+ New list of users', { :action => 'new_list' }, { class: 'btn btn-success '} |
|
44 | 44 | = link_to 'Bulk Manage', { action: :bulk_manage} , { class: 'btn btn-default btn-info'} |
|
45 | 45 | = link_to 'View administrators',{ :action => 'admin'}, { class: 'btn btn-default '} |
|
46 | 46 | = link_to 'Random passwords',{ :action => 'random_all_passwords'}, { class: 'btn btn-default '} |
|
47 | 47 | = link_to 'View active users',{ :action => 'active'}, { class: 'btn btn-default '} |
|
48 | 48 | = link_to 'Mass mailing',{ :action => 'mass_mailing'}, { class: 'btn btn-default '} |
|
49 | 49 | |
|
50 | 50 | - if GraderConfiguration.multicontests? |
|
51 | 51 | %br/ |
|
52 | 52 | %b Multi-contest: |
|
53 | 53 | = link_to '[Manage bulk users in contests]', :action => 'contest_management' |
|
54 | 54 | View users in: |
|
55 | 55 | - @contests.each do |contest| |
|
56 | 56 | = link_to "[#{contest.name}]", :action => 'contests', :id => contest.id |
|
57 | 57 | = link_to "[no contest]", :action => 'contests', :id => 'none' |
|
58 | 58 | |
|
59 | 59 | -# Total #{@user_count} users | |
|
60 | 60 | -# - if !@paginated |
|
61 | 61 | -# Display all users. |
|
62 | 62 | -# \#{link_to '[show in pages]', :action => 'index', :page => '1'} |
|
63 | 63 | -# - else |
|
64 | 64 | -# Display in pages. |
|
65 | 65 | -# \#{link_to '[display all]', :action => 'index', :page => 'all'} | |
|
66 | 66 | -# \#{will_paginate @users, :container => false} |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | %table.table.table-hover.table-condense.datatable |
|
70 | 70 | %thead |
|
71 | 71 | %th Login |
@@ -1,53 +1,53 | |||
|
1 | 1 | # frozen_string_literal: true |
|
2 | 2 | # |
|
3 | 3 | # Uncomment this and change the path if necessary to include your own |
|
4 | 4 | # components. |
|
5 |
- # See https://github.com/ |
|
|
5 | + # See https://github.com/heartcombo/simple_form#custom-components to know | |
|
6 | 6 | # more about custom components. |
|
7 | 7 | # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f } |
|
8 | 8 | # |
|
9 | 9 | # Use this setup block to configure all options available in SimpleForm. |
|
10 | 10 | SimpleForm.setup do |config| |
|
11 | 11 | # Wrappers are used by the form builder to generate a |
|
12 | 12 | # complete input. You can remove any component from the |
|
13 | 13 | # wrapper, change the order or even add your own to the |
|
14 | 14 | # stack. The options given below are used to wrap the |
|
15 | 15 | # whole input. |
|
16 | 16 | config.wrappers :default, class: :input, |
|
17 | 17 | hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b| |
|
18 | 18 | ## Extensions enabled by default |
|
19 | 19 | # Any of these extensions can be disabled for a |
|
20 | 20 | # given input by passing: `f.input EXTENSION_NAME => false`. |
|
21 | 21 | # You can make any of these extensions optional by |
|
22 | 22 | # renaming `b.use` to `b.optional`. |
|
23 | 23 | |
|
24 | 24 | # Determines whether to use HTML5 (:email, :url, ...) |
|
25 | 25 | # and required attributes |
|
26 | 26 | b.use :html5 |
|
27 | 27 | |
|
28 | 28 | # Calculates placeholders automatically from I18n |
|
29 | 29 | # You can also pass a string as f.input placeholder: "Placeholder" |
|
30 | 30 | b.use :placeholder |
|
31 | 31 | |
|
32 | 32 | ## Optional extensions |
|
33 | 33 | # They are disabled unless you pass `f.input EXTENSION_NAME => true` |
|
34 | 34 | # to the input. If so, they will retrieve the values from the model |
|
35 | 35 | # if any exists. If you want to enable any of those |
|
36 | 36 | # extensions by default, you can change `b.optional` to `b.use`. |
|
37 | 37 | |
|
38 | 38 | # Calculates maxlength from length validations for string inputs |
|
39 | 39 | # and/or database column lengths |
|
40 | 40 | b.optional :maxlength |
|
41 | 41 | |
|
42 | 42 | # Calculate minlength from length validations for string inputs |
|
43 | 43 | b.optional :minlength |
|
44 | 44 | |
|
45 | 45 | # Calculates pattern from format validations for string inputs |
|
46 | 46 | b.optional :pattern |
|
47 | 47 | |
|
48 | 48 | # Calculates min and max from length validations for numeric inputs |
|
49 | 49 | b.optional :min_max |
|
50 | 50 | |
|
51 | 51 | # Calculates readonly automatically from readonly attributes |
|
52 | 52 | b.optional :readonly |
|
53 | 53 | |
@@ -84,96 +84,93 | |||
|
84 | 84 | # Default tag used for error notification helper. |
|
85 | 85 | config.error_notification_tag = :div |
|
86 | 86 | |
|
87 | 87 | # CSS class to add for error notification helper. |
|
88 | 88 | config.error_notification_class = 'error_notification' |
|
89 | 89 | |
|
90 | 90 | # Series of attempts to detect a default label method for collection. |
|
91 | 91 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] |
|
92 | 92 | |
|
93 | 93 | # Series of attempts to detect a default value method for collection. |
|
94 | 94 | # config.collection_value_methods = [ :id, :to_s ] |
|
95 | 95 | |
|
96 | 96 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. |
|
97 | 97 | # config.collection_wrapper_tag = nil |
|
98 | 98 | |
|
99 | 99 | # You can define the class to use on all collection wrappers. Defaulting to none. |
|
100 | 100 | # config.collection_wrapper_class = nil |
|
101 | 101 | |
|
102 | 102 | # You can wrap each item in a collection of radio/check boxes with a tag, |
|
103 | 103 | # defaulting to :span. |
|
104 | 104 | # config.item_wrapper_tag = :span |
|
105 | 105 | |
|
106 | 106 | # You can define a class to use in all item wrappers. Defaulting to none. |
|
107 | 107 | # config.item_wrapper_class = nil |
|
108 | 108 | |
|
109 | 109 | # How the label text should be generated altogether with the required text. |
|
110 | 110 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } |
|
111 | 111 | |
|
112 | 112 | # You can define the class to use on all labels. Default is nil. |
|
113 | 113 | # config.label_class = nil |
|
114 | 114 | |
|
115 | 115 | # You can define the default class to be used on forms. Can be overriden |
|
116 | 116 | # with `html: { :class }`. Defaulting to none. |
|
117 | 117 | # config.default_form_class = nil |
|
118 | 118 | |
|
119 | 119 | # You can define which elements should obtain additional classes |
|
120 | 120 | # config.generate_additional_classes_for = [:wrapper, :label, :input] |
|
121 | 121 | |
|
122 | 122 | # Whether attributes are required by default (or not). Default is true. |
|
123 | 123 | # config.required_by_default = true |
|
124 | 124 | |
|
125 | 125 | # Tell browsers whether to use the native HTML5 validations (novalidate form option). |
|
126 | 126 | # These validations are enabled in SimpleForm's internal config but disabled by default |
|
127 | 127 | # in this configuration, which is recommended due to some quirks from different browsers. |
|
128 | 128 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, |
|
129 | 129 | # change this configuration to true. |
|
130 | 130 | config.browser_validations = false |
|
131 | 131 | |
|
132 | - # Collection of methods to detect if a file type was given. | |
|
133 | - # config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ] | |
|
134 | - | |
|
135 | 132 | # Custom mappings for input types. This should be a hash containing a regexp |
|
136 | 133 | # to match as key, and the input type that will be used when the field name |
|
137 | 134 | # matches the regexp as value. |
|
138 | 135 | # config.input_mappings = { /count/ => :integer } |
|
139 | 136 | |
|
140 | 137 | # Custom wrappers for input types. This should be a hash containing an input |
|
141 | 138 | # type as key and the wrapper that will be used for all inputs with specified type. |
|
142 | 139 | # config.wrapper_mappings = { string: :prepend } |
|
143 | 140 | |
|
144 | 141 | # Namespaces where SimpleForm should look for custom input classes that |
|
145 | 142 | # override default inputs. |
|
146 | 143 | # config.custom_inputs_namespaces << "CustomInputs" |
|
147 | 144 | |
|
148 | 145 | # Default priority for time_zone inputs. |
|
149 | 146 | # config.time_zone_priority = nil |
|
150 | 147 | |
|
151 | 148 | # Default priority for country inputs. |
|
152 | 149 | # config.country_priority = nil |
|
153 | 150 | |
|
154 | 151 | # When false, do not use translations for labels. |
|
155 | 152 | # config.translate_labels = true |
|
156 | 153 | |
|
157 | 154 | # Automatically discover new inputs in Rails' autoload path. |
|
158 | 155 | # config.inputs_discovery = true |
|
159 | 156 | |
|
160 | 157 | # Cache SimpleForm inputs discovery |
|
161 | 158 | # config.cache_discovery = !Rails.env.development? |
|
162 | 159 | |
|
163 | 160 | # Default class for inputs |
|
164 | 161 | # config.input_class = nil |
|
165 | 162 | |
|
166 | 163 | # Define the default class of the input wrapper of the boolean input. |
|
167 | 164 | config.boolean_label_class = 'checkbox' |
|
168 | 165 | |
|
169 | 166 | # Defines if the default input wrapper class should be included in radio |
|
170 | 167 | # collection wrappers. |
|
171 | 168 | # config.include_default_input_wrapper_class = true |
|
172 | 169 | |
|
173 | 170 | # Defines which i18n scope will be used in Simple Form. |
|
174 | 171 | # config.i18n_scope = 'simple_form' |
|
175 | 172 | |
|
176 | 173 | # Defines validation classes to the input_field. By default it's nil. |
|
177 | 174 | # config.input_field_valid_class = 'is-valid' |
|
178 | 175 | # config.input_field_error_class = 'is-invalid' |
|
179 | 176 | end |
@@ -1,439 +1,440 | |||
|
1 | 1 | # frozen_string_literal: true |
|
2 | 2 | |
|
3 | 3 | # Please do not make direct changes to this file! |
|
4 | 4 | # This generator is maintained by the community around simple_form-bootstrap: |
|
5 | 5 | # https://github.com/rafaelfranca/simple_form-bootstrap |
|
6 | 6 | # All future development, tests, and organization should happen there. |
|
7 |
- # Background history: https://github.com/ |
|
|
7 | + # Background history: https://github.com/heartcombo/simple_form/issues/1561 | |
|
8 | 8 | |
|
9 | 9 | # Uncomment this and change the path if necessary to include your own |
|
10 | 10 | # components. |
|
11 |
- # See https://github.com/ |
|
|
11 | + # See https://github.com/heartcombo/simple_form#custom-components | |
|
12 | 12 | # to know more about custom components. |
|
13 | 13 | # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f } |
|
14 | 14 | |
|
15 | 15 | # Use this setup block to configure all options available in SimpleForm. |
|
16 | 16 | SimpleForm.setup do |config| |
|
17 | 17 | # Default class for buttons |
|
18 | 18 | config.button_class = 'btn' |
|
19 | 19 | |
|
20 | 20 | # Define the default class of the input wrapper of the boolean input. |
|
21 | 21 | config.boolean_label_class = 'form-check-label' |
|
22 | 22 | |
|
23 | 23 | # How the label text should be generated altogether with the required text. |
|
24 | 24 | config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" } |
|
25 | 25 | |
|
26 | 26 | # Define the way to render check boxes / radio buttons with labels. |
|
27 | 27 | config.boolean_style = :inline |
|
28 | 28 | |
|
29 | 29 | # You can wrap each item in a collection of radio/check boxes with a tag |
|
30 | 30 | config.item_wrapper_tag = :div |
|
31 | 31 | |
|
32 | 32 | # Defines if the default input wrapper class should be included in radio |
|
33 | 33 | # collection wrappers. |
|
34 | 34 | config.include_default_input_wrapper_class = false |
|
35 | 35 | |
|
36 | 36 | # CSS class to add for error notification helper. |
|
37 | 37 | config.error_notification_class = 'alert alert-danger' |
|
38 | 38 | |
|
39 | 39 | # Method used to tidy up errors. Specify any Rails Array method. |
|
40 | 40 | # :first lists the first message for each field. |
|
41 | 41 | # :to_sentence to list all errors for each field. |
|
42 | 42 | config.error_method = :to_sentence |
|
43 | 43 | |
|
44 | 44 | # add validation classes to `input_field` |
|
45 | 45 | config.input_field_error_class = 'is-invalid' |
|
46 | 46 | config.input_field_valid_class = 'is-valid' |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | # vertical forms |
|
50 | 50 | # |
|
51 | 51 | # vertical default_wrapper |
|
52 | 52 | config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
53 | 53 | b.use :html5 |
|
54 | 54 | b.use :placeholder |
|
55 | 55 | b.optional :maxlength |
|
56 | 56 | b.optional :minlength |
|
57 | 57 | b.optional :pattern |
|
58 | 58 | b.optional :min_max |
|
59 | 59 | b.optional :readonly |
|
60 | - b.use :label, class: 'form-control-label' | |
|
60 | + b.use :label | |
|
61 | 61 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid' |
|
62 | 62 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
63 | 63 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | 66 | # vertical input for boolean |
|
67 | 67 | config.wrappers :vertical_boolean, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
68 | 68 | b.use :html5 |
|
69 | 69 | b.optional :readonly |
|
70 | 70 | b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb| |
|
71 | 71 | bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
72 | 72 | bb.use :label, class: 'form-check-label' |
|
73 | 73 | bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
74 | 74 | bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
75 | 75 | end |
|
76 | 76 | end |
|
77 | 77 | |
|
78 | 78 | # vertical input for radio buttons and check boxes |
|
79 | - config.wrappers :vertical_collection, item_wrapper_class: 'form-check', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
79 | + config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
80 | 80 | b.use :html5 |
|
81 | 81 | b.optional :readonly |
|
82 | 82 | b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba| |
|
83 | 83 | ba.use :label_text |
|
84 | 84 | end |
|
85 | 85 | b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
86 | 86 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
87 | 87 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | # vertical input for inline radio buttons and check boxes |
|
91 | - config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
91 | + config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
92 | 92 | b.use :html5 |
|
93 | 93 | b.optional :readonly |
|
94 | 94 | b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba| |
|
95 | 95 | ba.use :label_text |
|
96 | 96 | end |
|
97 | 97 | b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
98 | 98 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
99 | 99 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | # vertical file input |
|
103 | 103 | config.wrappers :vertical_file, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
104 | 104 | b.use :html5 |
|
105 | 105 | b.use :placeholder |
|
106 | 106 | b.optional :maxlength |
|
107 | 107 | b.optional :minlength |
|
108 | 108 | b.optional :readonly |
|
109 | 109 | b.use :label |
|
110 | 110 | b.use :input, class: 'form-control-file', error_class: 'is-invalid', valid_class: 'is-valid' |
|
111 |
- b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback |
|
|
111 | + b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } | |
|
112 | 112 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
113 | 113 | end |
|
114 | 114 | |
|
115 | 115 | # vertical multi select |
|
116 | 116 | config.wrappers :vertical_multi_select, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
117 | 117 | b.use :html5 |
|
118 | 118 | b.optional :readonly |
|
119 | - b.use :label, class: 'form-control-label' | |
|
119 | + b.use :label | |
|
120 | 120 | b.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |ba| |
|
121 | 121 | ba.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid' |
|
122 | 122 | end |
|
123 | 123 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
124 | 124 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | # vertical range input |
|
128 | 128 | config.wrappers :vertical_range, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
129 | 129 | b.use :html5 |
|
130 | 130 | b.use :placeholder |
|
131 | 131 | b.optional :readonly |
|
132 | 132 | b.optional :step |
|
133 | 133 | b.use :label |
|
134 | 134 | b.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid' |
|
135 | 135 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
136 | 136 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | |
|
140 | 140 | # horizontal forms |
|
141 | 141 | # |
|
142 | 142 | # horizontal default_wrapper |
|
143 | 143 | config.wrappers :horizontal_form, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
144 | 144 | b.use :html5 |
|
145 | 145 | b.use :placeholder |
|
146 | 146 | b.optional :maxlength |
|
147 | 147 | b.optional :minlength |
|
148 | 148 | b.optional :pattern |
|
149 | 149 | b.optional :min_max |
|
150 | 150 | b.optional :readonly |
|
151 | 151 | b.use :label, class: 'col-sm-3 col-form-label' |
|
152 | 152 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba| |
|
153 | 153 | ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid' |
|
154 | 154 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
155 | 155 | ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
156 | 156 | end |
|
157 | 157 | end |
|
158 | 158 | |
|
159 | 159 | # horizontal input for boolean |
|
160 | 160 | config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
161 | 161 | b.use :html5 |
|
162 | 162 | b.optional :readonly |
|
163 | 163 | b.wrapper tag: 'label', class: 'col-sm-3' do |ba| |
|
164 | 164 | ba.use :label_text |
|
165 | 165 | end |
|
166 | 166 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |wr| |
|
167 | 167 | wr.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb| |
|
168 | 168 | bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
169 | 169 | bb.use :label, class: 'form-check-label' |
|
170 | 170 | bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
171 | 171 | bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
172 | 172 | end |
|
173 | 173 | end |
|
174 | 174 | end |
|
175 | 175 | |
|
176 | 176 | # horizontal input for radio buttons and check boxes |
|
177 | - config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
177 | + config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
178 | 178 | b.use :html5 |
|
179 | 179 | b.optional :readonly |
|
180 |
- b.use :label, class: 'col-sm-3 form- |
|
|
180 | + b.use :label, class: 'col-sm-3 col-form-label pt-0' | |
|
181 | 181 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba| |
|
182 | 182 | ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
183 | 183 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
184 | 184 | ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
185 | 185 | end |
|
186 | 186 | end |
|
187 | 187 | |
|
188 | 188 | # horizontal input for inline radio buttons and check boxes |
|
189 | - config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
189 | + config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
190 | 190 | b.use :html5 |
|
191 | 191 | b.optional :readonly |
|
192 |
- b.use :label, class: 'col-sm-3 form- |
|
|
192 | + b.use :label, class: 'col-sm-3 col-form-label pt-0' | |
|
193 | 193 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba| |
|
194 | 194 | ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
195 | 195 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
196 | 196 | ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
197 | 197 | end |
|
198 | 198 | end |
|
199 | 199 | |
|
200 | 200 | # horizontal file input |
|
201 | 201 | config.wrappers :horizontal_file, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
202 | 202 | b.use :html5 |
|
203 | 203 | b.use :placeholder |
|
204 | 204 | b.optional :maxlength |
|
205 | 205 | b.optional :minlength |
|
206 | 206 | b.optional :readonly |
|
207 |
- b.use :label, class: 'col-sm-3 |
|
|
207 | + b.use :label, class: 'col-sm-3 col-form-label' | |
|
208 | 208 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba| |
|
209 | 209 | ba.use :input, error_class: 'is-invalid', valid_class: 'is-valid' |
|
210 | 210 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
211 | 211 | ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
212 | 212 | end |
|
213 | 213 | end |
|
214 | 214 | |
|
215 | 215 | # horizontal multi select |
|
216 | 216 | config.wrappers :horizontal_multi_select, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
217 | 217 | b.use :html5 |
|
218 | 218 | b.optional :readonly |
|
219 |
- b.use :label, class: 'col-sm-3 co |
|
|
219 | + b.use :label, class: 'col-sm-3 col-form-label' | |
|
220 | 220 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba| |
|
221 | 221 | ba.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |bb| |
|
222 | 222 | bb.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid' |
|
223 | 223 | end |
|
224 | 224 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
225 | 225 | ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
226 | 226 | end |
|
227 | 227 | end |
|
228 | 228 | |
|
229 | 229 | # horizontal range input |
|
230 | 230 | config.wrappers :horizontal_range, tag: 'div', class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
231 | 231 | b.use :html5 |
|
232 | 232 | b.use :placeholder |
|
233 | 233 | b.optional :readonly |
|
234 | 234 | b.optional :step |
|
235 |
- b.use :label, class: 'col-sm-3 |
|
|
235 | + b.use :label, class: 'col-sm-3 col-form-label' | |
|
236 | 236 | b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba| |
|
237 | 237 | ba.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid' |
|
238 | 238 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
239 | 239 | ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
240 | 240 | end |
|
241 | 241 | end |
|
242 | 242 | |
|
243 | 243 | |
|
244 | 244 | # inline forms |
|
245 | 245 | # |
|
246 | 246 | # inline default_wrapper |
|
247 | 247 | config.wrappers :inline_form, tag: 'span', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
248 | 248 | b.use :html5 |
|
249 | 249 | b.use :placeholder |
|
250 | 250 | b.optional :maxlength |
|
251 | 251 | b.optional :minlength |
|
252 | 252 | b.optional :pattern |
|
253 | 253 | b.optional :min_max |
|
254 | 254 | b.optional :readonly |
|
255 | 255 | b.use :label, class: 'sr-only' |
|
256 | 256 | |
|
257 | 257 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid' |
|
258 | 258 | b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
259 | 259 | b.optional :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
260 | 260 | end |
|
261 | 261 | |
|
262 | 262 | # inline input for boolean |
|
263 |
- config.wrappers :inline_boolean, tag: 'span', class: 'form-check |
|
|
263 | + config.wrappers :inline_boolean, tag: 'span', class: 'form-check mb-2 mr-sm-2', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
264 | 264 | b.use :html5 |
|
265 | 265 | b.optional :readonly |
|
266 | 266 | b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
267 | 267 | b.use :label, class: 'form-check-label' |
|
268 | 268 | b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
269 | 269 | b.optional :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
270 | 270 | end |
|
271 | 271 | |
|
272 | 272 | |
|
273 | 273 | # bootstrap custom forms |
|
274 | 274 | # |
|
275 | 275 | # custom input for boolean |
|
276 | 276 | config.wrappers :custom_boolean, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
277 | 277 | b.use :html5 |
|
278 | 278 | b.optional :readonly |
|
279 | 279 | b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-checkbox' do |bb| |
|
280 | 280 | bb.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
281 | 281 | bb.use :label, class: 'custom-control-label' |
|
282 | 282 | bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
283 | 283 | bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
284 | 284 | end |
|
285 | 285 | end |
|
286 | 286 | |
|
287 | + # custom input switch for boolean | |
|
287 | 288 | config.wrappers :custom_boolean_switch, tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
288 | 289 | b.use :html5 |
|
289 | 290 | b.optional :readonly |
|
290 |
- b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom- |
|
|
291 | + b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-switch' do |bb| | |
|
291 | 292 | bb.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
292 | 293 | bb.use :label, class: 'custom-control-label' |
|
293 | 294 | bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
294 | 295 | bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
295 | 296 | end |
|
296 | 297 | end |
|
297 | 298 | |
|
298 | 299 | # custom input for radio buttons and check boxes |
|
299 | - config.wrappers :custom_collection, item_wrapper_class: 'custom-control', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
300 | + config.wrappers :custom_collection, item_wrapper_class: 'custom-control', item_label_class: 'custom-control-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
300 | 301 | b.use :html5 |
|
301 | 302 | b.optional :readonly |
|
302 | 303 | b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba| |
|
303 | 304 | ba.use :label_text |
|
304 | 305 | end |
|
305 | 306 | b.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
306 | 307 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
307 | 308 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
308 | 309 | end |
|
309 | 310 | |
|
310 | 311 | # custom input for inline radio buttons and check boxes |
|
311 | - config.wrappers :custom_collection_inline, item_wrapper_class: 'custom-control custom-control-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
312 | + config.wrappers :custom_collection_inline, item_wrapper_class: 'custom-control custom-control-inline', item_label_class: 'custom-control-label', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| | |
|
312 | 313 | b.use :html5 |
|
313 | 314 | b.optional :readonly |
|
314 | 315 | b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba| |
|
315 | 316 | ba.use :label_text |
|
316 | 317 | end |
|
317 | 318 | b.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
318 | 319 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
319 | 320 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
320 | 321 | end |
|
321 | 322 | |
|
322 | 323 | # custom file input |
|
323 | 324 | config.wrappers :custom_file, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
324 | 325 | b.use :html5 |
|
325 | 326 | b.use :placeholder |
|
326 | 327 | b.optional :maxlength |
|
327 | 328 | b.optional :minlength |
|
328 | 329 | b.optional :readonly |
|
329 | - b.use :label, class: 'form-control-label' | |
|
330 | + b.use :label | |
|
330 | 331 | b.wrapper :custom_file_wrapper, tag: 'div', class: 'custom-file' do |ba| |
|
331 | 332 | ba.use :input, class: 'custom-file-input', error_class: 'is-invalid', valid_class: 'is-valid' |
|
332 | 333 | ba.use :label, class: 'custom-file-label' |
|
333 | 334 | ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
334 | 335 | end |
|
335 | 336 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
336 | 337 | end |
|
337 | 338 | |
|
338 | 339 | # custom multi select |
|
339 | 340 | config.wrappers :custom_multi_select, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
340 | 341 | b.use :html5 |
|
341 | 342 | b.optional :readonly |
|
342 | - b.use :label, class: 'form-control-label' | |
|
343 | + b.use :label | |
|
343 | 344 | b.wrapper tag: 'div', class: 'd-flex flex-row justify-content-between align-items-center' do |ba| |
|
344 | 345 | ba.use :input, class: 'custom-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid' |
|
345 | 346 | end |
|
346 | 347 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
347 | 348 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
348 | 349 | end |
|
349 | 350 | |
|
350 | 351 | # custom range input |
|
351 | 352 | config.wrappers :custom_range, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
352 | 353 | b.use :html5 |
|
353 | 354 | b.use :placeholder |
|
354 | 355 | b.optional :readonly |
|
355 | 356 | b.optional :step |
|
356 | - b.use :label, class: 'form-control-label' | |
|
357 | + b.use :label | |
|
357 | 358 | b.use :input, class: 'custom-range', error_class: 'is-invalid', valid_class: 'is-valid' |
|
358 | 359 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
359 | 360 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
360 | 361 | end |
|
361 | 362 | |
|
362 | 363 | |
|
363 | 364 | # Input Group - custom component |
|
364 | 365 | # see example app and config at https://github.com/rafaelfranca/simple_form-bootstrap |
|
365 | 366 | # config.wrappers :input_group, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
366 | 367 | # b.use :html5 |
|
367 | 368 | # b.use :placeholder |
|
368 | 369 | # b.optional :maxlength |
|
369 | 370 | # b.optional :minlength |
|
370 | 371 | # b.optional :pattern |
|
371 | 372 | # b.optional :min_max |
|
372 | 373 | # b.optional :readonly |
|
373 | - # b.use :label, class: 'form-control-label' | |
|
374 | + # b.use :label | |
|
374 | 375 | # b.wrapper :input_group_tag, tag: 'div', class: 'input-group' do |ba| |
|
375 | 376 | # ba.optional :prepend |
|
376 | 377 | # ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid' |
|
377 | 378 | # ba.optional :append |
|
378 | 379 | # end |
|
379 | 380 | # b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' } |
|
380 | 381 | # b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
381 | 382 | # end |
|
382 | 383 | |
|
383 | 384 | |
|
384 | 385 | # Floating Labels form |
|
385 | 386 | # |
|
386 | 387 | # floating labels default_wrapper |
|
387 | 388 | config.wrappers :floating_labels_form, tag: 'div', class: 'form-label-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
388 | 389 | b.use :html5 |
|
389 | 390 | b.use :placeholder |
|
390 | 391 | b.optional :maxlength |
|
391 | 392 | b.optional :minlength |
|
392 | 393 | b.optional :pattern |
|
393 | 394 | b.optional :min_max |
|
394 | 395 | b.optional :readonly |
|
395 | 396 | b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid' |
|
396 | - b.use :label, class: 'form-control-label' | |
|
397 | + b.use :label | |
|
397 | 398 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
398 | 399 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
399 | 400 | end |
|
400 | 401 | |
|
401 | 402 | # custom multi select |
|
402 | 403 | config.wrappers :floating_labels_select, tag: 'div', class: 'form-label-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b| |
|
403 | 404 | b.use :html5 |
|
404 | 405 | b.optional :readonly |
|
405 |
- b.use :input, class: 'custom-select |
|
|
406 | - b.use :label, class: 'form-control-label' | |
|
406 | + b.use :input, class: 'custom-select', error_class: 'is-invalid', valid_class: 'is-valid' | |
|
407 | + b.use :label | |
|
407 | 408 | b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' } |
|
408 | 409 | b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' } |
|
409 | 410 | end |
|
410 | 411 | |
|
411 | 412 | |
|
412 | 413 | # The default wrapper to be used by the FormBuilder. |
|
413 | 414 | config.default_wrapper = :vertical_form |
|
414 | 415 | |
|
415 | 416 | # Custom wrappers for input types. This should be a hash containing an input |
|
416 | 417 | # type as key and the wrapper that will be used for all inputs with specified type. |
|
417 | 418 | config.wrapper_mappings = { |
|
418 | 419 | boolean: :vertical_boolean, |
|
419 | 420 | check_boxes: :vertical_collection, |
|
420 | 421 | date: :vertical_multi_select, |
|
421 | 422 | datetime: :vertical_multi_select, |
|
422 | 423 | file: :vertical_file, |
|
423 | 424 | radio_buttons: :vertical_collection, |
|
424 | 425 | range: :vertical_range, |
|
425 | 426 | time: :vertical_multi_select |
|
426 | 427 | } |
|
427 | 428 | |
|
428 | 429 | # enable custom form wrappers |
|
429 | 430 | # config.wrapper_mappings = { |
|
430 | 431 | # boolean: :custom_boolean, |
|
431 | 432 | # check_boxes: :custom_collection, |
|
432 | 433 | # date: :custom_multi_select, |
|
433 | 434 | # datetime: :custom_multi_select, |
|
434 | 435 | # file: :custom_file, |
|
435 | 436 | # radio_buttons: :custom_collection, |
|
436 | 437 | # range: :custom_range, |
|
437 | 438 | # time: :custom_multi_select |
|
438 | 439 | # } |
|
439 | 440 | end |
You need to be logged in to leave comments.
Login now