pg_rails 7.1.9 → 7.1.10

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: 27fbc8e577ed0fed33aa886661ef3a3b0af756d2485e0af017eba42bedaed7c6
4
- data.tar.gz: e579a2a15e0dd692d102ee83615ec25f1b641ccc4674b14ca704a41ca93fc11a
3
+ metadata.gz: 671c1939e1e9cae615f0b025c14af1b2c7e25d725782bc28aa7a0416c6b9138b
4
+ data.tar.gz: 9ef68287946ee5aa453beec59bb1ffbcfd6a5acee7bac7c34b993313535b158c
5
5
  SHA512:
6
- metadata.gz: 21ced186a92373d6289c79c364510e65252594fdfd46a514c19cac55f39ce55398323325a5ef2d5ae75d3d462fdca5dafa6bc2d1b5c906538a47faed208a0d83
7
- data.tar.gz: e632afb4c13e2fb01ed5f641acce2efd681b610a96da8ef95ab5d48fed82c896634bd5a049833fef3669e11006db65b98af1fa4c3e2cd440fba72d954598e442
6
+ metadata.gz: 85c0900adc13bfb4955f46da877756864940b6e00e5a3a3f65b9c07d6792b068b5acb5d9baa3fc674bb51ab722f21c826e10c564644d60fae52780214c7c2493
7
+ data.tar.gz: 90a1bdfb038b4c9d0c5004ff854384669aa537e1efa1895c9f4bf9756a2deef9083552a152a870db0e43bf01c48b247ad8e6b10fe051cc40ee838c3b080437dc
@@ -84,6 +84,11 @@ input[type=datetime-local], input[type=datetime] {
84
84
  vertical-align: top;
85
85
  // max-width: 17em;
86
86
  }
87
+ .filter.active {
88
+ .form-select, .form-control {
89
+ background-color: #ffb40157;
90
+ }
91
+ }
87
92
 
88
93
  .filter label {
89
94
  font-size: 0.8em;
@@ -3,7 +3,9 @@
3
3
  module PgEngine
4
4
  module RequireSignIn
5
5
  def self.included(clazz)
6
+ clazz.include RansackMemory::Concern
6
7
  clazz.before_action :authenticate_user!
8
+ clazz.before_action :save_and_load_filters
7
9
  end
8
10
  end
9
11
  end
@@ -231,7 +231,7 @@ module PgEngine
231
231
  map = scope.map { |o| [o.to_s, o.id] }
232
232
 
233
233
  content_tag :div, class: 'col-auto' do
234
- content_tag :div, class: 'filter' do
234
+ content_tag :div, class: "filter #{active_class(campo)}" do
235
235
  suf = extraer_sufijo(campo)
236
236
  if suf.in? %w[in]
237
237
  @form.select campo, map, { multiple: true }, placeholder:, 'data-controller': 'selectize',
@@ -249,7 +249,7 @@ module PgEngine
249
249
  key.value]
250
250
  end
251
251
  content_tag :div, class: 'col-auto' do
252
- content_tag :div, class: 'filter' do
252
+ content_tag :div, class: "filter #{active_class(campo)}" do
253
253
  suf = extraer_sufijo(campo)
254
254
  if suf.in? %w[in]
255
255
  @form.select(campo, map, { multiple: true }, placeholder:, class: 'form-control form-control-sm pg-input-lg', 'data-controller': 'selectize')
@@ -262,7 +262,7 @@ module PgEngine
262
262
 
263
263
  def filtro_texto(campo, placeholder = '')
264
264
  content_tag :div, class: 'col-auto' do
265
- content_tag :div, class: 'filter' do
265
+ content_tag :div, class: "filter #{active_class(campo)}" do
266
266
  @form.search_field(
267
267
  campo, class: 'form-control form-control-sm allow-enter-submit', placeholder:, autocomplete: 'off'
268
268
  )
@@ -276,7 +276,7 @@ module PgEngine
276
276
  include_blank = "¿#{placeholder.titleize}?"
277
277
 
278
278
  content_tag :div, class: 'col-auto' do
279
- content_tag :div, class: 'filter' do
279
+ content_tag :div, class: "filter #{active_class(campo)}" do
280
280
  @form.select campo.to_sym, map, { include_blank: }, class: 'form-select form-select-sm pg-input-lg'
281
281
  end
282
282
  end
@@ -284,7 +284,7 @@ module PgEngine
284
284
 
285
285
  def filtro_fecha(campo, placeholder = '')
286
286
  content_tag :div, class: 'col-auto' do
287
- content_tag :div, class: 'filter' do
287
+ content_tag :div, class: "filter #{active_class(campo)}" do
288
288
  label_tag(nil, placeholder, class: 'text-body-secondary') +
289
289
  @form.date_field(
290
290
  campo, class: 'form-control form-control-sm d-inline-block w-auto ms-1', placeholder:, autocomplete: 'off'
@@ -293,6 +293,15 @@ module PgEngine
293
293
  end
294
294
  end
295
295
 
296
+ def active_class(campo)
297
+ if parametros_controller[:q] &&
298
+ [parametros_controller[:q][campo.to_sym]].flatten.compact_blank.any?
299
+ 'active'
300
+ else
301
+ ''
302
+ end
303
+ end
304
+
296
305
  def parametros_controller
297
306
  params
298
307
  end
@@ -30,9 +30,8 @@
30
30
  span.d-none.d-sm-inline
31
31
  | &nbsp
32
32
  span.text Buscar
33
- = link_to namespaced_path(@clase_modelo, mostrar_filtros: 1),
34
- class: 'btn btn-sm btn-secondary col-auto' do
35
- | Limpiar
33
+ = clear_filter(title: 'Limpiar', class: 'btn btn-sm btn-secondary col-auto')
34
+
36
35
  div
37
36
  - if @collection.any?
38
37
  .table-responsive
@@ -0,0 +1,4 @@
1
+ RansackMemory::Core.config = {
2
+ param: :q, # this means the default Ransack param name for searching. You can change it
3
+ session_key_format: '%controller_name%_%action_name%_%request_format%' # this means how the key used to store the information to the session will be stored. Currently it interpolates request parameters. You can customize it and use these vars to build a key that fits your needs
4
+ }
@@ -52,6 +52,7 @@ require 'mailgun-ruby'
52
52
  require 'pg_search'
53
53
  require 'view_component'
54
54
  require 'noticed'
55
+ require 'ransack_memory'
55
56
 
56
57
  if Rails.env.local?
57
58
  require 'letter_opener'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.1.9'
4
+ VERSION = '7.1.10'
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.9
4
+ version: 7.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
@@ -528,6 +528,20 @@ dependencies:
528
528
  - - "~>"
529
529
  - !ruby/object:Gem::Version
530
530
  version: 2.3.6
531
+ - !ruby/object:Gem::Dependency
532
+ name: ransack_memory
533
+ requirement: !ruby/object:Gem::Requirement
534
+ requirements:
535
+ - - "~>"
536
+ - !ruby/object:Gem::Version
537
+ version: '0.1'
538
+ type: :runtime
539
+ prerelease: false
540
+ version_requirements: !ruby/object:Gem::Requirement
541
+ requirements:
542
+ - - "~>"
543
+ - !ruby/object:Gem::Version
544
+ version: '0.1'
531
545
  - !ruby/object:Gem::Dependency
532
546
  name: view_component
533
547
  requirement: !ruby/object:Gem::Requirement
@@ -704,6 +718,7 @@ files:
704
718
  - pg_engine/config/initializers/cable_ready.rb
705
719
  - pg_engine/config/initializers/devise.rb
706
720
  - pg_engine/config/initializers/ransack.rb
721
+ - pg_engine/config/initializers/ransack_memory.rb
707
722
  - pg_engine/config/initializers/rollbar.rb
708
723
  - pg_engine/config/initializers/simple_form_monkey_patch.rb
709
724
  - pg_engine/config/initializers/zeitwerk.rb