pg_rails 7.1.1.pre.6 → 7.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b95efca3ae2b2ec3c5779300bbfd6cc00ba9cac453b4fd07395803eb5010a726
4
- data.tar.gz: 87811da5c11b5ec8bfb15e45e8b43ed5c606bceb23804bc473990f9f46ab13ed
3
+ metadata.gz: 3a62b699dfe2595c04b2c1dbde1379411b3ddaa4c49ad54b0a9f66e421b62796
4
+ data.tar.gz: 992584663e2439031e7760c9d97971478a8f9a41d4d9d52b01316d81789b3549
5
5
  SHA512:
6
- metadata.gz: 4da052d189d685cd90c2aed939bfebd8d3e4809f6e3db671d686a034d597b32b03a2f52f3b3413c9277566329822cbf4a520ab33531cc40ef8873a2b8c51850a
7
- data.tar.gz: fddd0362fab8db6f74816b583372fbc10fbd4d6ad68f48adbbe635579b28339603e1f09358a16563d9d9e6909573009ec6111c84f50d9c28f109758e402f6495
6
+ metadata.gz: cd3261127d268f14b9af5c991f66e959ccd3d5a700d500b109003c8a40fdf376ca8a85a9ff18b053fe657bcf4cdabc12d43ee95804f056fc1091d02c80fa7369
7
+ data.tar.gz: 5dfc48133fc688bd971d83586b845c78b8222740c598f7919dfc5ad8619aa3d140698c1fae4d869c4df38574fea07256b5921f03d715c196c0223dc9236bc876
@@ -77,7 +77,7 @@ input[type=datetime-local], input[type=datetime] {
77
77
  .filter {
78
78
  display: inline-block;
79
79
  vertical-align: top;
80
- max-width: 17em;
80
+ // max-width: 17em;
81
81
  }
82
82
 
83
83
  // Modal
@@ -318,7 +318,7 @@ 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.order(field => direction)
321
+ scope.order("#{field} #{direction} nulls last")
322
322
  end
323
323
  instance_variable_set(:@field, field)
324
324
  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, y sea con paranoia o con discard
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
- if multiple
262
- @form.select campo, map, { multiple: true }, 'data-controller': 'selectize',
263
- class: 'form-select form-select-sm pg-input-lg'
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 + '_id_in'
266
- placeholder = ransack_placeholder(campo)
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
- @form.select(campo, map, { multiple: true }, placeholder:, class: 'form-control form-control-sm pg-input-lg', 'data-controller': 'selectize')
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: true)
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
- = @filtros.filtros_html(form: f)
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
@@ -2,8 +2,11 @@ es:
2
2
  ransack:
3
3
  predicates:
4
4
  cont: ''
5
+ cont_all: ''
5
6
  in: ''
6
7
  eq: ''
8
+ lt: 'hasta'
9
+ gt: 'desde'
7
10
  pg_engine:
8
11
  base:
9
12
  index:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.1.1-6'
4
+ VERSION = '7.1.3'
5
5
  end
@@ -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.1.pre.6
4
+ version: 7.1.3
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