pg_rails 7.0.8.pre.alpha.76 → 7.0.8.pre.alpha.77

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: 1e72fb52c1042404baaf142d2b8a3e83eb75cd8034e4ba58ca7c862054cfe8d8
4
- data.tar.gz: 7f2cf6cd1ae8089fdeba57501d7d990fe9c59fc7a713b21068a16772a0506c17
3
+ metadata.gz: 356134a06d178d1da89941fd57ac424f400adea0d39bfe6a09a635f896380ea2
4
+ data.tar.gz: b144d8ab6758ccf469d242a3f14b5ac5b98ee892343053fb49f98ddd2555f87a
5
5
  SHA512:
6
- metadata.gz: 28be79030af6d2cf172da55d757d040b414e166cda53960fd66f982d3dd36f36b829c45e835d798425a50bd38609d3b2c1ca3ab5d0536983ffd3d3b3e38bd2d6
7
- data.tar.gz: 6c88a919dafb6e96c03214d0a7d91d6e4293752e0323b6a5fec3e0c1d97750b541e6af8000ce8f21e3057dbfb0159d44fe4d5644076046992144207261aa31f6
6
+ metadata.gz: 29d1bb1ec81bd9e6a3d11c84ba76a5cdcf03b1f95d4ecee39057bcc358721fa5ae252b511c09bcb7e1cfd6ed7e270ac20efb264eba325a42ce326c6d022234bc
7
+ data.tar.gz: 455515106f9dc06e3e1da329b0a7c23eda3da54602b922136b9c54cdd868d629b592098fcce9970c7e11e99aad5b8fdf61a580bdc7a40f332836ebad45bc66dc
@@ -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,16 @@ 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
+ }
82
+ this.savedInputState =
74
83
  this.input.select()
75
84
  if (this.input.value.length === 0) {
76
85
  this.escribiAlgo()
@@ -98,7 +107,6 @@ export default class extends Controller {
98
107
  }
99
108
  }
100
109
  this.input.onkeydown = (e) => {
101
- console.log(e.keyCode)
102
110
  if (e.keyCode === 13) { // Enter
103
111
  e.preventDefault()
104
112
  return false
@@ -210,6 +218,7 @@ export default class extends Controller {
210
218
  }
211
219
 
212
220
  buscando () {
221
+ // FIXME: spinner
213
222
  this.subWrapper.innerHTML = renderToStaticMarkup(
214
223
  <div className="resultados" tabIndex={-1}>
215
224
  <div className="fst-italic text-secondary px-3">Buscando...</div>
@@ -219,7 +228,7 @@ export default class extends Controller {
219
228
 
220
229
  selectItem (e) {
221
230
  if (e.target.dataset.object) {
222
- this.completarCampo(JSON.parse(e.target.dataset.object))
231
+ this.completarCampo(e.target)
223
232
  } else {
224
233
  this.completarCampo(null)
225
234
  }
@@ -258,10 +267,15 @@ export default class extends Controller {
258
267
  form.remove()
259
268
  }
260
269
 
261
- completarCampo (object) {
270
+ completarCampo (target) {
262
271
  const textField = this.element.querySelector('input[type=text]')
263
272
  const hiddenField = this.element.querySelector('input[type=hidden]')
264
- if (object) {
273
+
274
+ if (target && target.dataset.fieldName)
275
+ hiddenField.name = target.dataset.fieldName
276
+
277
+ if (target) {
278
+ let object = JSON.parse(target.dataset.object)
265
279
  hiddenField.value = object.id
266
280
  textField.value = object.to_s
267
281
  textField.setAttribute('readonly', 'true')
@@ -1,4 +1,4 @@
1
- / # locals: (collection:, query:)
1
+ / # locals: (collection:, query:, field_name: nil)
2
2
  .resultados.inline tabindex="-1"
3
3
  ul.list-group.list-group-flush
4
4
  - if collection.any?
@@ -6,6 +6,6 @@
6
6
  = link_to object.to_s, 'javascript:void(0)',
7
7
  class: 'list-group-item',
8
8
  data: { action: 'asociable#selectItem',
9
- id: object.id, object: object.decorate.to_json }
9
+ id: object.id, object: object.decorate.to_json, field_name: }
10
10
  - else
11
- li.px-3.py-1 No hay resultados para "#{query}"
11
+ li.px-3.py-1 style="font-size: 0.85em" No hay resultados para "#{query}"
@@ -53,10 +53,11 @@ module PgEngine
53
53
  end
54
54
  end
55
55
 
56
+ # FIXME: default: text: ' Modificar', klass: 'btn-warning')
56
57
  def edit_link(text: '', klass: 'btn-light')
57
58
  return unless Pundit.policy!(Current.user, object).edit?
58
59
 
59
- helpers.content_tag :span, rel: :tooltip, title: 'Editar' do
60
+ helpers.content_tag :span, rel: :tooltip, title: 'Modificar' do
60
61
  helpers.link_to edit_object_url, data: { turbo_frame: :main },
61
62
  class: "btn btn-sm #{klass}" do
62
63
  helpers.content_tag(:span, nil, class: clase_icono('pencil')) + text
@@ -5,6 +5,8 @@ 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
+ byebug if ENV.fetch('BYEBUG_ERRORS', false)
8
10
  pg_log(:error, *args)
9
11
  end
10
12
 
@@ -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
+ let 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')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.76'
4
+ VERSION = '7.0.8-alpha.77'
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.76
4
+ version: 7.0.8.pre.alpha.77
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-19 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails