pg_rails 7.0.8.pre.alpha.76 → 7.0.8.pre.alpha.78
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/pg_associable/app/helpers/pg_associable/helpers.rb +2 -1
- data/pg_associable/app/javascript/asociable_controller.tsx +38 -12
- data/pg_associable/app/views/pg_associable/_resultados_inline.html.slim +5 -3
- data/pg_engine/app/decorators/pg_engine/base_record_decorator.rb +2 -2
- data/pg_engine/lib/pg_engine/utils/pg_logger.rb +4 -0
- data/pg_layout/app/javascript/controllers/clear_timeout_controller.js +5 -3
- data/pg_layout/app/javascript/controllers/pg_form_controller.js +9 -1
- data/pg_rails/lib/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 871482c5c249da4284c330d128e8f9d3bb456ba55b2b434fd5ae7f7620402643
|
4
|
+
data.tar.gz: e12f78759a856ebd5f020f44e744e5d894fa5e5cba3e6fcc97751d3df6eecdaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -10,6 +10,7 @@ export default class extends Controller {
|
|
10
10
|
elemId = null
|
11
11
|
input = null
|
12
12
|
originalPlaceholder = null
|
13
|
+
savedInputState = null
|
13
14
|
|
14
15
|
connect () {
|
15
16
|
// ID único para identificar el campo y el modal
|
@@ -69,8 +70,15 @@ export default class extends Controller {
|
|
69
70
|
|
70
71
|
this.input.addEventListener('blur', () => {
|
71
72
|
this.input.placeholder = this.originalPlaceholder
|
73
|
+
if (!this.element.classList.contains('filled')) {
|
74
|
+
this.savedInputState = this.input.value
|
75
|
+
this.input.value = null
|
76
|
+
}
|
72
77
|
})
|
73
78
|
this.input.onfocus = () => {
|
79
|
+
if (this.savedInputState && !this.input.value) {
|
80
|
+
this.input.value = this.savedInputState
|
81
|
+
}
|
74
82
|
this.input.select()
|
75
83
|
if (this.input.value.length === 0) {
|
76
84
|
this.escribiAlgo()
|
@@ -98,7 +106,6 @@ export default class extends Controller {
|
|
98
106
|
}
|
99
107
|
}
|
100
108
|
this.input.onkeydown = (e) => {
|
101
|
-
console.log(e.keyCode)
|
102
109
|
if (e.keyCode === 13) { // Enter
|
103
110
|
e.preventDefault()
|
104
111
|
return false
|
@@ -164,6 +171,18 @@ export default class extends Controller {
|
|
164
171
|
)
|
165
172
|
}
|
166
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
|
+
|
167
186
|
setMaxHeight () {
|
168
187
|
let maxHeight
|
169
188
|
if (!this.element.closest('.modal')) {
|
@@ -211,15 +230,15 @@ export default class extends Controller {
|
|
211
230
|
|
212
231
|
buscando () {
|
213
232
|
this.subWrapper.innerHTML = renderToStaticMarkup(
|
214
|
-
<div className="resultados" tabIndex={-1}>
|
215
|
-
<
|
233
|
+
<div className="resultados text-center p-2" tabIndex={-1}>
|
234
|
+
<span className="spinner-border" role="status"></span>
|
216
235
|
</div>
|
217
236
|
)
|
218
237
|
}
|
219
238
|
|
220
239
|
selectItem (e) {
|
221
240
|
if (e.target.dataset.object) {
|
222
|
-
this.completarCampo(
|
241
|
+
this.completarCampo(e.target)
|
223
242
|
} else {
|
224
243
|
this.completarCampo(null)
|
225
244
|
}
|
@@ -238,16 +257,19 @@ export default class extends Controller {
|
|
238
257
|
}
|
239
258
|
this.lastValue = this.input.value
|
240
259
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
260
|
+
const timerBuscandoId = setTimeout(() => {
|
261
|
+
this.buscando()
|
262
|
+
}, 200)
|
263
|
+
const timerErrorId = setTimeout(() => {
|
264
|
+
this.mostrarError()
|
265
|
+
}, 15000)
|
266
|
+
const timeouts = `${timerBuscandoId},${timerErrorId}`
|
267
|
+
|
247
268
|
const elem = (
|
248
269
|
<form method="post" action={this.input.dataset.urlSearch} data-turbo-stream="true">
|
249
270
|
<input type="hidden" name="id" value={this.elemId} />
|
250
271
|
<input type="hidden" name="query" value={this.input.value} />
|
272
|
+
<input type="hidden" name="timeout_id" value={timeouts} />
|
251
273
|
<input type="hidden" name="puede_crear" value={this.element.dataset.puedeCrear} />
|
252
274
|
</form>
|
253
275
|
)
|
@@ -258,10 +280,14 @@ export default class extends Controller {
|
|
258
280
|
form.remove()
|
259
281
|
}
|
260
282
|
|
261
|
-
completarCampo (
|
283
|
+
completarCampo (target) {
|
262
284
|
const textField = this.element.querySelector('input[type=text]')
|
263
285
|
const hiddenField = this.element.querySelector('input[type=hidden]')
|
264
|
-
|
286
|
+
|
287
|
+
if (target && target.dataset.fieldName) { hiddenField.name = target.dataset.fieldName }
|
288
|
+
|
289
|
+
if (target) {
|
290
|
+
const object = JSON.parse(target.dataset.object)
|
265
291
|
hiddenField.value = object.id
|
266
292
|
textField.value = object.to_s
|
267
293
|
textField.setAttribute('readonly', 'true')
|
@@ -1,11 +1,13 @@
|
|
1
|
-
/ # locals: (collection:, query:)
|
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|
|
6
8
|
= link_to object.to_s, 'javascript:void(0)',
|
7
9
|
class: 'list-group-item',
|
8
10
|
data: { action: 'asociable#selectItem',
|
9
|
-
id: object.id, object: object.decorate.to_json }
|
11
|
+
id: object.id, object: object.decorate.to_json, field_name: }
|
10
12
|
- else
|
11
|
-
li.px-3.py-1 No hay resultados para "#{query}"
|
13
|
+
li.px-3.py-1 style="font-size: 0.85em" No hay resultados para "#{query}"
|
@@ -53,10 +53,10 @@ module PgEngine
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def edit_link(text: '', klass: 'btn-
|
56
|
+
def edit_link(text: ' Modificar', klass: 'btn-warning')
|
57
57
|
return unless Pundit.policy!(Current.user, object).edit?
|
58
58
|
|
59
|
-
helpers.content_tag :span, rel: :tooltip, title: '
|
59
|
+
helpers.content_tag :span, rel: :tooltip, title: 'Modificar' do
|
60
60
|
helpers.link_to edit_object_url, data: { turbo_frame: :main },
|
61
61
|
class: "btn btn-sm #{klass}" do
|
62
62
|
helpers.content_tag(:span, nil, class: clase_icono('pencil')) + text
|
@@ -5,6 +5,10 @@ require 'rainbow'
|
|
5
5
|
# TODO: poder pasar blocks
|
6
6
|
|
7
7
|
def pg_err(*args)
|
8
|
+
raise args.first if ENV.fetch('RAISE_ERRORS', false) && args.first.is_a?(Exception)
|
9
|
+
|
10
|
+
byebug if ENV.fetch('BYEBUG_ERRORS', false) # rubocop:disable Lint/Debugger
|
11
|
+
|
8
12
|
pg_log(:error, *args)
|
9
13
|
end
|
10
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
|
-
|
7
|
-
|
8
|
-
|
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
|
}
|
@@ -10,6 +10,14 @@ export default class extends Controller {
|
|
10
10
|
}
|
11
11
|
})
|
12
12
|
})
|
13
|
+
this.element.querySelectorAll('.btn-check').forEach((slct) => {
|
14
|
+
slct.addEventListener('change', (e) => {
|
15
|
+
const invalid = e.target.closest('.is-invalid')
|
16
|
+
if (invalid) {
|
17
|
+
invalid.classList.remove('is-invalid')
|
18
|
+
}
|
19
|
+
})
|
20
|
+
})
|
13
21
|
const errorTitle = this.element.querySelector('.error-title')
|
14
22
|
if (errorTitle) {
|
15
23
|
const invalidField = document.querySelector('.is-invalid')
|
@@ -17,7 +25,7 @@ export default class extends Controller {
|
|
17
25
|
if (!invalidField && !baseAlert) {
|
18
26
|
const errorTitle = this.element.querySelector('.error-title')
|
19
27
|
// TODO!: testear con capybara
|
20
|
-
errorTitle.innerText = '
|
28
|
+
errorTitle.innerText = 'Ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.'
|
21
29
|
// TODO!: link a contacto
|
22
30
|
const form = this.element.querySelector('form')
|
23
31
|
const errorMsg = `${form.id} - ${form.action} - ${form.dataset.errors}`
|
data/pg_rails/lib/version.rb
CHANGED
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.
|
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-
|
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
|