pg_rails 7.0.8.pre.alpha.75 → 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: 46472fd017bf8657e28b3d968159b206c7c2ab8118a4744b5ae887e38c6c0d57
4
- data.tar.gz: f0ecdadba8aaac1a640c74bc17ce6a182a0b0e4af138e5275d01c35a082b4bf7
3
+ metadata.gz: 356134a06d178d1da89941fd57ac424f400adea0d39bfe6a09a635f896380ea2
4
+ data.tar.gz: b144d8ab6758ccf469d242a3f14b5ac5b98ee892343053fb49f98ddd2555f87a
5
5
  SHA512:
6
- metadata.gz: 7cc3574cfed47ad618319c9320836ea0a7941c9951226f82cacf20dd885a7d8ba425361fefb53cbd64fb52a7b1af62d681a60da0ba3a8de2bc120977383ca489
7
- data.tar.gz: 16b08e59ac08a38348d08f88f591d32f2349d5f3baa188235bb57d57352213b3a224364be53a03da371971df4e1ba0f4f91e5b0fc5a9fd9b8deca7c8b5d2a25d
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
@@ -21,7 +21,6 @@ module PgEngine
21
21
  def render_unconfirmed
22
22
  self.content_type = 'text/vnd.turbo-stream.html'
23
23
  self.status = 200
24
- # TODO: poner data-turbo-temporary?
25
24
  self.response_body = <<~HTML
26
25
  <turbo-stream action="update" target="flash">
27
26
  <template>
@@ -27,7 +27,7 @@ class PgFormBuilder < SimpleForm::FormBuilder
27
27
  end
28
28
 
29
29
  def mensajes_de_error
30
- # TODO: poner data-turbo-temporary?
30
+ # TODO: quitar en before-cache?
31
31
  title = error_notification(message: mensaje, class: 'text-danger mb-2 error-title') if mensaje
32
32
 
33
33
  base_errors = object.errors[:base]
@@ -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
 
@@ -37,6 +37,9 @@ document.addEventListener('turbo:load', bindAndObserveToasts)
37
37
  document.addEventListener('turbo:render', bindAndObserveToasts)
38
38
 
39
39
  document.addEventListener('turbo:before-cache', () => {
40
+ document.querySelectorAll('#flash .alert').forEach((el) => {
41
+ el.remove()
42
+ })
40
43
  document.querySelectorAll('.offcanvas-backdrop').forEach((el) => {
41
44
  el.remove()
42
45
  })
@@ -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')
@@ -38,9 +38,9 @@ class Navbar
38
38
  path: eval(item['path']),
39
39
  show: item['policy'] ? eval(item['policy']) : true
40
40
  }
41
- rescue StandardError
41
+ rescue StandardError => e
42
42
  # TODO!: testear
43
- pg_err item
43
+ pg_err e, item
44
44
  return []
45
45
  end
46
46
  # rubocop:enable Security/Eval
@@ -1,6 +1,6 @@
1
1
  <%# locals: (error_msg: nil) %>
2
2
 
3
- <div class="d-flex justify-content-around mt-2" data-turbo-temporary="true">
3
+ <div class="d-flex justify-content-around mt-2">
4
4
  <div class="alert alert-danger d-flex align-items-center">
5
5
  <div>
6
6
  <span class="bi bi-emoji-dizzy fs-1 me-3"></span>
@@ -5,7 +5,7 @@
5
5
  mt-2 d-flex align-items-center
6
6
  alert-#{flash_type_to_class(flash_type)}
7
7
  #{'position-absolute pg-toast' if toast}"
8
- data-turbo-temporary="true" data-bs-autohide="true"
8
+ data-bs-autohide="true"
9
9
  aria-live="assertive" aria-atomic="true" role="alert"
10
10
  ]
11
11
  - case flash_type
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.75'
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.75
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