pg_rails 7.1.9 → 7.1.11

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: 0f6553a59df0df7aeb2906baac1974c3f2ef6f5b17bd83f4df1b4fbf3f7f2819
4
+ data.tar.gz: 20e9aa024c6aebb771ebea3c3b852a2e47a6d7583d043bcbc750d3ec2642e336
5
5
  SHA512:
6
- metadata.gz: 21ced186a92373d6289c79c364510e65252594fdfd46a514c19cac55f39ce55398323325a5ef2d5ae75d3d462fdca5dafa6bc2d1b5c906538a47faed208a0d83
7
- data.tar.gz: e632afb4c13e2fb01ed5f641acce2efd681b610a96da8ef95ab5d48fed82c896634bd5a049833fef3669e11006db65b98af1fa4c3e2cd440fba72d954598e442
6
+ metadata.gz: b5b1ff627eeff7269b53d81a2b8d39184118741001cb4d36d89eba76801910315551ef563d55216f5a2e5b372b7afd3ff66ef7a4bae8428f94b20a28004c727b
7
+ data.tar.gz: c7af654f04ac7fba7d48e9c220f9396bb5ab24508350035447c792f0fd0afe213ccb529ed5360db4e1baa4f27cd5cbf387d6f3b4a71877edccf10395359fc8a6
@@ -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;
@@ -0,0 +1,17 @@
1
+ - if helpers.show_filters?
2
+ .border-bottom#filtros
3
+ .d-flex.align-items-center.px-3.py-2
4
+ .px-2.d-none.d-sm-inline-block
5
+ span.bi.bi-funnel-fill
6
+ = helpers.search_form_for @q, url: url_for do |f|
7
+ .row.g-1
8
+ .col
9
+ .row.g-1
10
+ = @builder.filtros_html(form: f)
11
+ .col-auto.gap-1.d-flex.align-items-start
12
+ = helpers.button_tag class: 'btn btn-sm btn-primary col-auto' do
13
+ span.bi.bi-search
14
+ span.d-none.d-sm-inline
15
+ | &nbsp
16
+ span.text Buscar
17
+ = helpers.clear_filter(title: 'Limpiar', class: 'btn btn-sm btn-secondary col-auto')
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SearchBarComponent < ViewComponent::Base
4
+ def initialize(ransack, filtros)
5
+ @q = ransack
6
+ @builder = filtros
7
+
8
+ super
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ - if helpers.show_filters?
2
+ = link_to url_for(ocultar_filtros: 1, cancel_filter: 'true'),
3
+ class: 'btn btn-sm btn-outline-primary col-auto' do
4
+ | Ocultar filtros
5
+ - else
6
+ = link_to url_for(mostrar_filtros: 1),
7
+ class: 'btn btn-sm btn-outline-primary col-auto' do
8
+ | Filtrar
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SearchBarTogglerComponent < ViewComponent::Base
4
+ end
@@ -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
@@ -3,36 +3,13 @@
3
3
  - @actions&.each do |link_args|
4
4
  = link_to(*link_args)
5
5
  - if @filtros.present?
6
- - if show_filters?
7
- = link_to namespaced_path(@clase_modelo, ocultar_filtros: 1),
8
- class: 'btn btn-sm btn-outline-primary col-auto' do
9
- | Ocultar filtros
10
- - else
11
- = link_to namespaced_path(@clase_modelo, mostrar_filtros: 1),
12
- class: 'btn btn-sm btn-outline-primary col-auto' do
13
- | Filtrar
6
+ = render SearchBarTogglerComponent.new
14
7
  .ms-1
15
8
  = @clase_modelo.new.decorate.new_link
16
9
 
17
- - if @filtros.present? && show_filters?
18
- .border-bottom#filtros
19
- .d-flex.align-items-center.px-3.py-2
20
- .px-2.d-none.d-sm-inline-block
21
- span.bi.bi-funnel-fill
22
- = search_form_for @q, url: namespaced_path(@clase_modelo) do |f|
23
- .row.g-1
24
- .col
25
- .row.g-1
26
- = @filtros.filtros_html(form: f)
27
- .col-auto.gap-1.d-flex.align-items-start
28
- = button_tag class: 'btn btn-sm btn-primary col-auto' do
29
- span.bi.bi-search
30
- span.d-none.d-sm-inline
31
- | &nbsp
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
10
+ - if @filtros.present?
11
+ = render SearchBarComponent.new(@q, @filtros)
12
+
36
13
  div
37
14
  - if @collection.any?
38
15
  .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
+ }
@@ -0,0 +1,3 @@
1
+ Rails.application.configure do
2
+ config.view_component.capture_compatibility_patch_enabled = true
3
+ end
@@ -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.11'
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.11
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
@@ -603,6 +617,10 @@ files:
603
617
  - pg_engine/app/components/notification_component.rb
604
618
  - pg_engine/app/components/notifications_bell_component.rb
605
619
  - pg_engine/app/components/page_not_found_component.rb
620
+ - pg_engine/app/components/search_bar_component.html.slim
621
+ - pg_engine/app/components/search_bar_component.rb
622
+ - pg_engine/app/components/search_bar_toggler_component.html.slim
623
+ - pg_engine/app/components/search_bar_toggler_component.rb
606
624
  - pg_engine/app/controllers/admin/accounts_controller.rb
607
625
  - pg_engine/app/controllers/admin/email_logs_controller.rb
608
626
  - pg_engine/app/controllers/admin/emails_controller.rb
@@ -704,8 +722,10 @@ files:
704
722
  - pg_engine/config/initializers/cable_ready.rb
705
723
  - pg_engine/config/initializers/devise.rb
706
724
  - pg_engine/config/initializers/ransack.rb
725
+ - pg_engine/config/initializers/ransack_memory.rb
707
726
  - pg_engine/config/initializers/rollbar.rb
708
727
  - pg_engine/config/initializers/simple_form_monkey_patch.rb
728
+ - pg_engine/config/initializers/view_component.rb
709
729
  - pg_engine/config/initializers/zeitwerk.rb
710
730
  - pg_engine/config/locales/devise.en.yml
711
731
  - pg_engine/config/locales/es.yml