pg_rails 7.1.3 → 7.1.5

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: 3a62b699dfe2595c04b2c1dbde1379411b3ddaa4c49ad54b0a9f66e421b62796
4
- data.tar.gz: 992584663e2439031e7760c9d97971478a8f9a41d4d9d52b01316d81789b3549
3
+ metadata.gz: 0aaf9f6d48a4411856efca24dfbe0e1f27fe03202c2f5fc5f5c45b628f5142e9
4
+ data.tar.gz: a342d47cac9298e1a29ffab6222f7c66cf36aa48c15119330eed2efb258c369d
5
5
  SHA512:
6
- metadata.gz: cd3261127d268f14b9af5c991f66e959ccd3d5a700d500b109003c8a40fdf376ca8a85a9ff18b053fe657bcf4cdabc12d43ee95804f056fc1091d02c80fa7369
7
- data.tar.gz: 5dfc48133fc688bd971d83586b845c78b8222740c598f7919dfc5ad8619aa3d140698c1fae4d869c4df38574fea07256b5921f03d715c196c0223dc9236bc876
6
+ metadata.gz: 4de79ebcc76b2d4d04b0709d18f0ae5106019a16eec4cee8272708b33aba4476980d0563f7c0569bde685638614b91a5ee5197fb750f21bbd10862176ea429e8
7
+ data.tar.gz: 2f3b8bd20aee78bd24133777fd6660a919cfa10b66d581ff13b0a0ce60adae8061401e08966c994aed86bedaa08d5cfbc4bcb90c4d07217c39f3a3654e7d58ba
@@ -80,6 +80,19 @@ input[type=datetime-local], input[type=datetime] {
80
80
  // max-width: 17em;
81
81
  }
82
82
 
83
+ .filter label {
84
+ font-size: 0.8em;
85
+ font-weight: bold;
86
+ max-width: 5em;
87
+ text-align: right;
88
+ line-height: 1.2em;
89
+ vertical-align: middle;
90
+ opacity: 0.5;
91
+ min-width: 1em!important;
92
+ padding-left: 0.5em;
93
+ width: min-content;
94
+ }
95
+
83
96
  // Modal
84
97
  .modal-content {
85
98
  box-shadow: 15px 15px 9px 0px rgba(0, 0, 0, 0.6);
@@ -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.order("#{field} #{direction} nulls last")
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)
@@ -91,7 +91,7 @@ module PgEngine
91
91
  end
92
92
 
93
93
  if Current.user.present?
94
- @notifications = Current.user.notifications.order(id: :desc)
94
+ @notifications = Current.user.notifications.order(id: :desc).includes(:event)
95
95
  .where(type: 'SimpleUserNotifier::Notification')
96
96
  unseen = @notifications.unseen.any?
97
97
  # FIXME: testear y fixear, buscar el primero que esté present
@@ -6,6 +6,9 @@ module PgEngine
6
6
  campo = campo.to_s.sub(/_f\z/, '')
7
7
  campo = campo.to_s.sub(/_text\z/, '')
8
8
  clase = options[:clase] || @clase_modelo
9
+ key = [controller_name, action_name, 'listado_header', campo].join('.')
10
+ dflt = :"activerecord.attributes.#{clase.model_name.i18n_key}.#{campo}"
11
+ human_name = clase.human_attribute_name(key, default: dflt)
9
12
  if options[:ordenable]
10
13
  field = controller.instance_variable_get(:@field)
11
14
  direction = controller.instance_variable_get(:@direction)
@@ -35,9 +38,9 @@ module PgEngine
35
38
 
36
39
  uri.query = cgi.transform_values { |b| (b.length == 1 ? b.first : b) }.to_query
37
40
 
38
- link_to(clase.human_attribute_name(campo), uri.to_s) + " #{symbol}".html_safe
41
+ link_to(human_name, uri.to_s) + " #{symbol}".html_safe
39
42
  else
40
- clase.human_attribute_name(campo)
43
+ human_name
41
44
  end
42
45
  end
43
46
  end
@@ -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 in cont eq].freeze
10
+ SUFIJOS = %w[desde hasta gt gte lt lte incluye es_igual_a in cont cont_all eq].freeze
11
11
 
12
12
  def initialize(controller, clase_modelo, campos)
13
13
  @clase_modelo = clase_modelo
@@ -178,10 +178,13 @@ module PgEngine
178
178
 
179
179
  def placeholder_campo(campo)
180
180
  suf = extraer_sufijo(campo)
181
+ key = [controller_name, action_name, 'filter', sin_sufijo(campo)].join('.')
182
+ dflt = :"activerecord.attributes.#{@clase_modelo.model_name.i18n_key}.#{sin_sufijo(campo)}"
183
+ humann = @clase_modelo.human_attribute_name(key, default: dflt)
181
184
  if suf.present?
182
- "#{@clase_modelo.human_attribute_name(sin_sufijo(campo))} #{suf}"
185
+ "#{humann} #{I18n.t(suf, scope: 'ransack.predicates')}".strip.tap { _1[0] = _1[0].capitalize }
183
186
  else
184
- @clase_modelo.human_attribute_name(campo)
187
+ humann
185
188
  end
186
189
  end
187
190
 
@@ -238,7 +241,7 @@ module PgEngine
238
241
  end
239
242
  end
240
243
 
241
- def filtro_asociacion(campo, _placeholder = '')
244
+ def filtro_asociacion(campo, placeholder = '')
242
245
  asociacion = obtener_asociacion(campo)
243
246
  nombre_clase = asociacion.options[:class_name]
244
247
  nombre_clase = asociacion.name.to_s.camelize if nombre_clase.nil?
@@ -256,7 +259,7 @@ module PgEngine
256
259
 
257
260
  content_tag :div, class: 'col-auto' do
258
261
  content_tag :div, class: 'filter' do
259
- placeholder = ransack_placeholder(campo)
262
+ # placeholder = ransack_placeholder(campo)
260
263
  suf = extraer_sufijo(campo)
261
264
  if suf.in? %w[in]
262
265
  @form.select sin_sufijo(campo) + '_id_in', map, { multiple: true }, placeholder:, 'data-controller': 'selectize',
@@ -276,7 +279,7 @@ module PgEngine
276
279
  end
277
280
  content_tag :div, class: 'col-auto' do
278
281
  content_tag :div, class: 'filter' do
279
- placeholder = ransack_placeholder(campo)
282
+ # placeholder = ransack_placeholder(campo)
280
283
  suf = extraer_sufijo(campo)
281
284
  if suf.in? %w[in]
282
285
  @form.select(campo, map, { multiple: true }, placeholder:, class: 'form-control form-control-sm pg-input-lg', 'data-controller': 'selectize')
@@ -305,7 +308,7 @@ module PgEngine
305
308
  def filtro_texto(campo, placeholder = '')
306
309
  content_tag :div, class: 'col-auto' do
307
310
  content_tag :div, class: 'filter' do
308
- placeholder = ransack_placeholder(campo)
311
+ # placeholder = ransack_placeholder(campo)
309
312
  @form.search_field(
310
313
  campo, class: 'form-control form-control-sm allow-enter-submit', placeholder:, autocomplete: 'off'
311
314
  )
@@ -330,7 +333,7 @@ module PgEngine
330
333
  def filtro_fecha(campo, placeholder = '')
331
334
  content_tag :div, class: 'col-auto' do
332
335
  content_tag :div, class: 'filter' do
333
- placeholder = ransack_placeholder(campo)
336
+ # placeholder = ransack_placeholder(campo)
334
337
  label_tag(nil, placeholder, class: 'text-body-secondary') +
335
338
  @form.date_field(
336
339
  campo, class: 'form-control form-control-sm d-inline-block w-auto ms-1', placeholder:, autocomplete: 'off'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.1.3'
4
+ VERSION = '7.1.5'
5
5
  end
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.3
4
+ version: 7.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso