pg_rails 7.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +73 -0
- data/Rakefile +36 -0
- data/app/assets/javascripts/pg_rails/asociacion_creable.js +85 -0
- data/app/assets/javascripts/pg_rails/best_in_place_datepicker.js +58 -0
- data/app/assets/javascripts/pg_rails/librerias.js +13 -0
- data/app/assets/javascripts/pg_rails/librerias_b3.js +14 -0
- data/app/assets/javascripts/pg_rails/validaciones.js +44 -0
- data/app/assets/javascripts/pg_rails.js +318 -0
- data/app/assets/stylesheets/pg_rails/librerias.scss +5 -0
- data/app/assets/stylesheets/pg_rails/pg_chosen.scss +29 -0
- data/app/assets/stylesheets/pg_rails/pg_rails.scss +199 -0
- data/app/assets/stylesheets/pg_rails_b3.scss +10 -0
- data/app/assets/stylesheets/pg_rails_b4.scss +12 -0
- data/app/assets/stylesheets/pg_rails_b5.scss +1 -0
- data/app/controllers/pg_rails/application_controller.rb +316 -0
- data/app/controllers/pg_rails/editar_en_lugar_controller.rb +24 -0
- data/app/decorators/pg_rails/base_decorator.rb +120 -0
- data/app/helpers/pg_rails/editar_en_lugar_helper.rb +106 -0
- data/app/helpers/pg_rails/form_helper.rb +25 -0
- data/app/helpers/pg_rails/postgres_helper.rb +15 -0
- data/app/helpers/pg_rails/print_helper.rb +176 -0
- data/app/inputs/pg_rails/asociacion_creable_input.rb +72 -0
- data/app/inputs/pg_rails/fecha_input.rb +20 -0
- data/app/inputs/pg_rails/selects_dependientes_input.rb +9 -0
- data/app/lib/pg_form_builder.rb +31 -0
- data/app/lib/pg_rails/filtros_builder.rb +338 -0
- data/app/models/pg_rails/application_record.rb +51 -0
- data/app/policies/pg_rails/application_policy.rb +104 -0
- data/app/views/application/_abrir_modal.js.erb +14 -0
- data/app/views/application/_actualizar_smart_listing.html.slim +3 -0
- data/app/views/application/_cerrar_modal.js.erb +8 -0
- data/app/views/application/_modal_ajax_form.js.erb +7 -0
- data/config/brakeman.ignore +42 -0
- data/config/locales/es.yml +17 -0
- data/config/routes.rb +3 -0
- data/config/spring.rb +1 -0
- data/lib/pg_rails/configuracion.rb +24 -0
- data/lib/pg_rails/core_ext.rb +17 -0
- data/lib/pg_rails/engine.rb +42 -0
- data/lib/pg_rails/simple_form/initializer.rb +583 -0
- data/lib/pg_rails/utils/logueador.rb +39 -0
- data/lib/pg_rails/version.rb +5 -0
- data/lib/pg_rails.rb +23 -0
- data/lib/tasks/auto_anotar_modelos.rake +34 -0
- data/lib/tasks/pg_rails_tasks.rake +5 -0
- metadata +89 -0
@@ -0,0 +1,583 @@
|
|
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/rafaelfranca/simple_form-bootstrap
|
6
|
+
# All future development, tests, and organization should happen there.
|
7
|
+
# Background history: https://github.com/plataformatec/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/plataformatec/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
|
+
require 'simple_form'
|
16
|
+
require "#{__dir__}/../../../app/inputs/pg_rails/fecha_input"
|
17
|
+
|
18
|
+
module SimpleForm
|
19
|
+
class FormBuilder < ActionView::Helpers::FormBuilder
|
20
|
+
map_type :date, to: PgRails::FechaInput
|
21
|
+
|
22
|
+
def submit_button(*args, &block)
|
23
|
+
options = args.extract_options!.dup
|
24
|
+
options[:class] = ['btn-primary', options[:class]].compact
|
25
|
+
args << options
|
26
|
+
send(:submit, *args, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Use this setup block to configure all options available in SimpleForm.
|
32
|
+
SimpleForm.setup do |config|
|
33
|
+
# Default class for buttons
|
34
|
+
config.button_class = 'btn'
|
35
|
+
|
36
|
+
# Define the default class of the input wrapper of the boolean input.
|
37
|
+
config.boolean_label_class = 'form-check-label'
|
38
|
+
|
39
|
+
# How the label text should be generated altogether with the required text.
|
40
|
+
config.label_text = ->(label, required, _explicit_label) { "#{label} #{required}" }
|
41
|
+
|
42
|
+
# Define the way to render check boxes / radio buttons with labels.
|
43
|
+
config.boolean_style = :inline
|
44
|
+
|
45
|
+
# You can wrap each item in a collection of radio/check boxes with a tag
|
46
|
+
config.item_wrapper_tag = :div
|
47
|
+
|
48
|
+
# Defines if the default input wrapper class should be included in radio
|
49
|
+
# collection wrappers.
|
50
|
+
config.include_default_input_wrapper_class = false
|
51
|
+
|
52
|
+
# CSS class to add for error notification helper.
|
53
|
+
config.error_notification_class = 'alert alert-danger'
|
54
|
+
|
55
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
56
|
+
# :first lists the first message for each field.
|
57
|
+
# :to_sentence to list all errors for each field.
|
58
|
+
config.error_method = :to_sentence
|
59
|
+
|
60
|
+
# add validation classes to `input_field`
|
61
|
+
config.input_field_error_class = 'is-invalid'
|
62
|
+
config.input_field_valid_class = 'is-valid'
|
63
|
+
|
64
|
+
# vertical forms
|
65
|
+
#
|
66
|
+
# vertical default_wrapper
|
67
|
+
config.wrappers :vertical_form, tag: 'div', class: 'form-group',
|
68
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
69
|
+
b.use :html5
|
70
|
+
b.use :placeholder
|
71
|
+
b.optional :maxlength
|
72
|
+
b.optional :minlength
|
73
|
+
b.optional :pattern
|
74
|
+
b.optional :min_max
|
75
|
+
b.optional :readonly
|
76
|
+
b.use :label, class: 'form-control-label'
|
77
|
+
b.use :input, class: 'form-control'
|
78
|
+
# b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
79
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
80
|
+
end
|
81
|
+
|
82
|
+
# vertical input for boolean
|
83
|
+
config.wrappers :vertical_boolean, tag: 'fieldset', class: 'form-group' do |b|
|
84
|
+
b.use :html5
|
85
|
+
b.optional :readonly
|
86
|
+
b.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb|
|
87
|
+
bb.use :input, class: 'form-check-input'
|
88
|
+
bb.use :label, class: 'form-check-label'
|
89
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
90
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# vertical input for radio buttons and check boxes
|
95
|
+
config.wrappers :vertical_collection, item_wrapper_class: 'form-check', tag: 'fieldset',
|
96
|
+
class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
97
|
+
b.use :html5
|
98
|
+
b.optional :readonly
|
99
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
100
|
+
ba.use :label_text
|
101
|
+
end
|
102
|
+
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
103
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
104
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
105
|
+
end
|
106
|
+
|
107
|
+
# vertical input for inline radio buttons and check boxes
|
108
|
+
config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline',
|
109
|
+
tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
110
|
+
b.use :html5
|
111
|
+
b.optional :readonly
|
112
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
113
|
+
ba.use :label_text
|
114
|
+
end
|
115
|
+
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
116
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
117
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
118
|
+
end
|
119
|
+
|
120
|
+
# vertical file input
|
121
|
+
config.wrappers :vertical_file, tag: 'div', class: 'form-group',
|
122
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
123
|
+
b.use :html5
|
124
|
+
b.use :placeholder
|
125
|
+
b.optional :maxlength
|
126
|
+
b.optional :minlength
|
127
|
+
b.optional :readonly
|
128
|
+
b.use :label
|
129
|
+
b.use :input, class: 'form-control-file', error_class: 'is-invalid', valid_class: 'is-valid'
|
130
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
131
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
132
|
+
end
|
133
|
+
|
134
|
+
# vertical multi select
|
135
|
+
config.wrappers :vertical_multi_select, tag: 'div', class: 'form-group',
|
136
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
137
|
+
b.use :html5
|
138
|
+
b.optional :readonly
|
139
|
+
b.use :label, class: 'form-control-label'
|
140
|
+
b.wrapper tag: 'div',
|
141
|
+
class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
|
142
|
+
ba.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
|
143
|
+
end
|
144
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
145
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
146
|
+
end
|
147
|
+
# vertical multi select
|
148
|
+
config.wrappers :chosen_select, tag: 'div', class: 'form-group',
|
149
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
150
|
+
b.use :html5
|
151
|
+
b.optional :readonly
|
152
|
+
b.use :label, class: 'form-control-label'
|
153
|
+
b.wrapper tag: 'div',
|
154
|
+
class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
|
155
|
+
ba.use :input, class: 'form-control chosen-select mx-1', error_class: 'is-invalid',
|
156
|
+
valid_class: 'is-valid'
|
157
|
+
end
|
158
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
159
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
160
|
+
end
|
161
|
+
|
162
|
+
# vertical multi select
|
163
|
+
config.wrappers :select_7, tag: 'div', class: 'form-group',
|
164
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
165
|
+
b.use :html5
|
166
|
+
b.optional :readonly
|
167
|
+
b.use :label, class: 'form-control-label'
|
168
|
+
b.use :input, class: 'form-select'
|
169
|
+
# b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
170
|
+
# b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
171
|
+
end
|
172
|
+
|
173
|
+
if PgRails.config.bootstrap_version >= 4
|
174
|
+
config.wrappers :asociacion_creable, tag: 'div', class: 'asociacion_creable form-group',
|
175
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
176
|
+
b.use :html5
|
177
|
+
b.optional :readonly
|
178
|
+
b.use :label, class: 'form-control-label'
|
179
|
+
b.wrapper tag: 'div', class: 'input-group' do |ba|
|
180
|
+
ba.use :hidden_input
|
181
|
+
ba.use :input, class: 'form-control', disabled: true
|
182
|
+
ba.wrapper tag: 'div', class: 'input-group-append dropdown' do |append|
|
183
|
+
append.use :boton, class: 'btn btn-outline-secondary dropdown-toggle', type: :button,
|
184
|
+
data: { bs_toggle: :dropdown }
|
185
|
+
append.wrapper class: 'dropdown-menu' do |dropdown|
|
186
|
+
dropdown.use :seleccionar_asociado
|
187
|
+
dropdown.optional :crear_asociado
|
188
|
+
dropdown.use :borrar_seleccion
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
193
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
194
|
+
end
|
195
|
+
else
|
196
|
+
config.wrappers :asociacion_creable, tag: 'div', class: 'asociacion_creable form-group',
|
197
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
198
|
+
b.use :html5
|
199
|
+
b.optional :readonly
|
200
|
+
b.use :label, class: 'form-control-label'
|
201
|
+
b.wrapper tag: 'div', class: 'input-group' do |ba|
|
202
|
+
ba.use :hidden_input
|
203
|
+
ba.use :input, class: 'form-control', disabled: true, error_class: 'is-invalid',
|
204
|
+
valid_class: 'is-valid'
|
205
|
+
ba.wrapper tag: 'div', class: 'input-group-btn' do |append|
|
206
|
+
append.use :boton, class: 'btn btn-default dropdown-toggle', type: :button,
|
207
|
+
data: { toggle: :dropdown }
|
208
|
+
append.wrapper class: 'dropdown-menu' do |dropdown|
|
209
|
+
dropdown.use :seleccionar_asociado
|
210
|
+
dropdown.optional :crear_asociado
|
211
|
+
dropdown.use :borrar_seleccion
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
216
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
config.wrappers :selects_dependientes, tag: 'div', class: 'form-group dependent_fields',
|
221
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
222
|
+
b.use :html5
|
223
|
+
b.optional :readonly
|
224
|
+
b.use :label, class: 'form-control-label'
|
225
|
+
b.wrapper tag: 'div',
|
226
|
+
class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
|
227
|
+
ba.use :input, class: 'form-control mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
|
228
|
+
end
|
229
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
230
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
231
|
+
end
|
232
|
+
|
233
|
+
# vertical range input
|
234
|
+
config.wrappers :vertical_range, tag: 'div', class: 'form-group',
|
235
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
236
|
+
b.use :html5
|
237
|
+
b.use :placeholder
|
238
|
+
b.optional :readonly
|
239
|
+
b.optional :step
|
240
|
+
b.use :label
|
241
|
+
b.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid'
|
242
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
243
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
244
|
+
end
|
245
|
+
|
246
|
+
# horizontal forms
|
247
|
+
#
|
248
|
+
# horizontal default_wrapper
|
249
|
+
config.wrappers :horizontal_form, tag: 'div', class: 'form-group row',
|
250
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
251
|
+
b.use :html5
|
252
|
+
b.use :placeholder
|
253
|
+
b.optional :maxlength
|
254
|
+
b.optional :minlength
|
255
|
+
b.optional :pattern
|
256
|
+
b.optional :min_max
|
257
|
+
b.optional :readonly
|
258
|
+
b.use :label, class: 'col-sm-4 col-form-label text-truncate'
|
259
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-8' do |ba|
|
260
|
+
ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
261
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
262
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# horizontal input for boolean
|
267
|
+
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group row',
|
268
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
269
|
+
b.use :html5
|
270
|
+
b.optional :readonly
|
271
|
+
b.wrapper tag: 'label', class: 'col-sm-3' do |ba|
|
272
|
+
ba.use :label_text
|
273
|
+
end
|
274
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |wr|
|
275
|
+
wr.wrapper :form_check_wrapper, tag: 'div', class: 'form-check' do |bb|
|
276
|
+
bb.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
277
|
+
bb.use :label, class: 'form-check-label'
|
278
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
279
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
# horizontal input for radio buttons and check boxes
|
285
|
+
config.wrappers :horizontal_collection, item_wrapper_class: 'form-check', tag: 'div',
|
286
|
+
class: 'form-group row', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
287
|
+
b.use :html5
|
288
|
+
b.optional :readonly
|
289
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
290
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
291
|
+
ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
292
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
293
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# horizontal input for inline radio buttons and check boxes
|
298
|
+
config.wrappers :horizontal_collection_inline,
|
299
|
+
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|
|
300
|
+
b.use :html5
|
301
|
+
b.optional :readonly
|
302
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
303
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
304
|
+
ba.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
305
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
306
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
# horizontal file input
|
311
|
+
config.wrappers :horizontal_file, tag: 'div', class: 'form-group row',
|
312
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
313
|
+
b.use :html5
|
314
|
+
b.use :placeholder
|
315
|
+
b.optional :maxlength
|
316
|
+
b.optional :minlength
|
317
|
+
b.optional :readonly
|
318
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
319
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
320
|
+
ba.use :input, error_class: 'is-invalid', valid_class: 'is-valid'
|
321
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
322
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
# horizontal multi select
|
327
|
+
config.wrappers :horizontal_multi_select, tag: 'div', class: 'form-group row',
|
328
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
329
|
+
b.use :html5
|
330
|
+
b.optional :readonly
|
331
|
+
b.use :label, class: 'col-sm-3 control-label'
|
332
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
333
|
+
ba.wrapper tag: 'div',
|
334
|
+
class: 'd-flex flex-row justify-content-between align-items-center' do |bb|
|
335
|
+
bb.use :input, class: 'form-control mx-1', error_class: 'is-invalid',
|
336
|
+
valid_class: 'is-valid'
|
337
|
+
end
|
338
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
339
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# horizontal range input
|
344
|
+
config.wrappers :horizontal_range, tag: 'div', class: 'form-group row',
|
345
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
346
|
+
b.use :html5
|
347
|
+
b.use :placeholder
|
348
|
+
b.optional :readonly
|
349
|
+
b.optional :step
|
350
|
+
b.use :label, class: 'col-sm-3 form-control-label'
|
351
|
+
b.wrapper :grid_wrapper, tag: 'div', class: 'col-sm-9' do |ba|
|
352
|
+
ba.use :input, class: 'form-control-range', error_class: 'is-invalid', valid_class: 'is-valid'
|
353
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
354
|
+
ba.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
# inline forms
|
359
|
+
#
|
360
|
+
# inline default_wrapper
|
361
|
+
config.wrappers :inline_form, tag: 'span', error_class: 'form-group-invalid',
|
362
|
+
valid_class: 'form-group-valid' 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.use :label, class: 'sr-only'
|
371
|
+
|
372
|
+
b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
373
|
+
b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
374
|
+
b.optional :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
375
|
+
end
|
376
|
+
|
377
|
+
# inline input for boolean
|
378
|
+
config.wrappers :inline_boolean, tag: 'span',
|
379
|
+
class: 'form-check flex-wrap justify-content-start mr-sm-2', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
380
|
+
b.use :html5
|
381
|
+
b.optional :readonly
|
382
|
+
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
383
|
+
b.use :label, class: 'form-check-label'
|
384
|
+
b.use :error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
385
|
+
b.optional :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
386
|
+
end
|
387
|
+
|
388
|
+
# bootstrap custom forms
|
389
|
+
#
|
390
|
+
# custom input for boolean
|
391
|
+
config.wrappers :custom_boolean, tag: 'fieldset', class: 'form-group',
|
392
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
393
|
+
b.use :html5
|
394
|
+
b.optional :readonly
|
395
|
+
b.wrapper :form_check_wrapper, tag: 'div', class: 'custom-control custom-checkbox' do |bb|
|
396
|
+
bb.use :input, class: 'custom-control-input', error_class: 'is-invalid',
|
397
|
+
valid_class: 'is-valid'
|
398
|
+
bb.use :label, class: 'custom-control-label'
|
399
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
400
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
config.wrappers :custom_boolean_switch, tag: 'fieldset', class: 'form-group',
|
405
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
406
|
+
b.use :html5
|
407
|
+
b.optional :readonly
|
408
|
+
b.wrapper :form_check_wrapper, tag: 'div',
|
409
|
+
class: 'custom-control custom-checkbox-switch' do |bb|
|
410
|
+
bb.use :input, class: 'custom-control-input', error_class: 'is-invalid',
|
411
|
+
valid_class: 'is-valid'
|
412
|
+
bb.use :label, class: 'custom-control-label'
|
413
|
+
bb.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
414
|
+
bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
# custom input for radio buttons and check boxes
|
419
|
+
config.wrappers :custom_collection, item_wrapper_class: 'custom-control', tag: 'fieldset',
|
420
|
+
class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
421
|
+
b.use :html5
|
422
|
+
b.optional :readonly
|
423
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
424
|
+
ba.use :label_text
|
425
|
+
end
|
426
|
+
b.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
427
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
428
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
429
|
+
end
|
430
|
+
|
431
|
+
# custom input for inline radio buttons and check boxes
|
432
|
+
config.wrappers :custom_collection_inline,
|
433
|
+
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|
|
434
|
+
b.use :html5
|
435
|
+
b.optional :readonly
|
436
|
+
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
437
|
+
ba.use :label_text
|
438
|
+
end
|
439
|
+
b.use :input, class: 'custom-control-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
440
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
441
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
442
|
+
end
|
443
|
+
|
444
|
+
# custom file input
|
445
|
+
config.wrappers :custom_file, tag: 'div', class: 'form-group',
|
446
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
447
|
+
b.use :html5
|
448
|
+
b.use :placeholder
|
449
|
+
b.optional :maxlength
|
450
|
+
b.optional :minlength
|
451
|
+
b.optional :readonly
|
452
|
+
b.use :label, class: 'form-control-label'
|
453
|
+
b.wrapper :custom_file_wrapper, tag: 'div', class: 'custom-file' do |ba|
|
454
|
+
ba.use :input, class: 'custom-file-input', error_class: 'is-invalid', valid_class: 'is-valid'
|
455
|
+
ba.use :label, class: 'custom-file-label'
|
456
|
+
ba.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
457
|
+
end
|
458
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
459
|
+
end
|
460
|
+
|
461
|
+
# custom multi select
|
462
|
+
config.wrappers :custom_multi_select, tag: 'div', class: 'form-group',
|
463
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
464
|
+
b.use :html5
|
465
|
+
b.optional :readonly
|
466
|
+
b.use :label, class: 'form-control-label'
|
467
|
+
b.wrapper tag: 'div',
|
468
|
+
class: 'd-flex flex-row justify-content-between align-items-center' do |ba|
|
469
|
+
ba.use :input, class: 'custom-select mx-1', error_class: 'is-invalid', valid_class: 'is-valid'
|
470
|
+
end
|
471
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
472
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
473
|
+
end
|
474
|
+
|
475
|
+
# custom range input
|
476
|
+
config.wrappers :custom_range, tag: 'div', class: 'form-group',
|
477
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
478
|
+
b.use :html5
|
479
|
+
b.use :placeholder
|
480
|
+
b.optional :readonly
|
481
|
+
b.optional :step
|
482
|
+
b.use :label, class: 'form-control-label'
|
483
|
+
b.use :input, class: 'custom-range', error_class: 'is-invalid', valid_class: 'is-valid'
|
484
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
485
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
486
|
+
end
|
487
|
+
|
488
|
+
# Input Group - custom component
|
489
|
+
# see example app and config at https://github.com/rafaelfranca/simple_form-bootstrap
|
490
|
+
# config.wrappers :input_group, tag: 'div', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
491
|
+
# b.use :html5
|
492
|
+
# b.use :placeholder
|
493
|
+
# b.optional :maxlength
|
494
|
+
# b.optional :minlength
|
495
|
+
# b.optional :pattern
|
496
|
+
# b.optional :min_max
|
497
|
+
# b.optional :readonly
|
498
|
+
# b.use :label, class: 'form-control-label'
|
499
|
+
# b.wrapper :input_group_tag, tag: 'div', class: 'input-group' do |ba|
|
500
|
+
# ba.optional :prepend
|
501
|
+
# ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
502
|
+
# ba.optional :append
|
503
|
+
# end
|
504
|
+
# b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
|
505
|
+
# b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
506
|
+
# end
|
507
|
+
|
508
|
+
# Floating Labels form
|
509
|
+
#
|
510
|
+
# floating labels default_wrapper
|
511
|
+
config.wrappers :floating_labels_form, tag: 'div', class: 'form-label-group',
|
512
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
513
|
+
b.use :html5
|
514
|
+
b.use :placeholder
|
515
|
+
b.optional :maxlength
|
516
|
+
b.optional :minlength
|
517
|
+
b.optional :pattern
|
518
|
+
b.optional :min_max
|
519
|
+
b.optional :readonly
|
520
|
+
b.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
|
521
|
+
b.use :label, class: 'form-control-label'
|
522
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
523
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
524
|
+
end
|
525
|
+
|
526
|
+
# custom multi select
|
527
|
+
config.wrappers :floating_labels_select, tag: 'div', class: 'form-label-group',
|
528
|
+
error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
|
529
|
+
b.use :html5
|
530
|
+
b.optional :readonly
|
531
|
+
b.use :input, class: 'custom-select custom-select-lg', error_class: 'is-invalid',
|
532
|
+
valid_class: 'is-valid'
|
533
|
+
b.use :label, class: 'form-control-label'
|
534
|
+
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback' }
|
535
|
+
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
|
536
|
+
end
|
537
|
+
|
538
|
+
# The default wrapper to be used by the FormBuilder.
|
539
|
+
config.default_wrapper = :vertical_form
|
540
|
+
|
541
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
542
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
543
|
+
config.wrapper_mappings = {} if config.wrapper_mappings.nil?
|
544
|
+
config.wrapper_mappings.merge!({
|
545
|
+
boolean: :vertical_boolean,
|
546
|
+
check_boxes: :vertical_collection,
|
547
|
+
date: :vertical_form,
|
548
|
+
datetime: :vertical_multi_select,
|
549
|
+
file: :vertical_file,
|
550
|
+
radio_buttons: :vertical_collection,
|
551
|
+
range: :vertical_range,
|
552
|
+
time: :vertical_multi_select,
|
553
|
+
# select: :chosen_select,
|
554
|
+
asociacion_creable: :asociacion_creable
|
555
|
+
})
|
556
|
+
config.wrapper_mappings.merge!({ 'pg_rails/asociacion_creable' => :asociacion_creable })
|
557
|
+
|
558
|
+
# enable custom form wrappers
|
559
|
+
# config.wrapper_mappings = {
|
560
|
+
# boolean: :custom_boolean,
|
561
|
+
# check_boxes: :custom_collection,
|
562
|
+
# date: :custom_multi_select,
|
563
|
+
# datetime: :custom_multi_select,
|
564
|
+
# file: :custom_file,
|
565
|
+
# radio_buttons: :custom_collection,
|
566
|
+
# range: :custom_range,
|
567
|
+
# time: :custom_multi_select
|
568
|
+
# }
|
569
|
+
|
570
|
+
config.browser_validations = true
|
571
|
+
|
572
|
+
# Collection of methods to detect if a file type was given.
|
573
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ]
|
574
|
+
|
575
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
576
|
+
# to match as key, and the input type that will be used when the field name
|
577
|
+
# matches the regexp as value.
|
578
|
+
# config.input_mappings = { /count/ => :integer }
|
579
|
+
config.input_mappings = {
|
580
|
+
/fecha/ => 'pg_rails/fecha',
|
581
|
+
/date/ => 'pg_rails/fecha'
|
582
|
+
}
|
583
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rainbow'
|
4
|
+
|
5
|
+
module PgRails
|
6
|
+
module Utils
|
7
|
+
class Logueador
|
8
|
+
class << self
|
9
|
+
def excepcion(exception)
|
10
|
+
titulo = Rainbow(" EXCEPCION #{exception.class} en #{caller.first}").red.bold
|
11
|
+
detalles = Rainbow(" #{exception.message}").red
|
12
|
+
Rails.logger.error("#{titulo}\n#{detalles}")
|
13
|
+
Rollbar.error(exception)
|
14
|
+
end
|
15
|
+
|
16
|
+
def error(mensaje)
|
17
|
+
titulo = Rainbow(" ERROR en #{caller.first}").red.bold
|
18
|
+
detalles = Rainbow(" #{mensaje}").red
|
19
|
+
Rails.logger.error("#{titulo}\n#{detalles}")
|
20
|
+
Rollbar.error("#{mensaje}\n\n#{caller.join("\n")}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def warning(mensaje)
|
24
|
+
titulo = Rainbow(" WARNING en #{caller.first}").yellow.bold
|
25
|
+
detalles = Rainbow(" #{mensaje}").yellow
|
26
|
+
Rails.logger.warn("#{titulo}\n#{detalles}")
|
27
|
+
Rollbar.warning("#{mensaje}\n\n#{caller.join("\n")}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def info(mensaje)
|
31
|
+
titulo = Rainbow(" INFO en #{caller.first}").blue.bold
|
32
|
+
detalles = Rainbow(" #{mensaje}").blue
|
33
|
+
Rails.logger.info("#{titulo}\n#{detalles}")
|
34
|
+
Rollbar.info("#{mensaje}\n\n#{caller.join("\n")}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/pg_rails.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pg_rails/engine'
|
4
|
+
require 'pg_rails/core_ext'
|
5
|
+
require 'pg_rails/configuracion'
|
6
|
+
|
7
|
+
module PgRails
|
8
|
+
class << self
|
9
|
+
attr_writer :configuracion
|
10
|
+
|
11
|
+
def configuracion
|
12
|
+
@configuracion ||= Configuracion.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
configuracion
|
17
|
+
end
|
18
|
+
|
19
|
+
def configurar
|
20
|
+
yield(configuracion)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|