custom_table 0.1.0 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -3
- data/Rakefile +0 -0
- data/app/assets/config/custom_table_manifest.js +0 -0
- data/app/assets/stylesheets/custom_table/application.scss +0 -0
- data/app/assets/stylesheets/custom_table/table.scss +52 -1
- data/app/controllers/concerns/custom_table_concern.rb +0 -0
- data/app/controllers/custom_table/application_controller.rb +0 -0
- data/app/controllers/custom_table/settings_controller.rb +2 -0
- data/app/helpers/custom_table/application_helper.rb +71 -20
- data/app/helpers/custom_table/fieldset_helper.rb +5 -4
- data/app/helpers/custom_table/icons_helper.rb +5 -0
- data/app/inputs/date_picker_input.rb +0 -0
- data/app/javascript/controllers/batch_actions_controller.js +34 -10
- data/app/javascript/controllers/table_controller.js +0 -0
- data/app/jobs/custom_table/application_job.rb +0 -0
- data/app/mailers/custom_table/application_mailer.rb +0 -0
- data/app/models/concerns/custom_table_settings.rb +1 -1
- data/app/models/custom_table/application_record.rb +0 -0
- data/app/views/custom_table/_download.haml +0 -0
- data/app/views/custom_table/_field.haml +0 -0
- data/app/views/custom_table/_field_plain.haml +0 -0
- data/app/views/custom_table/_fieldset.haml +0 -0
- data/app/views/custom_table/_filter.html.haml +21 -11
- data/app/views/custom_table/_settings.html.haml +3 -3
- data/app/views/custom_table/_table.html.haml +52 -21
- data/app/views/custom_table/_table.xlsx.axlsx +0 -0
- data/app/views/custom_table/_table_fe.xlsx.fast_excel +0 -0
- data/app/views/custom_table/_table_row.html.haml +16 -4
- data/app/views/custom_table/_table_row_data.html.haml +0 -0
- data/app/views/custom_table/settings/destroy.html.haml +0 -0
- data/app/views/custom_table/settings/edit.html.haml +0 -0
- data/app/views/custom_table/settings/update.html.haml +0 -0
- data/app/views/kaminari/bootstrap-5/_first_page.html.haml +3 -0
- data/app/views/kaminari/bootstrap-5/_last_page.html.haml +3 -0
- data/app/views/kaminari/bootstrap-5/_next_page.html.haml +3 -0
- data/app/views/kaminari/bootstrap-5/_paginator.html.haml +14 -0
- data/app/views/kaminari/bootstrap-5/_prev_page.haml.haml +3 -0
- data/app/views/layouts/custom_table/application.html.erb +0 -0
- data/config/initializers/simple_form_bootstrap.rb +21 -317
- data/config/locales/en.yml +8 -0
- data/config/locales/ru.yml +9 -0
- data/config/routes.rb +0 -0
- data/lib/custom_table/configuration.rb +12 -0
- data/lib/custom_table/engine.rb +0 -0
- data/lib/custom_table/version.rb +1 -1
- data/lib/custom_table.rb +0 -0
- data/lib/generators/custom_table/USAGE +0 -0
- data/lib/generators/custom_table/custom_table_generator.rb +0 -0
- data/lib/generators/custom_table/templates/initializer.rb +0 -0
- data/lib/generators/custom_table/templates/migration.rb +0 -0
- data/lib/tasks/custom_table_tasks.rake +0 -0
- metadata +25 -6
@@ -18,13 +18,17 @@
|
|
18
18
|
|
19
19
|
- fields = fields.except(*local_assigns[:skip_fields]) if !local_assigns[:skip_fields].nil?
|
20
20
|
|
21
|
-
%div.table-wrapper{data: {controller: "batch-actions"}}
|
21
|
+
%div.table-wrapper.overflow-x-lg-scroll{data: {controller: "batch-actions"}, class: (local_assigns[:batch_activator] ? "batch-hidden" : "")}
|
22
22
|
|
23
23
|
- if local_assigns[:batch_actions]
|
24
|
-
|
24
|
+
.batch-actions
|
25
|
+
- if local_assigns[:batch_actions] === true
|
26
|
+
= self.send(:custom_table_batch_actions, model_class)
|
27
|
+
- else
|
28
|
+
= self.send(local_assigns[:batch_actions])
|
25
29
|
|
26
30
|
%table{class: ["search-fields", "custom-table", "table", "table-hover", "table-sm", model_class.model_name.plural], data: {controller: "table toggle"}}
|
27
|
-
%thead.sticky
|
31
|
+
%thead.sticky-lg-top
|
28
32
|
- if local_assigns[:quick_filter]
|
29
33
|
%tr
|
30
34
|
%td{colspan: "100%"}
|
@@ -39,17 +43,25 @@
|
|
39
43
|
- if local_assigns[:tree]
|
40
44
|
%th{style: "width: 15px;"}
|
41
45
|
|
46
|
+
- if local_assigns[:sortable]
|
47
|
+
%th{style: "width: 15px;"}
|
48
|
+
|
42
49
|
- if local_assigns[:with_select]
|
43
50
|
%th.checkbox-col
|
44
51
|
= check_box_tag "check-all", "", true, data: {"toggle-target": "toggler", "action": "toggle#toggle batch-actions#refresh"}
|
45
52
|
- if local_assigns[:with_index]
|
46
53
|
%th= "#"
|
47
|
-
|
54
|
+
|
55
|
+
- fields.each_with_index do |(field, defs), index|
|
48
56
|
- next if defs[:table] == false
|
49
57
|
- cls = [field.to_s]
|
50
58
|
- defs[:amount] = true if defs[:amount].nil? && !model_class.columns_hash[field.to_s].nil? && [:float, :decimal, :integer].include?(model_class.columns_hash[field.to_s].type) && !model_class.defined_enums.has_key?(field.to_s)
|
51
59
|
- cls += ["text-end"] if defs[:amount]
|
52
60
|
%th{class: cls}
|
61
|
+
|
62
|
+
- if local_assigns[:batch_activator] && index==0
|
63
|
+
%input{type: "checkbox", data: {"batch-actions-target": "activator", action: "batch-actions#activate"}}
|
64
|
+
|
53
65
|
- if !defs[:sort].nil? && !@q.nil?
|
54
66
|
- defs[:sort] = {} if defs[:sort]===true
|
55
67
|
- sort_field = defs[:sort][:field].blank? ? field : defs[:sort][:field]
|
@@ -63,7 +75,12 @@
|
|
63
75
|
- if !local_assigns[:skip_actions]
|
64
76
|
%th.text-end
|
65
77
|
|
66
|
-
|
78
|
+
- table_data_tag = {}
|
79
|
+
- table_data_tag["controller"] = "sortable"
|
80
|
+
- table_data_tag["sortable-resource-name-value"] = model_class.model_name.singular
|
81
|
+
- table_data_tag["sortable-handle-value"] = ".sort-handler"
|
82
|
+
|
83
|
+
%tbody{data: table_data_tag}
|
67
84
|
|
68
85
|
- position = 0
|
69
86
|
|
@@ -113,24 +130,34 @@
|
|
113
130
|
- items.each do |item|
|
114
131
|
- custom_table_fields_totals(fields: fields, item: item, totals: local_assigns[:totals], variant: variant, fields_totals: group_fields_totals)
|
115
132
|
%tr
|
116
|
-
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
=
|
127
|
-
|
133
|
+
- if group_fields_totals.values.empty?
|
134
|
+
%th{class: ["text-start", "text-nowrap"], colspan: fields.length}
|
135
|
+
= tree_opener(group_id, true, local_assigns[:expanded])
|
136
|
+
= group.to_s
|
137
|
+
- else
|
138
|
+
- shown = false
|
139
|
+
- fields.each do |field, defs|
|
140
|
+
- next if defs[:table] == false
|
141
|
+
- if !group_fields_totals[field].nil?
|
142
|
+
%th{class: [field.to_s, "text-end"]}
|
143
|
+
= amount_color group_fields_totals[field]
|
144
|
+
- else
|
145
|
+
%th{class: [field.to_s, "text-start"]}
|
146
|
+
- if !shown
|
147
|
+
%span.text-nowrap
|
148
|
+
= tree_opener(group_id, true, local_assigns[:expanded])
|
149
|
+
= render(group) rescue group.to_s
|
150
|
+
- shown = true
|
128
151
|
- if !local_assigns[:skip_actions]
|
129
152
|
%th.text-end
|
153
|
+
- if !local_assigns[:group_actions].nil?
|
154
|
+
= self.send(local_assigns[:group_actions], group)
|
130
155
|
|
131
156
|
- items.each do |item|
|
132
157
|
- position+=1
|
133
|
-
|
158
|
+
- la = local_assigns.merge({item: item, fields: fields, position: position, fields_totals: fields_totals, grouped_by_id: group_id})
|
159
|
+
- la[:expanded] = true if group.nil? # Items without group will be shown anyway
|
160
|
+
= render "custom_table/table_row", la
|
134
161
|
|
135
162
|
- else
|
136
163
|
|
@@ -209,20 +236,24 @@
|
|
209
236
|
|
210
237
|
- if collection.length == 0
|
211
238
|
%tr.warning.text-center
|
212
|
-
%th{:colspan=>"100%"}
|
239
|
+
%th{:colspan=>"100%"}
|
240
|
+
= local_assigns[:no_records_message] || t("custom_table.no_records_found")
|
213
241
|
- else
|
214
242
|
|
215
243
|
- found_totals = custom_table_totals(collection, fields, local_assigns[:totals], fields_totals)
|
216
244
|
|
217
245
|
- if !found_totals.empty?
|
218
246
|
|
219
|
-
%tr.totals{data: {"table-target": "move"}}
|
247
|
+
%tr.totals{data: ((CustomTable.configuration.move_totals_top || local_assigns[:move_totals_top]) ? {"table-target": "move"} : {})}
|
220
248
|
- if local_assigns[:tree]
|
221
249
|
%th
|
222
250
|
|
223
251
|
- if local_assigns[:with_index]
|
224
252
|
%th
|
225
253
|
|
254
|
+
- if local_assigns[:sortable]
|
255
|
+
%td
|
256
|
+
|
226
257
|
- if local_assigns[:with_select]
|
227
258
|
%th
|
228
259
|
|
@@ -245,7 +276,7 @@
|
|
245
276
|
|
246
277
|
- begin
|
247
278
|
- if collection.total_count > 25
|
248
|
-
%nav.float-end.ms-2
|
279
|
+
%nav.float-end.ms-2.d-none.d-sm-block
|
249
280
|
%ul.pagination
|
250
281
|
- [25, 50, 100].each do |p|
|
251
282
|
%li.page-item{class: (collection.limit_value.to_i == p) ? "active" : ""}
|
File without changes
|
File without changes
|
@@ -7,7 +7,10 @@
|
|
7
7
|
- row_class += ["child-of-#{item.parent_id}", (local_assigns[:expanded] ? "" : "d-none")] if local_assigns[:tree] && !item.parent_id.nil?
|
8
8
|
- row_class += ["child-of-#{local_assigns[:grouped_by_id]}", (local_assigns[:expanded] ? "" : "d-none")] if local_assigns[:grouped_by_id]
|
9
9
|
|
10
|
-
|
10
|
+
- tr_data = {}
|
11
|
+
- if local_assigns[:sortable]
|
12
|
+
- tr_data["sortable-update-url"] = url_for(item)
|
13
|
+
%tr{id: dom_id(item, "row"), :class => row_class, data: tr_data }
|
11
14
|
|
12
15
|
- if local_assigns[:tree]
|
13
16
|
%td
|
@@ -15,7 +18,12 @@
|
|
15
18
|
- if local_assigns[:has_children]
|
16
19
|
= tree_opener(item.id, local_assigns[:has_children], local_assigns[:expanded])
|
17
20
|
- else
|
18
|
-
|
21
|
+
%span.ms-2
|
22
|
+
= custom_table_icon(custom_table_tree_child_icon_class)
|
23
|
+
|
24
|
+
- if local_assigns[:sortable]
|
25
|
+
%td
|
26
|
+
%i.fa.fa-grip-vertical.sort-handler.me-2
|
19
27
|
|
20
28
|
- if local_assigns[:with_select]
|
21
29
|
%td.checkbox-col
|
@@ -40,7 +48,10 @@
|
|
40
48
|
%td{class: td_classes, id: dom_id(item, field)}
|
41
49
|
- v = field_value_for(item, field, definitions: defs, variant: variant)
|
42
50
|
|
43
|
-
-
|
51
|
+
- editable_enabled = defs[:editable]
|
52
|
+
- editable_enabled = editable_enabled.call(item) if editable_enabled.respond_to?(:call)
|
53
|
+
|
54
|
+
- if editable_enabled
|
44
55
|
|
45
56
|
= editable item, field do
|
46
57
|
- if defs[:link_to_show] == true && custom_table_has_show_route?(item) && can?(:show, item)
|
@@ -65,7 +76,8 @@
|
|
65
76
|
- elsif self.class.method_defined?("#{model_name}_custom_table_actions")
|
66
77
|
= self.send("#{model_name}_custom_table_actions", item)
|
67
78
|
- if local_assigns[:skip_default_actions].nil?
|
68
|
-
-
|
79
|
+
- local_assigns[:force_edit_button] = true if local_assigns[:force_edit_button].nil? && !custom_table_has_show_route?(item)
|
80
|
+
- if (local_assigns[:force_edit_button]) && can?(:update, item)
|
69
81
|
= custom_table_edit_button [:edit, namespace, local_assigns[:parent], item], id: "edit_#{item.model_name.singular}_#{item.id}", modal: local_assigns[:modal_edit]
|
70
82
|
- if can? :destroy, item
|
71
83
|
- if (Rails.application.routes.recognize_path(url_for([namespace, local_assigns[:parent], item]), :method => :delete) rescue false)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- pagination_class ||= ''
|
2
|
+
- nav_class ||= ''
|
3
|
+
= paginator.render do
|
4
|
+
%nav{:class => nav_class}
|
5
|
+
%ul{:class => "pagination #{pagination_class}"}
|
6
|
+
= first_page_tag unless current_page.first?
|
7
|
+
= prev_page_tag unless current_page.first?
|
8
|
+
- each_page do |page|
|
9
|
+
- if page.left_outer? || page.right_outer? || page.inside_window?
|
10
|
+
= page_tag page
|
11
|
+
- elsif !page.was_truncated?
|
12
|
+
= gap_tag
|
13
|
+
= next_page_tag unless current_page.last?
|
14
|
+
= last_page_tag unless current_page.last?
|
File without changes
|
@@ -10,7 +10,6 @@
|
|
10
10
|
# components.
|
11
11
|
# See https://github.com/heartcombo/simple_form#custom-components
|
12
12
|
# to know more about custom components.
|
13
|
-
Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
|
14
13
|
|
15
14
|
# Use this setup block to configure all options available in SimpleForm.
|
16
15
|
SimpleForm.setup do |config|
|
@@ -46,37 +45,9 @@ SimpleForm.setup do |config|
|
|
46
45
|
#config.input_field_valid_class = 'is-valid'
|
47
46
|
config.input_field_valid_class = '' # Do not need to show valid class
|
48
47
|
|
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
48
|
|
78
49
|
# vertical input for radio buttons and check boxes
|
79
|
-
config.wrappers :
|
50
|
+
config.wrappers :ct_vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
|
80
51
|
b.use :html5
|
81
52
|
b.optional :readonly
|
82
53
|
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
@@ -88,7 +59,7 @@ SimpleForm.setup do |config|
|
|
88
59
|
end
|
89
60
|
|
90
61
|
# vertical input for inline radio buttons and check boxes
|
91
|
-
config.wrappers :
|
62
|
+
config.wrappers :ct_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
63
|
b.use :html5
|
93
64
|
b.optional :readonly
|
94
65
|
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
@@ -99,181 +70,10 @@ SimpleForm.setup do |config|
|
|
99
70
|
b.use :hint, wrap_with: { class: 'form-text' }
|
100
71
|
end
|
101
72
|
|
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
73
|
# inline forms
|
274
74
|
#
|
275
75
|
# inline default_wrapper
|
276
|
-
config.wrappers :
|
76
|
+
config.wrappers :ct_inline_form, class: 'col-6' do |b|
|
277
77
|
b.use :html5
|
278
78
|
b.use :placeholder
|
279
79
|
b.optional :maxlength
|
@@ -289,7 +89,7 @@ SimpleForm.setup do |config|
|
|
289
89
|
end
|
290
90
|
|
291
91
|
# vertical select input
|
292
|
-
config.wrappers :
|
92
|
+
config.wrappers :ct_inline_select, class: 'col-6' do |b|
|
293
93
|
b.use :html5
|
294
94
|
b.optional :readonly
|
295
95
|
b.use :label, class: 'form-label visually-hidden'
|
@@ -299,7 +99,7 @@ SimpleForm.setup do |config|
|
|
299
99
|
end
|
300
100
|
|
301
101
|
# vertical select input
|
302
|
-
config.wrappers :
|
102
|
+
config.wrappers :ct_inline_element, class: 'col-6' do |b|
|
303
103
|
b.use :html5
|
304
104
|
b.optional :readonly
|
305
105
|
b.use :label, class: 'form-label'
|
@@ -309,7 +109,7 @@ SimpleForm.setup do |config|
|
|
309
109
|
end
|
310
110
|
|
311
111
|
# inline input for boolean
|
312
|
-
config.wrappers :
|
112
|
+
config.wrappers :ct_inline_boolean, class: 'col-6' do |b|
|
313
113
|
b.use :html5
|
314
114
|
b.optional :readonly
|
315
115
|
b.wrapper :form_check_wrapper, class: 'form-check' do |bb|
|
@@ -324,7 +124,7 @@ SimpleForm.setup do |config|
|
|
324
124
|
# bootstrap custom forms
|
325
125
|
#
|
326
126
|
# custom input switch for boolean
|
327
|
-
config.wrappers :
|
127
|
+
config.wrappers :ct_custom_boolean_switch, class: 'mb-3' do |b|
|
328
128
|
b.use :html5
|
329
129
|
b.optional :readonly
|
330
130
|
b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check form-switch' do |bb|
|
@@ -337,52 +137,7 @@ SimpleForm.setup do |config|
|
|
337
137
|
|
338
138
|
# Input Group - custom component
|
339
139
|
# see example app and config at https://github.com/heartcombo/simple_form-bootstrap
|
340
|
-
config.wrappers :
|
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|
|
140
|
+
config.wrappers :ct_input_group, class: 'mb-3' do |b|
|
386
141
|
b.use :html5
|
387
142
|
b.use :placeholder
|
388
143
|
b.optional :maxlength
|
@@ -401,68 +156,17 @@ SimpleForm.setup do |config|
|
|
401
156
|
end
|
402
157
|
|
403
158
|
|
404
|
-
#
|
405
|
-
#
|
406
|
-
#
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
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
|
159
|
+
# # Custom wrappers for input types. This should be a hash containing an input
|
160
|
+
# # type as key and the wrapper that will be used for all inputs with specified type.
|
161
|
+
# config.wrapper_mappings = {
|
162
|
+
# boolean: :vertical_boolean,
|
163
|
+
# check_boxes: :vertical_collection,
|
164
|
+
# date: :vertical_multi_select,
|
165
|
+
# datetime: :vertical_multi_select,
|
166
|
+
# file: :vertical_file,
|
167
|
+
# radio_buttons: :vertical_collection,
|
168
|
+
# range: :vertical_range,
|
169
|
+
# time: :vertical_multi_select,
|
170
|
+
# select: :vertical_select
|
171
|
+
# }
|
467
172
|
end
|
468
|
-
SimpleForm::FormBuilder.send :include, WrappedButton
|
data/config/locales/en.yml
CHANGED
@@ -16,3 +16,11 @@ en:
|
|
16
16
|
huge_xlsx_alert: Too many records to download in Excel format. Try %{csv}
|
17
17
|
quick_search: Quick Search
|
18
18
|
download_only_selected_fields: Download selected columns only
|
19
|
+
show_all_filters: Show all filters
|
20
|
+
batch_update: Change selected
|
21
|
+
batch_destroy: Delete selected
|
22
|
+
batch_action_description: Mark fields for changing with check boxes
|
23
|
+
batch_selected_items_count:
|
24
|
+
one: "One item selected for batch update"
|
25
|
+
few: "%{count} items selected for batch update"
|
26
|
+
many: "%{count} items selected for batch update"
|