pg_rails 7.0.8.pre.alpha.16 → 7.0.8.pre.alpha.18

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: f27fe3f2ee02b2a1654d32f0c37ed02d2310e9d44e0d3f93fc29eeb25ee27280
4
- data.tar.gz: a7635ed50ab55e3c2d9d1251e94f20b910ae2310e49ce86d55bc56b9062368ac
3
+ metadata.gz: fe2517c50a77409c6c90dc4378588e7b5bfc8cfa227859bdd7a163979c1b8e0d
4
+ data.tar.gz: dd5da55fffc24abb9bbb4942a2e6de0a7e52184cca97e54ec16500afb556f043
5
5
  SHA512:
6
- metadata.gz: 951befcf7f41a83899f89cc535b833f84466bfc218b7b285a4b5c6b5ad9862de37bfb6f69c0923b10cabfd30857671ec80050307ff8ee0f7dedd1ed6d3b9ac87
7
- data.tar.gz: cb09bdadffa8d09251b24b10da5da7b02610feba9fb80079a078686f2ecaeddca78262f91d5d0317c13a7a3b7fc0f2bc0b4d878a0aafa13c827ca0c0102efd66
6
+ metadata.gz: c3d214ad9f2a591590582d92b8c409a593ef5d5a6b0a3bc207aca5dc37944ab0be4f72ad785d119beb1c56fc954ef74c43d7da8418b06a45688330127ff4c6ff
7
+ data.tar.gz: be03f50c19c74783a6c2bce2d371ed9b58a41eefa87addeecfddbb79e5999906a9e6456017b1a318e8d2c4f492d1b488e9f6d9aba9215f0a3eb9b31d4c183e38
@@ -10,7 +10,7 @@ export default class extends Controller {
10
10
  connect (e) {
11
11
  this.modalPuntero = new bootstrap.Modal(this.element)
12
12
  this.modalPuntero.show()
13
- document.addEventListener("turbo:before-cache", () => {
13
+ document.addEventListener('turbo:before-cache', () => {
14
14
  this.element.remove()
15
15
  }, { once: true })
16
16
  }
@@ -1,5 +1,9 @@
1
1
  import AsociableController from './app/javascript/asociable_controller'
2
2
  import ModalController from './app/javascript/modal_controller'
3
3
 
4
- window.Stimulus.register('asociable', AsociableController)
5
- window.Stimulus.register('modal', ModalController)
4
+ if (window.Stimulus) {
5
+ window.Stimulus.register('asociable', AsociableController)
6
+ window.Stimulus.register('modal', ModalController)
7
+ } else {
8
+ console.error('window.Stimulus must be set')
9
+ }
@@ -31,58 +31,62 @@ module PgEngine
31
31
  end
32
32
  # rubocop:enable Style/MissingRespondToMissing
33
33
 
34
- def destroy_link(message = '¿Estás seguro?')
34
+ def destroy_link(confirm_text: '¿Estás seguro?', klass: 'btn-light')
35
35
  return unless Pundit.policy!(helpers.send(PgEngine.configuracion.current_user_method), object).destroy?
36
36
 
37
37
  helpers.content_tag :span, rel: :tooltip, title: 'Eliminar' do
38
- helpers.link_to object_url, data: { 'turbo-confirm': message, 'turbo-method': :delete },
39
- class: "btn #{_config.clase_botones_chicos} btn-#{_config.boton_destroy}" do
40
- helpers.content_tag :span, nil, class: clase_icono(_config.icono_destroy).to_s
38
+ helpers.link_to object_url, data: { 'turbo-confirm': confirm_text, 'turbo-method': :delete },
39
+ class: "btn btn-sm #{klass}" do
40
+ helpers.content_tag :span, nil, class: clase_icono('trash-fill')
41
41
  end
42
42
  end
43
43
  end
44
44
 
45
- def edit_link(texto = '')
45
+ def edit_link(text: '', klass: 'btn-light')
46
46
  return unless Pundit.policy!(helpers.send(PgEngine.configuracion.current_user_method), object).edit?
47
47
 
48
48
  helpers.content_tag :span, rel: :tooltip, title: 'Editar' do
49
49
  helpers.link_to edit_object_url, data: { turbo_frame: :main },
50
- class: "btn #{_config.clase_botones_chicos} btn-#{_config.boton_edit}" do
51
- helpers.content_tag(:span, nil, class: clase_icono(_config.icono_edit).to_s) + texto
50
+ class: "btn btn-sm #{klass}" do
51
+ helpers.content_tag(:span, nil, class: clase_icono('pencil')) + text
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
- def show_link(texto = '')
56
+ def show_link(text: '', klass: 'btn-light')
57
57
  return unless Pundit.policy!(helpers.send(PgEngine.configuracion.current_user_method), object).show?
58
58
 
59
59
  helpers.content_tag :span, rel: :tooltip, title: 'Ver' do
60
60
  helpers.link_to object_url, data: { turbo_frame: :main },
61
- class: "btn #{_config.clase_botones_chicos} btn-#{_config.boton_show}" do
62
- helpers.content_tag(:span, nil, class: clase_icono(_config.icono_show).to_s) + texto
61
+ class: "btn btn-sm #{klass}" do
62
+ helpers.content_tag(:span, nil, class: clase_icono('eye-fill')) + text
63
63
  end
64
64
  end
65
65
  end
66
66
 
67
- def export_link(url, texto = '')
68
- return unless Pundit.policy!(helpers.send(PgEngine.configuracion.current_user_method), object).export?
67
+ def export_link(url, text: '', klass: 'btn-info')
68
+ return unless Pundit.policy!(helpers.current_user, object).export?
69
69
 
70
- helpers.content_tag :span, rel: :tooltip, title: 'Exportar' do
70
+ helpers.content_tag :span, rel: :tooltip, title: 'Exportar en excel' do
71
71
  helpers.content_tag :a, target: '_blank',
72
- class: "btn #{_config.clase_botones_chicos} btn-#{_config.boton_export}", href: url_change_format(url, 'xlsx') do
73
- "#{helpers.content_tag(:span, nil, class: clase_icono('file-earmark-excel-fill'))} #{texto}".html_safe
72
+ class: "btn btn-sm #{klass}", href: url_change_format(url, 'xlsx') do
73
+ "#{helpers.content_tag(:span, nil, class: clase_icono('file-earmark-excel-fill'))} #{text}".html_safe
74
74
  end
75
75
  end
76
76
  end
77
77
 
78
- def new_link(options = {})
78
+ def new_link(remote: nil, klass: 'btn-warning')
79
79
  return unless Pundit.policy!(helpers.send(PgEngine.configuracion.current_user_method), object).new?
80
80
 
81
- helpers.content_tag :span, rel: :tooltip, title: 'Crear' do
82
- helpers.link_to new_object_url, class: "btn #{_config.clase_botones_chicos} btn-primary",
83
- remote: options[:remote] do
81
+ word_to_create = I18n.t("form.#{object.class.nombre_singular.downcase}.create", default: :'form.create')
82
+
83
+ full_text = "#{word_to_create} #{object.class.nombre_singular.downcase}"
84
+
85
+ helpers.content_tag :span, rel: :tooltip, title: word_to_create do
86
+ helpers.link_to(new_object_url, class: "btn btn-sm #{klass}",
87
+ remote:) do
84
88
  helpers.content_tag(:span, nil,
85
- class: clase_icono('plus').to_s) + "<span class='d-none d-sm-inline'> Crear #{object.class.nombre_singular.downcase}</span>".html_safe
89
+ class: clase_icono('plus').to_s) + "<span class='d-none d-sm-inline'> #{full_text}</span>".html_safe
86
90
  end
87
91
  end
88
92
  end
@@ -109,12 +113,8 @@ module PgEngine
109
113
 
110
114
  private
111
115
 
112
- def _config
113
- PgEngine.configuracion
114
- end
115
-
116
116
  def clase_icono(icono)
117
- "#{_config.sistema_iconos} #{_config.sistema_iconos}-#{icono}"
117
+ "bi bi-#{icono}"
118
118
  end
119
119
  end
120
120
  end
@@ -1,14 +1,13 @@
1
1
  - content_for(:title, @clase_modelo.nombre_plural)
2
2
  - content_for :actions do
3
- button.btn.btn-sm.btn-primary[type="button" data-bs-toggle="collapse"
3
+ button.btn.btn-sm.btn-outline-primary[type="button" data-bs-toggle="collapse"
4
4
  data-bs-target="#filtros" aria-expanded="false"
5
5
  aria-controls="filtros"]
6
6
  span.bi.bi-funnel-fill
7
7
  span.d-none.d-sm-inline Filtrar
8
8
  .ms-1
9
9
  = @clase_modelo.new.decorate.new_link
10
- .ms-1
11
- = @clase_modelo.new.decorate.export_link(request.url)
10
+
12
11
  .collapse.border-bottom#filtros class="#{ 'show' if any_filter? }"
13
12
  .d-flex.align-items-center.p-2
14
13
  .px-2.d-none.d-sm-inline-block
@@ -33,7 +32,7 @@ div
33
32
  tr
34
33
  - atributos_para_listar.each do |att|
35
34
  th = encabezado att, ordenable: true
36
- th
35
+ th.text-end = @clase_modelo.new.decorate.export_link(request.url)
37
36
  tbody
38
37
  - @collection.each do |object|
39
38
  - object = object.decorate
@@ -5,6 +5,8 @@ es:
5
5
  discarded_at: Fecha de borrado
6
6
  actualizado_por: Actualizado por
7
7
  creado_por: Creado por
8
+ form:
9
+ create: Crear
8
10
  ancestry:
9
11
  exclude_self: No puede ser hijx de si mismx
10
12
  simple_form:
@@ -18,20 +18,15 @@ end
18
18
 
19
19
  module PgEngine
20
20
  class PgLogger
21
+ # Generalmente en local queremos que se lancen los errores, salvo
22
+ # cuando estamos testeando casos de error puntuales.
23
+ @raise_errors = Rails.env.local?
24
+
21
25
  class << self
22
- # DEPRECATED
23
- # Muestro el caller[1] para saber dónde se llamó a la función deprecada
24
- # def deprecated(mensaje)
25
- # titulo = Rainbow(" WARNING en #{caller[1]}").yellow.bold
26
- # detalles = Rainbow(" #{mensaje}").yellow
27
- # Rails.logger.warn("#{titulo}\n#{detalles}")
28
- # Rollbar.warning("#{mensaje}\n\n#{caller.join("\n")}")
29
- # end
26
+ attr_accessor :raise_errors
30
27
 
31
28
  def error(obj)
32
- # TODO: arreglar
33
- # Si es dev o test lanzo el error y si no, lo logueo para que no le salte al usuario
34
- # raise obj if Rails.env.local? && ENV.fetch('RAISE_ERRORS', nil).present?
29
+ raise obj if raise_errors
35
30
 
36
31
  mensaje = if obj.is_a?(Exception) && obj.backtrace.present?
37
32
  "#{obj.inspect}\nBacktrace:\n#{cleaner.clean(obj.backtrace).join("\n")}"
@@ -93,3 +88,12 @@ module PgEngine
93
88
  end
94
89
  end
95
90
  end
91
+
92
+ # DEPRECATED
93
+ # Muestro el caller[1] para saber dónde se llamó a la función deprecada
94
+ # def deprecated(mensaje)
95
+ # titulo = Rainbow(" WARNING en #{caller[1]}").yellow.bold
96
+ # detalles = Rainbow(" #{mensaje}").yellow
97
+ # Rails.logger.warn("#{titulo}\n#{detalles}")
98
+ # Rollbar.warning("#{mensaje}\n\n#{caller.join("\n")}")
99
+ # end
@@ -11,6 +11,12 @@ describe PgEngine::PgLogger do
11
11
  end
12
12
  end
13
13
 
14
+ around do |example|
15
+ described_class.raise_errors = false
16
+ example.run
17
+ described_class.raise_errors = true
18
+ end
19
+
14
20
  shared_examples 'logger' do |type|
15
21
  it do
16
22
  expect(Rails.logger).to have_received(type).twice
@@ -1,4 +1,7 @@
1
- // TODO: si no existe la aplicacion mostrar error
1
+ if (!window.Stimulus) {
2
+ console.error('window.Stimulus must be set')
3
+ }
4
+
2
5
  const application = window.Stimulus
3
6
 
4
7
  export { application }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.16'
4
+ VERSION = '7.0.8-alpha.18'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.16
4
+ version: 7.0.8.pre.alpha.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso