pg_rails 7.0.8.pre.alpha.77 → 7.0.8.pre.alpha.78

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: 356134a06d178d1da89941fd57ac424f400adea0d39bfe6a09a635f896380ea2
4
- data.tar.gz: b144d8ab6758ccf469d242a3f14b5ac5b98ee892343053fb49f98ddd2555f87a
3
+ metadata.gz: 871482c5c249da4284c330d128e8f9d3bb456ba55b2b434fd5ae7f7620402643
4
+ data.tar.gz: e12f78759a856ebd5f020f44e744e5d894fa5e5cba3e6fcc97751d3df6eecdaf
5
5
  SHA512:
6
- metadata.gz: 29d1bb1ec81bd9e6a3d11c84ba76a5cdcf03b1f95d4ecee39057bcc358721fa5ae252b511c09bcb7e1cfd6ed7e270ac20efb264eba325a42ce326c6d022234bc
7
- data.tar.gz: 455515106f9dc06e3e1da329b0a7c23eda3da54602b922136b9c54cdd868d629b592098fcce9970c7e11e99aad5b8fdf61a580bdc7a40f332836ebad45bc66dc
6
+ metadata.gz: 2259c319165804262def78cfb9ea6fb60eb9d3ac813b85f2787c9388aa0127dd905019c964b4fece97ca8a193ac514205b1768f51eac850a78c40c8ce7719503
7
+ data.tar.gz: 216652a6d27af8b4f17fffa6799215dd07d2d960483e40141f0d12db189558f1234c77138ed8e3939e9c99112c7b52832d0634bb47e9c73a494097d6d516a227
@@ -14,10 +14,11 @@ module PgAssociable
14
14
  partial = 'pg_associable/resultados_inline'
15
15
  resultados_prefix = 'resultados-inline'
16
16
  query = params[:query]
17
+ timeout_id = params[:timeout_id]
17
18
  @collection = policy_scope(@clase_modelo).kept.query(query).limit(MAX_RESULTS)
18
19
  render turbo_stream:
19
20
  turbo_stream.update("#{resultados_prefix}-#{params[:id]}",
20
- partial:, locals: { collection: @collection, query: })
21
+ partial:, locals: { collection: @collection, query:, timeout_id: })
21
22
  end
22
23
  end
23
24
  end
@@ -79,7 +79,6 @@ export default class extends Controller {
79
79
  if (this.savedInputState && !this.input.value) {
80
80
  this.input.value = this.savedInputState
81
81
  }
82
- this.savedInputState =
83
82
  this.input.select()
84
83
  if (this.input.value.length === 0) {
85
84
  this.escribiAlgo()
@@ -172,6 +171,18 @@ export default class extends Controller {
172
171
  )
173
172
  }
174
173
 
174
+ mostrarError () {
175
+ // TODO: link a contacto
176
+ this.subWrapper.innerHTML = renderToStaticMarkup(
177
+ <div className="resultados" tabIndex={-1}>
178
+ <div className="text-center p-2 text-danger d-flex align-items-center">
179
+ <i className="bi-exclamation-circle me-2"></i>
180
+ Ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.
181
+ </div>
182
+ </div>
183
+ )
184
+ }
185
+
175
186
  setMaxHeight () {
176
187
  let maxHeight
177
188
  if (!this.element.closest('.modal')) {
@@ -218,10 +229,9 @@ export default class extends Controller {
218
229
  }
219
230
 
220
231
  buscando () {
221
- // FIXME: spinner
222
232
  this.subWrapper.innerHTML = renderToStaticMarkup(
223
- <div className="resultados" tabIndex={-1}>
224
- <div className="fst-italic text-secondary px-3">Buscando...</div>
233
+ <div className="resultados text-center p-2" tabIndex={-1}>
234
+ <span className="spinner-border" role="status"></span>
225
235
  </div>
226
236
  )
227
237
  }
@@ -247,16 +257,19 @@ export default class extends Controller {
247
257
  }
248
258
  this.lastValue = this.input.value
249
259
 
250
- this.buscando()
251
- // TODO: hacer bien el clearTimeout con la respuesta del server, ya sea por turbo stream o por cable ready
252
- // IMPORTANTE: además, un timeout por si nunca llega la respuesta
253
- // const timerId = setTimeout(() => {
254
- // this.buscando()
255
- // }, 200)
260
+ const timerBuscandoId = setTimeout(() => {
261
+ this.buscando()
262
+ }, 200)
263
+ const timerErrorId = setTimeout(() => {
264
+ this.mostrarError()
265
+ }, 15000)
266
+ const timeouts = `${timerBuscandoId},${timerErrorId}`
267
+
256
268
  const elem = (
257
269
  <form method="post" action={this.input.dataset.urlSearch} data-turbo-stream="true">
258
270
  <input type="hidden" name="id" value={this.elemId} />
259
271
  <input type="hidden" name="query" value={this.input.value} />
272
+ <input type="hidden" name="timeout_id" value={timeouts} />
260
273
  <input type="hidden" name="puede_crear" value={this.element.dataset.puedeCrear} />
261
274
  </form>
262
275
  )
@@ -271,11 +284,10 @@ export default class extends Controller {
271
284
  const textField = this.element.querySelector('input[type=text]')
272
285
  const hiddenField = this.element.querySelector('input[type=hidden]')
273
286
 
274
- if (target && target.dataset.fieldName)
275
- hiddenField.name = target.dataset.fieldName
287
+ if (target && target.dataset.fieldName) { hiddenField.name = target.dataset.fieldName }
276
288
 
277
289
  if (target) {
278
- let object = JSON.parse(target.dataset.object)
290
+ const object = JSON.parse(target.dataset.object)
279
291
  hiddenField.value = object.id
280
292
  textField.value = object.to_s
281
293
  textField.setAttribute('readonly', 'true')
@@ -1,5 +1,7 @@
1
- / # locals: (collection:, query:, field_name: nil)
1
+ / # locals: (collection:, query:, field_name: nil, timeout_id: nil)
2
2
  .resultados.inline tabindex="-1"
3
+ - if timeout_id.present?
4
+ div data-controller="clear-timeout" data-timeout-id="#{timeout_id}"
3
5
  ul.list-group.list-group-flush
4
6
  - if collection.any?
5
7
  - collection.each do |object|
@@ -53,8 +53,7 @@ module PgEngine
53
53
  end
54
54
  end
55
55
 
56
- # FIXME: default: text: ' Modificar', klass: 'btn-warning')
57
- def edit_link(text: '', klass: 'btn-light')
56
+ def edit_link(text: ' Modificar', klass: 'btn-warning')
58
57
  return unless Pundit.policy!(Current.user, object).edit?
59
58
 
60
59
  helpers.content_tag :span, rel: :tooltip, title: 'Modificar' do
@@ -6,7 +6,9 @@ require 'rainbow'
6
6
 
7
7
  def pg_err(*args)
8
8
  raise args.first if ENV.fetch('RAISE_ERRORS', false) && args.first.is_a?(Exception)
9
- byebug if ENV.fetch('BYEBUG_ERRORS', false)
9
+
10
+ byebug if ENV.fetch('BYEBUG_ERRORS', false) # rubocop:disable Lint/Debugger
11
+
10
12
  pg_log(:error, *args)
11
13
  end
12
14
 
@@ -3,9 +3,11 @@ import { Controller } from '@hotwired/stimulus'
3
3
  // Connects to data-controller="clear-timeout"
4
4
  export default class extends Controller {
5
5
  connect () {
6
- const timeoutId = parseInt(this.element.dataset.timeoutId)
7
- clearTimeout(timeoutId)
8
- console.log(`clearedTimeout: ${timeoutId}`)
6
+ this.element.dataset.timeoutId.split(',').forEach((el) => {
7
+ const timeoutId = parseInt(el)
8
+ clearTimeout(timeoutId)
9
+ console.log(`clearedTimeout: ${timeoutId}`)
10
+ })
9
11
  this.element.remove()
10
12
  }
11
13
  }
@@ -12,7 +12,7 @@ export default class extends Controller {
12
12
  })
13
13
  this.element.querySelectorAll('.btn-check').forEach((slct) => {
14
14
  slct.addEventListener('change', (e) => {
15
- let invalid = e.target.closest('.is-invalid')
15
+ const invalid = e.target.closest('.is-invalid')
16
16
  if (invalid) {
17
17
  invalid.classList.remove('is-invalid')
18
18
  }
@@ -25,7 +25,7 @@ export default class extends Controller {
25
25
  if (!invalidField && !baseAlert) {
26
26
  const errorTitle = this.element.querySelector('.error-title')
27
27
  // TODO!: testear con capybara
28
- errorTitle.innerText = 'Lo lamentamos mucho pero ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.'
28
+ errorTitle.innerText = 'Ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.'
29
29
  // TODO!: link a contacto
30
30
  const form = this.element.querySelector('form')
31
31
  const errorMsg = `${form.id} - ${form.action} - ${form.dataset.errors}`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.77'
4
+ VERSION = '7.0.8-alpha.78'
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.77
4
+ version: 7.0.8.pre.alpha.78
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-21 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -808,6 +808,34 @@ dependencies:
808
808
  - - "~>"
809
809
  - !ruby/object:Gem::Version
810
810
  version: 0.22.0
811
+ - !ruby/object:Gem::Dependency
812
+ name: simplecov-lcov
813
+ requirement: !ruby/object:Gem::Requirement
814
+ requirements:
815
+ - - "~>"
816
+ - !ruby/object:Gem::Version
817
+ version: 0.8.0
818
+ type: :development
819
+ prerelease: false
820
+ version_requirements: !ruby/object:Gem::Requirement
821
+ requirements:
822
+ - - "~>"
823
+ - !ruby/object:Gem::Version
824
+ version: 0.8.0
825
+ - !ruby/object:Gem::Dependency
826
+ name: undercover
827
+ requirement: !ruby/object:Gem::Requirement
828
+ requirements:
829
+ - - "~>"
830
+ - !ruby/object:Gem::Version
831
+ version: 0.5.0
832
+ type: :development
833
+ prerelease: false
834
+ version_requirements: !ruby/object:Gem::Requirement
835
+ requirements:
836
+ - - "~>"
837
+ - !ruby/object:Gem::Version
838
+ version: 0.5.0
811
839
  - !ruby/object:Gem::Dependency
812
840
  name: spring
813
841
  requirement: !ruby/object:Gem::Requirement