pg_rails 7.0.8.pre.alpha.73 → 7.0.8.pre.alpha.75

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: 7fead42e7825fd503115e697fc2c276181f4eaf6accfd783c8ebd463cf5ae278
4
- data.tar.gz: 0ba91edbd93dd46d83a1d2aee3e77aba5d2d2d28d38625ddcce287b8ecb2a59e
3
+ metadata.gz: 46472fd017bf8657e28b3d968159b206c7c2ab8118a4744b5ae887e38c6c0d57
4
+ data.tar.gz: f0ecdadba8aaac1a640c74bc17ce6a182a0b0e4af138e5275d01c35a082b4bf7
5
5
  SHA512:
6
- metadata.gz: e55f215a88c48203ae08aa09b6005a376b3efc2fef02005b4719f19a8927bf8bca0865f663d4f08dc098a75e53dc50707ee111d78a3bfeb2d92e2d202cbdc026
7
- data.tar.gz: a0c3ce96cf9303518e40ba5a4b669db2a0570dff432d30aea65821ceffe2ad10016cc536459a69b819545dad5854b7f49549c1d4c3f615226fa6f235c95453d7
6
+ metadata.gz: 7cc3574cfed47ad618319c9320836ea0a7941c9951226f82cacf20dd885a7d8ba425361fefb53cbd64fb52a7b1af62d681a60da0ba3a8de2bc120977383ca489
7
+ data.tar.gz: 16b08e59ac08a38348d08f88f591d32f2349d5f3baa188235bb57d57352213b3a224364be53a03da371971df4e1ba0f4f91e5b0fc5a9fd9b8deca7c8b5d2a25d
@@ -88,7 +88,7 @@
88
88
  border: 1px solid #a7b7bb;
89
89
  border-top: none;
90
90
  border-radius: 4px;
91
- padding: 5px 11px;
91
+ padding: 5px 0;
92
92
  width: 100%;
93
93
 
94
94
  border-top-left-radius: 0;
@@ -9,6 +9,12 @@ module PgAssociable
9
9
  MAXIMO_PARA_SELECT = 10
10
10
  # TODO: si está entre 10 y 50, habilitar un buscador por js
11
11
 
12
+ def pg_associable_pro(atributo, options = {})
13
+ return input(atributo, options) if options[:disabled]
14
+
15
+ select_pro(atributo, options, nil)
16
+ end
17
+
12
18
  def pg_associable(atributo, options = {})
13
19
  return input(atributo, options) if options[:disabled]
14
20
 
@@ -15,8 +15,8 @@ class PgAssociableInput < SimpleForm::Inputs::StringInput
15
15
 
16
16
  def input(wrapper_options = nil)
17
17
  atributo = attribute_name.to_s.gsub('_id', '')
18
- url_modal = namespaced_path(clase_asociacion(atributo), prefix: :abrir_modal)
19
- url_search = namespaced_path(clase_asociacion(atributo), prefix: :buscar)
18
+ url_modal = options[:modal_url] || namespaced_path(clase_asociacion(atributo), prefix: :abrir_modal)
19
+ url_search = options[:buscar_url] || namespaced_path(clase_asociacion(atributo), prefix: :buscar)
20
20
 
21
21
  input_html_options[:data] = { url_search:, url_modal: }
22
22
  input_html_options[:type] = 'text'
@@ -45,7 +45,8 @@ export default class extends Controller {
45
45
 
46
46
  const input = this.element.querySelector('input[type=text]')
47
47
  this.originalPlaceholder = input.placeholder
48
- if (input.value) {
48
+ const hiddenField = this.element.querySelector('input[type=hidden]')
49
+ if (hiddenField.value) {
49
50
  this.element.classList.add('filled')
50
51
  input.setAttribute('readonly', 'true')
51
52
  }
@@ -64,7 +65,7 @@ export default class extends Controller {
64
65
  }
65
66
  const doSearchBounce = debounce((force) => {
66
67
  this.doSearch(force)
67
- }, 200)
68
+ }, 900)
68
69
 
