pg_rails 7.0.8.pre.alpha.74 → 7.0.8.pre.alpha.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1be4c79ea65550474a25d90dfe6350776ee4729e1606fc4a33f9b2d510c00f6e
4
- data.tar.gz: 2455fe21d800515773fc24a930e2ef78d79ce05ebda5e579ca900b7c6ab9e8c6
3
+ metadata.gz: 46472fd017bf8657e28b3d968159b206c7c2ab8118a4744b5ae887e38c6c0d57
4
+ data.tar.gz: f0ecdadba8aaac1a640c74bc17ce6a182a0b0e4af138e5275d01c35a082b4bf7
5
5
  SHA512:
6
- metadata.gz: 5dec9355d0371042c062dd6b90ae6306196965ef7c41ed59e672dddd38f658b2428e230f1c3e6ed82b4cb1e82657f48b7372b1b05c7d7062ccbc07cac903c711
7
- data.tar.gz: 135d91aed0d9fdfe6e7aaa61d98a8cc2773516a6649eca3a65ee5fe2b49b563879276143ee49f4228605fc7caea8bc9cb1ef5a25fed54624dad73c9ef7006aad
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;
@@ -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
@@ -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.74'
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.74
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
@@ -1051,6 +1051,7 @@ files:
1051
1051
  - pg_engine/spec/features/signup_spec.rb
1052
1052
  - pg_engine/spec/fixtures/test.pdf
1053
1053
  - pg_engine/spec/helpers/pg_engine/pg_rails_helper_spec.rb
1054
+ - pg_engine/spec/helpers/pg_engine/print_helper_spec.rb
1054
1055
  - pg_engine/spec/lib/pg_engine/error_helper_spec.rb
1055
1056
  - pg_engine/spec/lib/pg_engine/mailgun/log_sync_spec.rb
1056
1057
  - pg_engine/spec/lib/pg_engine/utils/pg_engine/pg_logger_spec.rb
@@ -1072,10 +1073,12 @@ files:
1072
1073
  - pg_layout/app/javascript/controllers/application.js
1073
1074
  - pg_layout/app/javascript/controllers/clear_timeout_controller.js
1074
1075
  - pg_layout/app/javascript/controllers/fadein_onload_controller.js
1076
+ - pg_layout/app/javascript/controllers/filtros_controller.js
1075
1077
  - pg_layout/app/javascript/controllers/index.js
1076
1078
  - pg_layout/app/javascript/controllers/navbar_controller.js
1077
1079
  - pg_layout/app/javascript/controllers/nested_controller.js
1078
1080
  - pg_layout/app/javascript/controllers/pg_form_controller.js
1081
+ - pg_layout/app/javascript/controllers/switcher_controller.js
1079
1082
  - pg_layout/app/javascript/utils/cookies.js
1080
1083
  - pg_layout/app/javascript/utils/utils.ts
1081
1084
  - pg_layout/app/lib/navbar.rb