pg_rails 7.0.8.pre.alpha.77 → 7.0.8.pre.alpha.79

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: 356134a06d178d1da89941fd57ac424f400adea0d39bfe6a09a635f896380ea2
4
- data.tar.gz: b144d8ab6758ccf469d242a3f14b5ac5b98ee892343053fb49f98ddd2555f87a
3
+ metadata.gz: d09fbc215c11289297d4f68d0c757492382490591e45e555ad6bd9347dd5a48f
4
+ data.tar.gz: 31677fedfd7ff1eb0d02fdaf038f1b97995b979d96ba066ba4bad6f2c87a60ab
5
5
  SHA512:
6
- metadata.gz: 29d1bb1ec81bd9e6a3d11c84ba76a5cdcf03b1f95d4ecee39057bcc358721fa5ae252b511c09bcb7e1cfd6ed7e270ac20efb264eba325a42ce326c6d022234bc
7
- data.tar.gz: 455515106f9dc06e3e1da329b0a7c23eda3da54602b922136b9c54cdd868d629b592098fcce9970c7e11e99aad5b8fdf61a580bdc7a40f332836ebad45bc66dc
6
+ metadata.gz: 52cc06a4a2e3843abc3fbe5344bc913276556c8bbc9f0945f10843c188ad92e92e02955738715a18e4f09526e4759d0db716fef414941a086eda36347279e312
7
+ data.tar.gz: 712ff73b644360b0f05f133d172af8cb3a827116439ea10352b56272313b4e06a39092f322e666569609c7b0ab173e3f1ab1f2ddb3ae6e37e1e5964baa8c660d
@@ -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,21 @@ export default class extends Controller {
172
171
  )
173
172
  }
174
173
 
174
+ mostrarError () {
175
+ if (this.element.querySelector('.resultados .spinner-border')) {
176
+ Rollbar.error('Time out de asociable.js')
177
+ // TODO: link a contacto
178
+ this.subWrapper.innerHTML = renderToStaticMarkup(
179
+ <div className="resultados" tabIndex={-1}>
180
+ <div className="text-center p-2 text-danger d-flex align-items-center">
181
+ <i className="bi-exclamation-circle me-2"></i>
182
+ Ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.
183
+ </div>
184
+ </div>
185
+ )
186
+ }
187
+ }
188
+
175
189
  setMaxHeight () {
176
190
  let maxHeight
177
191
  if (!this.element.closest('.modal')) {
@@ -218,10 +232,9 @@ export default class extends Controller {
218
232
  }
219
233
 
220
234
  buscando () {
221
- // FIXME: spinner
222
235
  this.subWrapper.innerHTML = renderToStaticMarkup(
223
- <div className="resultados" tabIndex={-1}>
224
- <div className="fst-italic text-secondary px-3">Buscando...</div>
236
+ <div className="resultados text-center p-2" tabIndex={-1}>
237
+ <span className="spinner-border" role="status"></span>
225
238
  </div>
226
239
  )
227
240
  }
@@ -247,16 +260,25 @@ export default class extends Controller {
247
260
  }
248
261
  this.lastValue = this.input.value
249
262
 
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)
263
+ const timerBuscandoId = setTimeout(() => {
264
+ // console.log(`timed out ${timerBuscandoId}`)
265
+ this.buscando()
266
+ }, 200)
267
+ // console.log(`setTimeOut ${timerBuscandoId}`)
268
+ document.addEventListener('turbo:before-stream-render', (i) => {
269
+ // console.log(`clear before stream render ${timerBuscandoId}`)
270
+ clearTimeout(timerBuscandoId)
271
+ }, { once: true })
272
+ const timerErrorId = setTimeout(() => {
273
+ this.mostrarError()
274
+ }, 15000)
275
+ const timeouts = `${timerBuscandoId},${timerErrorId}`
276
+
256
277
  const elem = (
257
278
  <form method="post" action={this.input.dataset.urlSearch} data-turbo-stream="true">
258
279
  <input type="hidden" name="id" value={this.elemId} />
259
280
  <input type="hidden" name="query" value={this.input.value} />
281
+ <input type="hidden" name="timeout_id" value={timeouts} />
260
282
  <input type="hidden" name="puede_crear" value={this.element.dataset.puedeCrear} />
261
283
  </form>
262
284
  )
@@ -271,11 +293,10 @@ export default class extends Controller {
271
293
  const textField = this.element.querySelector('input[type=text]')
272
294
  const hiddenField = this.element.querySelector('input[type=hidden]')
273
295
 
274
- if (target && target.dataset.fieldName)
275
- hiddenField.name = target.dataset.fieldName
296
+ if (target && target.dataset.fieldName) { hiddenField.name = target.dataset.fieldName }
276
297
 
277
298
  if (target) {
278
- let object = JSON.parse(target.dataset.object)
299
+ const object = JSON.parse(target.dataset.object)
279
300
  hiddenField.value = object.id
280
301
  textField.value = object.to_s
281
302
  textField.setAttribute('readonly', 'true')
@@ -1,5 +1,6 @@
1
- / # locals: (collection:, query:, field_name: nil)
1
+ / # locals: (collection:, query:, timeout_id:, field_name: nil)
2
2
  .resultados.inline tabindex="-1"
3
+ div data-controller="clear-timeout" data-timeout-id="#{timeout_id}"
3
4
  ul.list-group.list-group-flush
4
5
  - if collection.any?
5
6
  - 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.79'
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.79
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