69
70
  this.input.addEventListener('blur', () => {
70
71
  this.input.placeholder = this.originalPlaceholder
@@ -211,7 +212,7 @@ export default class extends Controller {
211
212
  buscando () {
212
213
  this.subWrapper.innerHTML = renderToStaticMarkup(
213
214
  <div className="resultados" tabIndex={-1}>
214
- <div className="fst-italic text-secondary">Buscando...</div>
215
+ <div className="fst-italic text-secondary px-3">Buscando...</div>
215
216
  </div>
216
217
  )
217
218
  }
@@ -8,4 +8,4 @@
8
8
  data: { action: 'asociable#selectItem',
9
9
  id: object.id, object: object.decorate.to_json }
10
10
  - else
11
- li.list-group-item No hay resultados para "#{query}"
11
+ li.px-3.py-1 No hay resultados para "#{query}"
@@ -102,3 +102,13 @@ input[type=datetime-local], input[type=datetime] {
102
102
  padding: 0.725rem $alert-padding-x;
103
103
  }
104
104
  }
105
+
106
+ // Switcher (ver switcher_controller.js)
107
+ .switcher > * {
108
+ display: none;
109
+ }
110
+
111
+ // Flash
112
+ #flash .alert {
113
+ box-shadow: 0px 9px 13px -3px rgba(0, 0, 0, 0.5);
114
+ }
@@ -32,10 +32,17 @@ module PgEngine
32
32
  end
33
33
 
34
34
  def print_cuit(cuit_number)
35
- return '' if cuit_number.blank?
36
-
37
- str = cuit_number.to_s
38
- "#{str[0..1]}-#{str[2..9]}-#{str[10]}"
35
+ str = cuit_number.to_s.gsub(/[^\d]/, '')
36
+ if str.length == 11
37
+ "#{str[0..1]}-#{str[2..9]}-#{str[10]}"
38
+ else
39
+ cuit_number
40
+ end
41
+ rescue StandardError => e
42
+ # :nocov:
43
+ pg_err e
44
+ cuit_number
45
+ # :nocov:
39
46
  end
40
47
 
41
48
  def dmy_time(date)
@@ -93,10 +100,10 @@ module PgEngine
93
100
  return if number.blank?
94
101
 
95
102
  # TODO!: testear
96
- precision ||= if (number % 0.01).positive?
97
- 3
103
+ precision ||= if (number % 1).positive?
104
+ (number * 100 % 1).positive? ? 3 : 2
98
105
  else
99
- (number % 1).positive? ? 2 : 0
106
+ 0
100
107
  end
101
108
 
102
109
  "#{simbolo} #{number_with_precision(number, delimiter: '.', separator: ',',
@@ -1,11 +1,15 @@
1
1
  - content_for(:title, @clase_modelo.nombre_plural)
2
2
  - content_for :actions do
3
3
  - if @filtros.present?
4
- button.btn.btn-sm.btn-outline-primary[type="button" data-bs-toggle="collapse"
5
- data-bs-target="#filtros" aria-expanded="false"
6
- aria-controls="filtros"]
4
+ button.btn.btn-sm.btn-outline-primary[
5
+ type="button" data-bs-toggle="collapse"
6
+ data-bs-target="#filtros" aria-expanded="#{any_filter? ? 'true' : 'false'}"
7
+ aria-controls="filtros" data-controller="filtros" data-expanded-text="Ocultar filtros"
8
+ ]
7
9
  span.bi.bi-funnel-fill
8
- span.d-none.d-sm-inline Filtrar
10
+ span.d-none.d-sm-inline
11
+ | &nbsp
12
+ span.text Filtrar
9
13
  .ms-1
10
14
  = @clase_modelo.new.decorate.new_link
11
15
 
@@ -20,6 +24,9 @@
20
24
  .col-auto
21
25
  = button_tag class: 'btn btn-sm btn-primary col-auto' do
22
26
  span.bi.bi-search
27
+ span.d-none.d-sm-inline
28
+ | &nbsp
29
+ span.text Buscar
23
30
  .col-auto
24
31
  = link_to namespaced_path(@clase_modelo, clean: true),
25
32
  class: 'btn btn-sm btn-secondary col-auto' do
@@ -0,0 +1,5 @@
1
+ class PgTrgm < ActiveRecord::Migration[7.1]
2
+ def change
3
+ enable_extension "pg_trgm"
4
+ end
5
+ end
@@ -49,6 +49,7 @@ require 'hashid/rails'
49
49
  require 'redis'
50
50
  require 'kredis'
51
51
  require 'mailgun-ruby'
52
+ require 'pg_search'
52
53
 
53
54
  if Rails.env.local?
54
55
  require 'letter_opener'
@@ -0,0 +1,53 @@
1
+ require 'rails_helper'
2
+
3
+ describe PgEngine::PrintHelper do
4
+ describe '#print_cuit' do
5
+ subject { print_cuit(input) }
6
+
7
+ context 'cuando es nil' do
8
+ let(:input) { nil }
9
+
10
+ it { expect(subject).to be_nil }
11
+ end
12
+
13
+ context 'cuando es un cuit válido' do
14
+ let(:input) { 20_351_404_478 }
15
+
16
+ it { expect(subject).to eq '20-35140447-8' }
17
+ end
18
+
19
+ context 'cuando es un cuit válido mal formateado' do
20
+ let(:input) { '2035140447-8' }
21
+
22
+ it { expect(subject).to eq '20-35140447-8' }
23
+ end
24
+
25
+ context 'cuando no es un cuit válido' do
26
+ let(:input) { 2035 }
27
+
28
+ it { expect(subject).to eq 2035 }
29
+ end
30
+ end
31
+
32
+ describe '#print_currency' do
33
+ subject { print_currency(input) }
34
+
35
+ context 'cuando es un entero' do
36
+ let(:input) { 191_624 }
37
+
38
+ it { expect(subject).to eq '$ 191.624' }
39
+ end
40
+
41
+ context 'cuando tiene 1 decimal' do
42
+ let(:input) { 123_456.1 }
43
+
44
+ it { expect(subject).to eq '$ 123.456,10' }
45
+ end
46
+
47
+ context 'cuando tiene más de 3 decimales' do
48
+ let(:input) { 123_456.164234 }
49
+
50
+ it { expect(subject).to eq '$ 123.456,164' }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ // Connects to data-controller="switcher"
4
+ export default class extends Controller {
5
+ originalText = null
6
+ textEl = null
7
+
8
+ connect () {
9
+ this.textEl = this.element.querySelector('.text')
10
+ this.originalText = this.textEl.textContent
11
+ this.element.addEventListener('click', () => { this.cambiarTexto() })
12
+ this.cambiarTexto()
13
+ }
14
+
15
+ cambiarTexto () {
16
+ if (this.element.getAttribute('aria-expanded') === 'true') {
17
+ this.textEl.textContent = this.element.dataset.expandedText
18
+ } else {
19
+ this.textEl.textContent = this.originalText
20
+ }
21
+ }
22
+ }
@@ -5,9 +5,13 @@ import NestedController from './nested_controller'
5
5
  import PgFormController from './pg_form_controller'
6
6
  import FadeinOnloadController from './fadein_onload_controller'
7
7
  import ClearTimeoutController from './clear_timeout_controller'
8
+ import SwitcherController from './switcher_controller'
9
+ import FiltrosController from './filtros_controller'
8
10
 
9
11
  application.register('navbar', NavbarController)
10
12
  application.register('nested', NestedController)
11
13
  application.register('pg_form', PgFormController)
12
14
  application.register('fadein_onload', FadeinOnloadController)
13
15
  application.register('clear-timeout', ClearTimeoutController)
16
+ application.register('switcher', SwitcherController)
17
+ application.register('filtros', FiltrosController)
@@ -0,0 +1,26 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ // Connects to data-controller="switcher"
4
+ export default class extends Controller {
5
+ connect () {
6
+ if (this.element.checked) {
7
+ this.show()
8
+ }
9
+ this.element.setAttribute('data-action', `${this.element.getAttribute('data-action') || ''} switcher#show`)
10
+ }
11
+
12
+ show () {
13
+ const elemToShow = document.querySelector(this.element.dataset.target)
14
+ this.getSiblings(elemToShow).forEach((el) => {
15
+ el.classList.add('d-none')
16
+ el.classList.remove('d-block')
17
+ })
18
+ elemToShow.classList.remove('d-none')
19
+ elemToShow.classList.add('d-block')
20
+ }
21
+
22
+ getSiblings (el) {
23
+ const childrenArray = [...el.parentNode.children]
24
+ return childrenArray.filter(child => child !== el)
25
+ }
26
+ }
@@ -1,4 +1,4 @@
1
- #flash-wrapper.d-flex.justify-content-around
1
+ #flash-wrapper.d-flex.justify-content-around.sticky-top
2
2
  #flash.flash.position-relative.w-100.d-flex.justify-content-center
3
3
  = render partial: 'pg_layout/flash'
4
4
  / TODO: si hay varios flashes toast, se superponen. habría que hacer un container
@@ -1,2 +1,2 @@
1
- <%# Se renderea en el rescue de base_controller %>
2
- <%= render partial: 'pg_layout/error' %>
1
+ <%# Para usar como respuesta con layout en controllers %>
2
+ <%= render partial: 'pg_layout/error', locals: { error_msg: @error_msg } %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.73'
4
+ VERSION = '7.0.8-alpha.75'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.8.pre.alpha.73
4
+ version: 7.0.8.pre.alpha.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-17 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -514,6 +514,20 @@ dependencies:
514
514
  - - "~>"
515
515
  - !ruby/object:Gem::Version
516
516
  version: 1.2.14
517
+ - !ruby/object:Gem::Dependency
518
+ name: pg_search
519
+ requirement: !ruby/object:Gem::Requirement
520
+ requirements:
521
+ - - "~>"
522
+ - !ruby/object:Gem::Version
523
+ version: 2.3.6
524
+ type: :runtime
525
+ prerelease: false
526
+ version_requirements: !ruby/object:Gem::Requirement
527
+ requirements:
528
+ - - "~>"
529
+ - !ruby/object:Gem::Version
530
+ version: 2.3.6
517
531
  - !ruby/object:Gem::Dependency
518
532
  name: vcr
519
533
  requirement: !ruby/object:Gem::Requirement
@@ -1004,6 +1018,7 @@ files:
1004
1018
  - pg_engine/db/migrate/20240314114503_remove_hash_ids.rb
1005
1019
  - pg_engine/db/migrate/20240428152916_create_mensaje_contactos.rb
1006
1020
  - pg_engine/db/migrate/20240506194106_create_emails.rb
1021
+ - pg_engine/db/migrate/20240517174821_pg_trgm.rb
1007
1022
  - pg_engine/db/seeds.rb
1008
1023
  - pg_engine/lib/pg_engine.rb
1009
1024
  - pg_engine/lib/pg_engine/configuracion.rb
@@ -1036,6 +1051,7 @@ files:
1036
1051
  - pg_engine/spec/features/signup_spec.rb
1037
1052
  - pg_engine/spec/fixtures/test.pdf
1038
1053
  - pg_engine/spec/helpers/pg_engine/pg_rails_helper_spec.rb
1054
+ - pg_engine/spec/helpers/pg_engine/print_helper_spec.rb
1039
1055
  - pg_engine/spec/lib/pg_engine/error_helper_spec.rb
1040
1056
  - pg_engine/spec/lib/pg_engine/mailgun/log_sync_spec.rb
1041
1057
  - pg_engine/spec/lib/pg_engine/utils/pg_engine/pg_logger_spec.rb
@@ -1057,10 +1073,12 @@ files:
1057
1073
  - pg_layout/app/javascript/controllers/application.js
1058
1074
  - pg_layout/app/javascript/controllers/clear_timeout_controller.js
1059
1075
  - pg_layout/app/javascript/controllers/fadein_onload_controller.js
1076
+ - pg_layout/app/javascript/controllers/filtros_controller.js
1060
1077
  - pg_layout/app/javascript/controllers/index.js
1061
1078
  - pg_layout/app/javascript/controllers/navbar_controller.js
1062
1079
  - pg_layout/app/javascript/controllers/nested_controller.js
1063
1080
  - pg_layout/app/javascript/controllers/pg_form_controller.js
1081
+ - pg_layout/app/javascript/controllers/switcher_controller.js
1064
1082
  - pg_layout/app/javascript/utils/cookies.js
1065
1083
  - pg_layout/app/javascript/utils/utils.ts
1066
1084
  - pg_layout/app/lib/navbar.rb