custom_table 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +210 -0
  3. data/Rakefile +8 -0
  4. data/app/assets/config/custom_table_manifest.js +1 -0
  5. data/app/assets/stylesheets/custom_table/application.scss +1 -0
  6. data/app/assets/stylesheets/custom_table/table.scss +89 -0
  7. data/app/controllers/concerns/custom_table_concern.rb +118 -0
  8. data/app/controllers/custom_table/application_controller.rb +4 -0
  9. data/app/controllers/custom_table/settings_controller.rb +86 -0
  10. data/app/helpers/custom_table/application_helper.rb +483 -0
  11. data/app/helpers/custom_table/fieldset_helper.rb +90 -0
  12. data/app/helpers/custom_table/icons_helper.rb +42 -0
  13. data/app/inputs/date_picker_input.rb +52 -0
  14. data/app/javascript/controllers/batch_actions_controller.js +53 -0
  15. data/app/javascript/controllers/table_controller.js +109 -0
  16. data/app/jobs/custom_table/application_job.rb +4 -0
  17. data/app/mailers/custom_table/application_mailer.rb +6 -0
  18. data/app/models/concerns/custom_table_settings.rb +42 -0
  19. data/app/models/custom_table/application_record.rb +5 -0
  20. data/app/views/custom_table/_download.haml +19 -0
  21. data/app/views/custom_table/_field.haml +8 -0
  22. data/app/views/custom_table/_field_plain.haml +1 -0
  23. data/app/views/custom_table/_fieldset.haml +2 -0
  24. data/app/views/custom_table/_filter.html.haml +104 -0
  25. data/app/views/custom_table/_settings.html.haml +57 -0
  26. data/app/views/custom_table/_table.html.haml +261 -0
  27. data/app/views/custom_table/_table.xlsx.axlsx +76 -0
  28. data/app/views/custom_table/_table_fe.xlsx.fast_excel +141 -0
  29. data/app/views/custom_table/_table_row.html.haml +72 -0
  30. data/app/views/custom_table/_table_row_data.html.haml +26 -0
  31. data/app/views/custom_table/settings/destroy.html.haml +4 -0
  32. data/app/views/custom_table/settings/edit.html.haml +2 -0
  33. data/app/views/custom_table/settings/update.html.haml +4 -0
  34. data/app/views/layouts/custom_table/application.html.erb +15 -0
  35. data/config/initializers/simple_form_bootstrap.rb +468 -0
  36. data/config/locales/en.yml +18 -0
  37. data/config/locales/ru.yml +18 -0
  38. data/config/routes.rb +5 -0
  39. data/lib/custom_table/configuration.rb +10 -0
  40. data/lib/custom_table/engine.rb +12 -0
  41. data/lib/custom_table/version.rb +3 -0
  42. data/lib/custom_table.rb +14 -0
  43. data/lib/generators/custom_table/USAGE +8 -0
  44. data/lib/generators/custom_table/custom_table_generator.rb +16 -0
  45. data/lib/generators/custom_table/templates/initializer.rb +3 -0
  46. data/lib/generators/custom_table/templates/migration.rb +5 -0
  47. data/lib/tasks/custom_table_tasks.rake +4 -0
  48. metadata +300 -0
@@ -0,0 +1,468 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Please do not make direct changes to this file!
4
+ # This generator is maintained by the community around simple_form-bootstrap:
5
+ # https://github.com/heartcombo/simple_form-bootstrap
6
+ # All future development, tests, and organization should happen there.
7
+ # Background history: https://github.com/heartcombo/simple_form/issues/1561
8
+
9
+ # Uncomment this and change the path if necessary to include your own
10
+ # components.
11
+ # See https://github.com/heartcombo/simple_form#custom-components
12
+ # to know more about custom components.
13
+ Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
14
+
15
+ # Use this setup block to configure all options available in SimpleForm.
16
+ SimpleForm.setup do |config|
17
+ # Default class for buttons
18
+ config.button_class = 'btn'
19
+
20
+ # Define the default class of the input wrapper of the boolean input.
21
+ config.boolean_label_class = 'form-check-label'
22
+
23
+ # How the label text should be generated altogether with the required text.
24
+ config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
25
+
26
+ # Define the way to render check boxes / radio buttons with labels.
27
+ config.boolean_style = :inline
28
+
29
+ # You can wrap each item in a collection of radio/check boxes with a tag
30
+ config.item_wrapper_tag = :div
31
+
32
+ # Defines if the default input wrapper class should be included in radio
33
+ # collection wrappers.
34
+ config.include_default_input_wrapper_class = false
35
+
36
+ # CSS class to add for error notification helper.
37
+ config.error_notification_class = 'alert alert-danger'
38
+
39
+ # Method used to tidy up errors. Specify any Rails Array method.
40
+ # :first lists the first message for each field.
41
+ # :to_sentence to list all errors for each field.
42
+ config.error_method = :to_sentence
43
+
44
+ # add validation classes to `input_field`
45
+ config.input_field_error_class = 'is-invalid'
46
+ #config.input_field_valid_class = 'is-valid'
47
+ config.input_field_valid_class = '' # Do not need to show valid class
48
+
49
+ # vertical forms
50
+ #
51
+ # vertical default_wrapper
52
+ config.wrappers :vertical_form, class: 'mb-3' do |b|
53
+ b.use :html5
54
+ b.use :placeholder
55
+ b.optional :maxlength
56
+ b.optional :minlength
57
+ b.optional :pattern
58
+ b.optional :min_max
59
+ b.optional :readonly
60
+ b.use :label, class: 'form-label'
61
+ b.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
62
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
63
+ b.use :hint, wrap_with: { class: 'form-text' }
64
+ end
65
+
66
+ # vertical input for boolean
67
+ config.wrappers :vertical_boolean, tag: 'fieldset', class: 'mb-3' do |b|
68
+ b.use :html5
69
+ b.optional :readonly
70
+ b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
71
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
72
+ bb.use :label, class: 'form-check-label'
73
+ bb.use :full_error, wrap_with: { class: 'invalid-feedback' }
74
+ bb.use :hint, wrap_with: { class: 'form-text' }
75
+ end
76
+ end
77
+
78
+ # vertical input for radio buttons and check boxes
79
+ config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
80
+ b.use :html5
81
+ b.optional :readonly
82
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
83
+ ba.use :label_text
84
+ end
85
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
86
+ b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
87
+ b.use :hint, wrap_with: { class: 'form-text' }
88
+ end
89
+
90
+ # vertical input for inline radio buttons and check boxes
91
+ config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
92
+ b.use :html5
93
+ b.optional :readonly
94
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
95
+ ba.use :label_text
96
+ end
97
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
98
+ b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
99
+ b.use :hint, wrap_with: { class: 'form-text' }
100
+ end
101
+
102
+ # vertical file input
103
+ config.wrappers :vertical_file, class: 'mb-3' do |b|
104
+ b.use :html5
105
+ b.use :placeholder
106
+ b.optional :maxlength
107
+ b.optional :minlength
108
+ b.optional :readonly
109
+ b.use :label, class: 'form-label'
110
+ b.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
111
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
112
+ b.use :hint, wrap_with: { class: 'form-text' }
113
+ end
114
+
115
+ # vertical select input
116
+ config.wrappers :vertical_select, class: 'mb-3' do |b|
117
+ b.use :html5
118
+ b.optional :readonly
119
+ b.use :label, class: 'form-label'
120
+ b.use :input, class: 'form-select', error_class: 'is-invalid'#, valid_class: 'is-valid'
121
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
122
+ b.use :hint, wrap_with: { class: 'form-text' }
123
+ end
124
+
125
+ # vertical select input
126
+ config.wrappers :vertical_date, class: 'mb-3' do |b|
127
+ b.use :html5
128
+ b.optional :readonly
129
+ b.use :label, class: 'form-label'
130
+ b.use :input, class: 'form-date', error_class: 'is-invalid'#, valid_class: 'is-valid'
131
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
132
+ b.use :hint, wrap_with: { class: 'form-text' }
133
+ end
134
+
135
+ # vertical multi select
136
+ config.wrappers :vertical_multi_select, class: 'mb-3' do |b|
137
+ b.use :html5
138
+ b.optional :readonly
139
+ b.use :label, class: 'form-label'
140
+ b.wrapper class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
141
+ ba.use :input, class: 'form-select mx-1', error_class: 'is-invalid'#, valid_class: 'is-valid'
142
+ end
143
+ b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
144
+ b.use :hint, wrap_with: { class: 'form-text' }
145
+ end
146
+
147
+ # vertical range input
148
+ config.wrappers :vertical_range, class: 'mb-3' do |b|
149
+ b.use :html5
150
+ b.use :placeholder
151
+ b.optional :readonly
152
+ b.optional :step
153
+ b.use :label, class: 'form-label'
154
+ b.use :input, class: 'form-range', error_class: 'is-invalid'#, valid_class: 'is-valid'
155
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
156
+ b.use :hint, wrap_with: { class: 'form-text' }
157
+ end
158
+
159
+
160
+ # horizontal forms
161
+ #
162
+ # horizontal default_wrapper
163
+ config.wrappers :horizontal_form, class: 'row mb-3' do |b|
164
+ b.use :html5
165
+ b.use :placeholder
166
+ b.optional :maxlength
167
+ b.optional :minlength
168
+ b.optional :pattern
169
+ b.optional :min_max
170
+ b.optional :readonly
171
+ b.use :label, class: 'col-sm-3 col-form-label'
172
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
173
+ ba.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
174
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
175
+ ba.use :hint, wrap_with: { class: 'form-text' }
176
+ end
177
+ end
178
+
179
+ # horizontal input for boolean
180
+ config.wrappers :horizontal_boolean, class: 'row mb-3' do |b|
181
+ b.use :html5
182
+ b.optional :readonly
183
+ b.wrapper :grid_wrapper, class: 'col-sm-9 offset-sm-3' do |wr|
184
+ wr.wrapper :form_check_wrapper, class: 'form-check' do |bb|
185
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
186
+ bb.use :label, class: 'form-check-label'
187
+ bb.use :full_error, wrap_with: { class: 'invalid-feedback' }
188
+ bb.use :hint, wrap_with: { class: 'form-text' }
189
+ end
190
+ end
191
+ end
192
+
193
+ # horizontal input for radio buttons and check boxes
194
+ config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', class: 'row mb-3' do |b|
195
+ b.use :html5
196
+ b.optional :readonly
197
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
198
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
199
+ ba.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
200
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
201
+ ba.use :hint, wrap_with: { class: 'form-text' }
202
+ end
203
+ end
204
+
205
+ # horizontal input for inline radio buttons and check boxes
206
+ config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', class: 'row mb-3' do |b|
207
+ b.use :html5
208
+ b.optional :readonly
209
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
210
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
211
+ ba.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
212
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
213
+ ba.use :hint, wrap_with: { class: 'form-text' }
214
+ end
215
+ end
216
+
217
+ # horizontal file input
218
+ config.wrappers :horizontal_file, class: 'row mb-3' do |b|
219
+ b.use :html5
220
+ b.use :placeholder
221
+ b.optional :maxlength
222
+ b.optional :minlength
223
+ b.optional :readonly
224
+ b.use :label, class: 'col-sm-3 col-form-label'
225
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
226
+ ba.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
227
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
228
+ ba.use :hint, wrap_with: { class: 'form-text' }
229
+ end
230
+ end
231
+
232
+ # horizontal select input
233
+ config.wrappers :horizontal_select, class: 'row mb-3' do |b|
234
+ b.use :html5
235
+ b.optional :readonly
236
+ b.use :label, class: 'col-sm-3 col-form-label'
237
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
238
+ ba.use :input, class: 'form-select', error_class: 'is-invalid'#, valid_class: 'is-valid'
239
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
240
+ ba.use :hint, wrap_with: { class: 'form-text' }
241
+ end
242
+ end
243
+
244
+ # horizontal multi select
245
+ config.wrappers :horizontal_multi_select, class: 'row mb-3' do |b|
246
+ b.use :html5
247
+ b.optional :readonly
248
+ b.use :label, class: 'col-sm-3 col-form-label'
249
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
250
+ ba.wrapper class: 'd-flex flex-row justify-content-between align-items-center' do |bb|
251
+ bb.use :input, class: 'form-select mx-1', error_class: 'is-invalid'#, valid_class: 'is-valid'
252
+ end
253
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
254
+ ba.use :hint, wrap_with: { class: 'form-text' }
255
+ end
256
+ end
257
+
258
+ # horizontal range input
259
+ config.wrappers :horizontal_range, class: 'row mb-3' do |b|
260
+ b.use :html5
261
+ b.use :placeholder
262
+ b.optional :readonly
263
+ b.optional :step
264
+ b.use :label, class: 'col-sm-3 col-form-label pt-0'
265
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
266
+ ba.use :input, class: 'form-range', error_class: 'is-invalid'#, valid_class: 'is-valid'
267
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
268
+ ba.use :hint, wrap_with: { class: 'form-text' }
269
+ end
270
+ end
271
+
272
+
273
+ # inline forms
274
+ #
275
+ # inline default_wrapper
276
+ config.wrappers :inline_form, class: 'col-12' do |b|
277
+ b.use :html5
278
+ b.use :placeholder
279
+ b.optional :maxlength
280
+ b.optional :minlength
281
+ b.optional :pattern
282
+ b.optional :min_max
283
+ b.optional :readonly
284
+ b.use :label, class: 'visually-hidden'
285
+
286
+ b.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
287
+ b.use :error, wrap_with: { class: 'invalid-feedback' }
288
+ b.optional :hint, wrap_with: { class: 'form-text' }
289
+ end
290
+
291
+ # vertical select input
292
+ config.wrappers :inline_select, class: 'col-12' do |b|
293
+ b.use :html5
294
+ b.optional :readonly
295
+ b.use :label, class: 'form-label visually-hidden'
296
+ b.use :input, class: 'form-select', error_class: 'is-invalid'#, valid_class: 'is-valid'
297
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
298
+ b.use :hint, wrap_with: { class: 'form-text' }
299
+ end
300
+
301
+ # vertical select input
302
+ config.wrappers :inline_element, class: 'col-12' do |b|
303
+ b.use :html5
304
+ b.optional :readonly
305
+ b.use :label, class: 'form-label'
306
+ b.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
307
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
308
+ b.use :hint, wrap_with: { class: 'form-text' }
309
+ end
310
+
311
+ # inline input for boolean
312
+ config.wrappers :inline_boolean, class: 'col-12' do |b|
313
+ b.use :html5
314
+ b.optional :readonly
315
+ b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
316
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
317
+ bb.use :label, class: 'form-check-label'
318
+ bb.use :error, wrap_with: { class: 'invalid-feedback' }
319
+ bb.optional :hint, wrap_with: { class: 'form-text' }
320
+ end
321
+ end
322
+
323
+
324
+ # bootstrap custom forms
325
+ #
326
+ # custom input switch for boolean
327
+ config.wrappers :custom_boolean_switch, class: 'mb-3' do |b|
328
+ b.use :html5
329
+ b.optional :readonly
330
+ b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check form-switch' do |bb|
331
+ bb.use :input, class: 'form-check-input', error_class: 'is-invalid'#, valid_class: 'is-valid'
332
+ bb.use :label, class: 'form-check-label'
333
+ bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
334
+ bb.use :hint, wrap_with: { class: 'form-text' }
335
+ end
336
+ end
337
+
338
+ # Input Group - custom component
339
+ # see example app and config at https://github.com/heartcombo/simple_form-bootstrap
340
+ config.wrappers :horizontal_input_group, class: 'row mb-3' do |b|
341
+ b.use :html5
342
+ b.use :placeholder
343
+ b.optional :maxlength
344
+ b.optional :minlength
345
+ b.optional :pattern
346
+ b.optional :min_max
347
+ b.optional :readonly
348
+ b.use :label, class: 'col-sm-3 col-form-label'
349
+ b.wrapper :grid_wrapper, class: 'col-sm-9' do |ba|
350
+ ba.wrapper :input_group_tag, class: 'input-group' do |ig|
351
+ ig.optional :prepend
352
+ ig.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
353
+ ig.optional :append
354
+ ig.use :full_error, wrap_with: { class: 'invalid-feedback' }
355
+ end
356
+ ba.use :hint, wrap_with: { class: 'form-text' }
357
+ end
358
+ end
359
+
360
+ # Input Group - custom component
361
+ # see example app and config at https://github.com/heartcombo/simple_form-bootstrap
362
+ config.wrappers :floating_input_group, class: 'mb-3' do |b|
363
+ b.use :html5
364
+ b.use :placeholder
365
+ b.optional :maxlength
366
+ b.optional :minlength
367
+ b.optional :pattern
368
+ b.optional :min_max
369
+ b.optional :readonly
370
+ b.wrapper :input_group_tag, class: 'input-group' do |igw|
371
+ igw.optional :prepend
372
+ igw.wrapper :floating_tag, class: 'form-floating flex-1' do |ig|
373
+ ig.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
374
+ ig.use :label
375
+ ig.use :full_error, wrap_with: { class: 'invalid-feedback' }
376
+ end
377
+ igw.optional :append
378
+ end
379
+ b.use :hint, wrap_with: { class: 'form-text' }
380
+ end
381
+
382
+
383
+ # Input Group - custom component
384
+ # see example app and config at https://github.com/heartcombo/simple_form-bootstrap
385
+ config.wrappers :input_group, class: 'mb-3' do |b|
386
+ b.use :html5
387
+ b.use :placeholder
388
+ b.optional :maxlength
389
+ b.optional :minlength
390
+ b.optional :pattern
391
+ b.optional :min_max
392
+ b.optional :readonly
393
+ b.use :label, class: 'form-label'
394
+ b.wrapper :input_group_tag, class: 'input-group' do |ba|
395
+ ba.optional :prepend
396
+ ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
397
+ ba.optional :append
398
+ ba.use :full_error, wrap_with: { class: 'invalid-feedback' }
399
+ end
400
+ b.use :hint, wrap_with: { class: 'form-text' }
401
+ end
402
+
403
+
404
+ # Floating Labels form
405
+ #
406
+ # floating labels default_wrapper
407
+ config.wrappers :floating_labels_form, class: 'form-floating mb-3' do |b|
408
+ b.use :html5
409
+ b.use :placeholder
410
+ b.optional :maxlength
411
+ b.optional :minlength
412
+ b.optional :pattern
413
+ b.optional :min_max
414
+ b.optional :readonly
415
+ b.use :input, class: 'form-control', error_class: 'is-invalid'#, valid_class: 'is-valid'
416
+ b.use :label
417
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
418
+ b.use :hint, wrap_with: { class: 'form-text' }
419
+ end
420
+
421
+ # custom multi select
422
+ config.wrappers :floating_labels_select, class: 'form-floating mb-3' do |b|
423
+ b.use :html5
424
+ b.optional :readonly
425
+ b.use :input, class: 'form-select', error_class: 'is-invalid'#, valid_class: 'is-valid'
426
+ b.use :label
427
+ b.use :full_error, wrap_with: { class: 'invalid-feedback' }
428
+ b.use :hint, wrap_with: { class: 'form-text' }
429
+ end
430
+
431
+
432
+ # The default wrapper to be used by the FormBuilder.
433
+ config.default_wrapper = :vertical_form
434
+
435
+ # Custom wrappers for input types. This should be a hash containing an input
436
+ # type as key and the wrapper that will be used for all inputs with specified type.
437
+ config.wrapper_mappings = {
438
+ boolean: :vertical_boolean,
439
+ check_boxes: :vertical_collection,
440
+ date: :vertical_multi_select,
441
+ datetime: :vertical_multi_select,
442
+ file: :vertical_file,
443
+ radio_buttons: :vertical_collection,
444
+ range: :vertical_range,
445
+ time: :vertical_multi_select,
446
+ select: :vertical_select
447
+ }
448
+ end
449
+
450
+ module WrappedButton
451
+ def wrapped_button(*args, &block)
452
+ template.content_tag :div, :class => "row mb-0" do
453
+ template.content_tag :div, :class => "col-sm-9 offset-sm-3" do
454
+ options = args.extract_options!
455
+ loading = self.object.new_record? ? I18n.t('simple_form.creating') : I18n.t('simple_form.updating')
456
+ options[:"data-disable-with"] = [loading, options[:"data-disable-with"]].compact
457
+ options[:class] = ['btn btn-primary', options[:class]].compact
458
+ args << options
459
+ if cancel = options.delete(:cancel)
460
+ submit(*args, &block) + ' ' + I18n.t('simple_form.buttons.or') + ' ' + template.link_to(I18n.t('simple_form.buttons.cancel'), cancel)
461
+ else
462
+ submit(*args, &block)
463
+ end
464
+ end
465
+ end
466
+ end
467
+ end
468
+ SimpleForm::FormBuilder.send :include, WrappedButton
@@ -0,0 +1,18 @@
1
+ en:
2
+ custom_table:
3
+ customize_table: Choose columns
4
+ customize_table_description: Choose columns you want to see in the table and sort them
5
+ customization_not_allowed: Customization of %{model} table is not allowed
6
+ customization_saved: Table columns customization saved!
7
+ cannot_save_customization: Cannot save customization
8
+ save_settings: Save Settings
9
+ reset_settings: Reset to default
10
+ are_you_sure: Are you sure?
11
+ date_from: from
12
+ date_to: to
13
+ clear_search: Clear search
14
+ no_records_found: No records found
15
+ download_as_csv: Download as CSV
16
+ huge_xlsx_alert: Too many records to download in Excel format. Try %{csv}
17
+ quick_search: Quick Search
18
+ download_only_selected_fields: Download selected columns only
@@ -0,0 +1,18 @@
1
+ ru:
2
+ custom_table:
3
+ customize_table: Настроить колонки
4
+ customize_table_description: Выберите колонки, которые вы хотите видеть в таблице, и отсортируйте порядок их показа
5
+ customization_not_allowed: Настройка таблицы %{model} не предусмотрена
6
+ customization_saved: Настройки таблицы сохранены!
7
+ cannot_save_customization: Ошибка при сохранении настроек таблицы
8
+ save_settings: Сохранить настройки
9
+ reset_settings: Сбросить настройки
10
+ are_you_sure: Вы уверены?
11
+ date_from: от
12
+ date_to: до
13
+ clear_search: Очистить поиск
14
+ no_records_found: Записи не найдены
15
+ download_as_csv: Скачать в CSV
16
+ huge_xlsx_alert: Слишком много записей для экспорта в формате Excel. Попробуйте %{csv}
17
+ quick_search: Быстрый поиск
18
+ download_only_selected_fields: Скачать только выбранные колонки
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ CustomTable::Engine.routes.draw do
2
+
3
+ resources :settings, only: [:edit, :update, :destroy]
4
+
5
+ end
@@ -0,0 +1,10 @@
1
+ module CustomTable
2
+ class Configuration
3
+ attr_accessor :icons_framework
4
+
5
+ def initialize
6
+ @icons_framework = :bi
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ module CustomTable
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CustomTable
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.fixture_replacement :factory_bot
8
+ g.factory_bot dir: 'spec/factories'
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module CustomTable
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "custom_table/version"
2
+ require "custom_table/engine"
3
+ require "custom_table/configuration"
4
+ module CustomTable
5
+
6
+ def self.configuration
7
+ @configuration ||= Configuration.new
8
+ end
9
+
10
+ def self.configure(&block)
11
+ yield(configuration)
12
+ end
13
+
14
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ bin/rails generate custom_table Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,16 @@
1
+
2
+ require 'rails/generators/active_record'
3
+
4
+ class CustomTableGenerator < ActiveRecord::Generators::Base
5
+ include Rails::Generators::Migration
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def copy_initializer_file
9
+ copy_file "initializer.rb", "config/initializers/custom_table.rb"
10
+ end
11
+
12
+ def copy_migration_file
13
+ migration_template "migration.rb", "db/migrate/add_custom_table_to_users.rb"
14
+ end
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ CustomTable.configure do |config|
2
+ config.icons_framework = :bi
3
+ end
@@ -0,0 +1,5 @@
1
+ class AddCustomTableToUsers < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :users, :custom_table, :text
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :custom_table do
3
+ # # Task goes here
4
+ # end