pg_rails 7.1.2 → 7.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/pg_engine/app/assets/stylesheets/pg_rails_b5.scss +1 -1
- data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +2 -1
- data/pg_engine/app/lib/pg_engine/filtros_builder.rb +16 -13
- data/pg_engine/app/views/pg_engine/base/index.html.slim +3 -1
- data/pg_engine/config/initializers/ransack.rb +48 -0
- data/pg_engine/config/locales/es.yml +3 -0
- data/pg_rails/lib/version.rb +1 -1
- data/pg_rails/scss/pg_rails.scss +5 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97005ad0cfff2f7088c2dbfe667e1fc8339b8873c3935580d374069fdda0c463
|
4
|
+
data.tar.gz: 938afdb82665e744d1c352e5879523329064bb5cadc7c9becdd88bb6aa85505e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce4389f063db55a1761fa50c4335a5b7c98825222b7c541accd5f3e8b4e65c13f9a7ebe3a65787b7c90219f90f11370136faf1efb98f2b2996d9047fc8707e86
|
7
|
+
data.tar.gz: 6a510173f026e874693cc471f9eb251b733164f3cfc1fd72f105b9b556e7cf918962340584e1479d47d130ba723d0c5642a97f3b8097f417c84d7bf495a53c97
|
@@ -318,7 +318,8 @@ module PgEngine
|
|
318
318
|
scope = if scope.model.respond_to? "order_by_#{field}"
|
319
319
|
scope.send "order_by_#{field}", direction
|
320
320
|
else
|
321
|
-
scope.
|
321
|
+
sql = scope.model.arel_table[field.to_sym].send(direction).to_sql + ' nulls last'
|
322
|
+
scope.order(sql)
|
322
323
|
end
|
323
324
|
instance_variable_set(:@field, field)
|
324
325
|
instance_variable_set(:@direction, direction)
|
@@ -7,7 +7,7 @@ module PgEngine
|
|
7
7
|
include PostgresHelper
|
8
8
|
attr_accessor :controller
|
9
9
|
|
10
|
-
SUFIJOS = %w[desde hasta incluye es_igual_a].freeze
|
10
|
+
SUFIJOS = %w[desde hasta incluye es_igual_a in cont eq].freeze
|
11
11
|
|
12
12
|
def initialize(controller, clase_modelo, campos)
|
13
13
|
@clase_modelo = clase_modelo
|
@@ -240,14 +240,12 @@ module PgEngine
|
|
240
240
|
|
241
241
|
def filtro_asociacion(campo, _placeholder = '')
|
242
242
|
asociacion = obtener_asociacion(campo)
|
243
|
-
multiple = asociacion.instance_of?(ActiveRecord::Reflection::HasAndBelongsToManyReflection)
|
244
243
|
nombre_clase = asociacion.options[:class_name]
|
245
244
|
nombre_clase = asociacion.name.to_s.camelize if nombre_clase.nil?
|
246
245
|
clase_asociacion = Object.const_get(nombre_clase)
|
247
246
|
scope = Pundit.policy_scope!(Current.user, clase_asociacion)
|
248
247
|
|
249
|
-
# Filtro soft deleted
|
250
|
-
scope = scope.without_deleted if scope.respond_to?(:without_deleted)
|
248
|
+
# Filtro soft deleted
|
251
249
|
scope = scope.kept if scope.respond_to?(:kept)
|
252
250
|
|
253
251
|
if @filtros[campo.to_sym][:scope_asociacion].present?
|
@@ -258,14 +256,14 @@ module PgEngine
|
|
258
256
|
|
259
257
|
content_tag :div, class: 'col-auto' do
|
260
258
|
content_tag :div, class: 'filter' do
|
261
|
-
|
262
|
-
|
263
|
-
|
259
|
+
placeholder = ransack_placeholder(campo)
|
260
|
+
suf = extraer_sufijo(campo)
|
261
|
+
if suf.in? %w[in]
|
262
|
+
@form.select sin_sufijo(campo) + '_id_in', map, { multiple: true }, placeholder:, 'data-controller': 'selectize',
|
263
|
+
class: 'form-control form-control-sm pg-input-lg'
|
264
264
|
else
|
265
|
-
campo = campo.to_s + '
|
266
|
-
placeholder
|
267
|
-
@form.select campo, map, { multiple: true }, placeholder:, 'data-controller': 'selectize',
|
268
|
-
class: 'form-control form-control-sm pg-input-lg'
|
265
|
+
campo = campo.to_s + '_id_eq'
|
266
|
+
@form.select campo, map, { include_blank: "Seleccionar #{placeholder}" }, class: 'form-select form-select-sm pg-input-lg'
|
269
267
|
end
|
270
268
|
end
|
271
269
|
end
|
@@ -279,7 +277,12 @@ module PgEngine
|
|
279
277
|
content_tag :div, class: 'col-auto' do
|
280
278
|
content_tag :div, class: 'filter' do
|
281
279
|
placeholder = ransack_placeholder(campo)
|
282
|
-
|
280
|
+
suf = extraer_sufijo(campo)
|
281
|
+
if suf.in? %w[in]
|
282
|
+
@form.select(campo, map, { multiple: true }, placeholder:, class: 'form-control form-control-sm pg-input-lg', 'data-controller': 'selectize')
|
283
|
+
else
|
284
|
+
@form.select(campo, map, { include_blank: "Seleccionar #{placeholder}" }, placeholder:, class: 'form-select form-select-sm pg-input-lg')
|
285
|
+
end
|
283
286
|
end
|
284
287
|
end
|
285
288
|
end
|
@@ -337,7 +340,7 @@ module PgEngine
|
|
337
340
|
end
|
338
341
|
|
339
342
|
def ransack_placeholder(campo)
|
340
|
-
@form.object.translate(campo, include_associations:
|
343
|
+
@form.object.translate(campo, include_associations: false)
|
341
344
|
end
|
342
345
|
|
343
346
|
def parametros_controller
|
@@ -21,7 +21,9 @@
|
|
21
21
|
span.bi.bi-funnel-fill
|
22
22
|
= search_form_for @q, url: namespaced_path(@clase_modelo) do |f|
|
23
23
|
.row.g-1
|
24
|
-
|
24
|
+
.col
|
25
|
+
.row.g-1
|
26
|
+
= @filtros.filtros_html(form: f)
|
25
27
|
.col-auto.gap-1.d-flex.align-items-start
|
26
28
|
= button_tag class: 'btn btn-sm btn-primary col-auto' do
|
27
29
|
span.bi.bi-search
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Arel
|
2
|
+
module Predications
|
3
|
+
def matches_unaccent(other, escape = nil, case_sensitive = false)
|
4
|
+
left = Arel::Nodes::NamedFunction.new('unaccent', [self])
|
5
|
+
right = Arel::Nodes::NamedFunction.new('unaccent',
|
6
|
+
[Arel::Nodes::Quoted.new(other)])
|
7
|
+
left.matches(right)
|
8
|
+
end
|
9
|
+
|
10
|
+
def matches_unaccent_any(others, escape = nil, case_sensitive = false)
|
11
|
+
grouping_any :matches_unaccent, others, escape, case_sensitive
|
12
|
+
end
|
13
|
+
|
14
|
+
def matches_unaccent_all(others, escape = nil, case_sensitive = false)
|
15
|
+
grouping_all :matches_unaccent, others, escape, case_sensitive
|
16
|
+
end
|
17
|
+
|
18
|
+
def does_not_match_unaccent(other)
|
19
|
+
left = Arel::Nodes::NamedFunction.new('unaccent', [self])
|
20
|
+
right = Arel::Nodes::NamedFunction.new('unaccent',
|
21
|
+
[Arel::Nodes::Quoted.new(other)])
|
22
|
+
left.does_not_match(right)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Ransack.configure do |config|
|
28
|
+
# Piso predicados cont y not_cont para que usen unaccent
|
29
|
+
config.add_predicate 'cont',
|
30
|
+
arel_predicate: 'matches_unaccent',
|
31
|
+
formatter: proc { |v| "%#{Ransack::Constants.escape_wildcards(v.downcase)}%" },
|
32
|
+
case_insensitive: true
|
33
|
+
|
34
|
+
config.add_predicate 'cont_any',
|
35
|
+
arel_predicate: 'matches_unaccent_any',
|
36
|
+
formatter: proc { |v| v.split(' ').map { "%#{Ransack::Constants.escape_wildcards(_1.downcase)}%" } },
|
37
|
+
case_insensitive: true
|
38
|
+
|
39
|
+
config.add_predicate 'cont_all',
|
40
|
+
arel_predicate: 'matches_unaccent_all',
|
41
|
+
formatter: proc { |v| v.split(' ').map { "%#{Ransack::Constants.escape_wildcards(_1.downcase)}%" } },
|
42
|
+
case_insensitive: true
|
43
|
+
|
44
|
+
config.add_predicate 'not_cont',
|
45
|
+
arel_predicate: 'does_not_match_unaccent',
|
46
|
+
formatter: proc { |v| "%#{Ransack::Constants.escape_wildcards(v.downcase)}%" },
|
47
|
+
case_insensitive: true
|
48
|
+
end
|
data/pg_rails/lib/version.rb
CHANGED
data/pg_rails/scss/pg_rails.scss
CHANGED
@@ -53,6 +53,11 @@ $alert-margin-bottom: 0.5rem;
|
|
53
53
|
.ts-wrapper.multi .ts-control > div {
|
54
54
|
margin: 0!important;
|
55
55
|
}
|
56
|
+
.ts-control:not(.rtl) {
|
57
|
+
padding-right: 0.75rem !important;
|
58
|
+
}
|
59
|
+
|
60
|
+
|
56
61
|
$warning-border-emphasis: shade-color($yellow, 60%);
|
57
62
|
.bg-primary-subtle .btn-warning {
|
58
63
|
border: 1px solid $warning-border-emphasis;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.1.
|
4
|
+
version: 7.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martín Rosso
|
@@ -703,6 +703,7 @@ files:
|
|
703
703
|
- pg_engine/config/initializers/anycable.rb
|
704
704
|
- pg_engine/config/initializers/cable_ready.rb
|
705
705
|
- pg_engine/config/initializers/devise.rb
|
706
|
+
- pg_engine/config/initializers/ransack.rb
|
706
707
|
- pg_engine/config/initializers/rollbar.rb
|
707
708
|
- pg_engine/config/initializers/simple_form_monkey_patch.rb
|
708
709
|
- pg_engine/config/initializers/zeitwerk.rb
|