pg_rails 7.2.2 → 7.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/pg_associable/app/helpers/pg_associable/form_builder_methods.rb +1 -2
  3. data/pg_associable/app/helpers/pg_associable/helpers.rb +4 -5
  4. data/pg_associable/app/javascript/modal_controller.js +19 -7
  5. data/pg_associable/spec/system/associable_spec.rb +2 -2
  6. data/pg_engine/app/components/actions_component.rb +14 -0
  7. data/pg_engine/app/components/asociable_modal_component.html.slim +6 -0
  8. data/pg_engine/app/components/asociable_modal_component.rb +7 -0
  9. data/pg_engine/app/components/form_modal_component.html.slim +15 -0
  10. data/pg_engine/app/components/form_modal_component.rb +6 -0
  11. data/pg_engine/app/components/modal_component.html.slim +5 -0
  12. data/pg_engine/app/components/modal_component.rb +11 -0
  13. data/pg_engine/app/components/modal_content_component.rb +28 -0
  14. data/pg_engine/app/components/show_modal_component.html.slim +10 -0
  15. data/pg_engine/app/components/show_modal_component.rb +7 -0
  16. data/pg_engine/app/controllers/admin/emails_controller.rb +3 -20
  17. data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +134 -102
  18. data/pg_engine/app/decorators/pg_engine/base_record_decorator.rb +29 -8
  19. data/pg_engine/app/helpers/pg_engine/flash_helper.rb +6 -2
  20. data/pg_engine/app/helpers/pg_engine/form_helper.rb +20 -2
  21. data/pg_engine/app/models/email.rb +2 -0
  22. data/pg_engine/app/models/pg_engine/base_record.rb +11 -0
  23. data/pg_engine/app/views/admin/accounts/_form.html.slim +1 -4
  24. data/pg_engine/app/views/admin/email_logs/_form.html.slim +2 -5
  25. data/pg_engine/app/views/admin/emails/_form.html.slim +13 -13
  26. data/pg_engine/app/views/admin/emails/_send.html.slim +0 -1
  27. data/pg_engine/app/views/admin/emails/show.html.slim +19 -20
  28. data/pg_engine/app/views/admin/eventos/new.html.slim +0 -2
  29. data/pg_engine/app/views/admin/user_accounts/_form.html.slim +1 -4
  30. data/pg_engine/app/views/admin/users/_form.html.slim +1 -4
  31. data/pg_engine/app/views/pg_engine/base/index.html.slim +4 -0
  32. data/pg_engine/app/views/pg_engine/base/new.html.slim +1 -2
  33. data/pg_engine/app/views/public/mensaje_contactos/new.html.slim +2 -5
  34. data/pg_engine/config/initializers/kaminari.rb +3 -0
  35. data/pg_engine/lib/pg_engine/utils/pg_logger.rb +10 -10
  36. data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +2 -2
  37. data/pg_engine/spec/controllers/admin/email_logs_controller_spec.rb +2 -2
  38. data/pg_engine/spec/controllers/admin/emails_controller_spec.rb +2 -2
  39. data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +2 -2
  40. data/pg_engine/spec/controllers/admin/users_controller_spec.rb +2 -2
  41. data/pg_engine/spec/lib/pg_engine/form_helper_spec.rb +53 -0
  42. data/pg_engine/spec/system/modal_windows_spec.rb +89 -0
  43. data/pg_engine/spec/system/send_mail_spec.rb +1 -1
  44. data/pg_layout/app/javascript/application.js +24 -0
  45. data/pg_layout/app/javascript/controllers/date_selector_controller.js +5 -4
  46. data/pg_layout/app/javascript/controllers/popover_toggler_controller.js +3 -2
  47. data/pg_layout/app/javascript/elements/index.js +1 -0
  48. data/pg_layout/app/javascript/elements/pg_event.js +12 -0
  49. data/pg_layout/app/views/devise/confirmations/new.html.erb +0 -1
  50. data/pg_layout/app/views/devise/passwords/edit.html.erb +0 -2
  51. data/pg_layout/app/views/devise/passwords/new.html.erb +0 -2
  52. data/pg_layout/app/views/devise/registrations/edit.html.erb +0 -2
  53. data/pg_layout/app/views/devise/registrations/new.html.erb +0 -2
  54. data/pg_layout/app/views/devise/unlocks/new.html.erb +0 -1
  55. data/pg_rails/lib/version.rb +1 -1
  56. data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +2 -2
  57. data/pg_scaffold/lib/generators/pg_slim/templates/_form.html.slim +2 -5
  58. data/pg_scaffold/lib/generators/pg_slim/templates/show.html.slim +1 -1
  59. metadata +17 -4
  60. data/pg_associable/app/views/pg_engine/base/_pg_associable_modal.html.slim +0 -14
  61. data/pg_layout/app/views/pg_layout/_modal_show.html.slim +0 -14
@@ -2,7 +2,12 @@
2
2
 
3
3
  module PgEngine
4
4
  module FormHelper
5
- def pg_form_for(object, *args, &)
5
+ def using_modal?
6
+ @using_modal || controller.instance_variable_get(:@using_modal)
7
+ end
8
+
9
+ # rubocop:disable Metrics/CyclomaticComplexity
10
+ def pg_form_for(object, *args, &block_passed)
6
11
  resource = object
7
12
  if object.is_a? PgEngine::BaseRecordDecorator
8
13
  object = object.target_object
@@ -27,8 +32,21 @@ module PgEngine
27
32
  options[:html][:data][:errors] = resource.errors.details.to_json
28
33
  end
29
34
 
30
- simple_form_for(object, *(args << options), &)
35
+ if options[:render_errors].nil?
36
+ options[:render_errors] = true
37
+ end
38
+
39
+ block_with_additives = lambda do |f|
40
+ ret = ''.html_safe
41
+ ret += f.mensajes_de_error if options[:render_errors]
42
+ # ret += hidden_field_tag(:using_modal, true) if using_modal?
43
+ ret += capture(f, &block_passed)
44
+ ret
45
+ end
46
+
47
+ simple_form_for(object, *(args << options), &block_with_additives)
31
48
  end
49
+ # rubocop:enable Metrics/CyclomaticComplexity
32
50
 
33
51
  def url_change_format(url, formato)
34
52
  uri = URI.parse(url)
@@ -36,6 +36,8 @@ class Email < ApplicationRecord
36
36
  include Hashid::Rails
37
37
  audited
38
38
 
39
+ self.default_modal = true
40
+
39
41
  after_commit do
40
42
  associated.email_updated(self) if associated.respond_to? :email_updated
41
43
  end
@@ -13,6 +13,10 @@ module PgEngine
13
13
  before_create :setear_creado_y_actualizado_por
14
14
  before_update :setear_actualizado_por
15
15
 
16
+ class << self
17
+ attr_accessor :default_modal
18
+ end
19
+
16
20
  scope :query, ->(param) { param.present? ? where(id: param) : all }
17
21
 
18
22
  def self.ransackable_associations(_auth_object = nil)
@@ -47,6 +51,10 @@ module PgEngine
47
51
  end
48
52
  end
49
53
 
54
+ def actions_component
55
+ ActionsComponent.new(self)
56
+ end
57
+
50
58
  # Para el dom_id (index.html)
51
59
  def to_key
52
60
  if respond_to? :hashid
@@ -58,6 +66,9 @@ module PgEngine
58
66
 
59
67
  def to_s
60
68
  %i[nombre name].each do |campo|
69
+ # Using `_in_database` for consistent breadcrumbs when editing the name
70
+ campo = :"#{campo}_in_database"
71
+
61
72
  return "#{send(campo)} ##{to_param}" if try(campo).present?
62
73
  end
63
74
  if to_param.present?
@@ -1,10 +1,7 @@
1
- / # locals: (object: nil, asociable: false)
1
+ / # locals: (object: nil)
2
2
 
3
3
  div style="max-width: 22em"
4
4
  = pg_form_for(@account || object) do |f|
5
- = f.mensajes_de_error
6
-
7
- = hidden_field_tag :asociable, true if asociable
8
5
  = f.input :plan
9
6
  = f.input :nombre
10
7
  .mt-2
@@ -1,10 +1,7 @@
1
- / # locals: (object: nil, asociable: false)
1
+ / # locals: (object: nil)
2
2
 
3
3
  div style="max-width: 22em" data-controller="pg_form"
4
- = pg_form_for(@email_log || object, asociable:) do |f|
5
- = f.mensajes_de_error
6
-
7
- = hidden_field_tag :asociable, true if asociable
4
+ = pg_form_for(@email_log || object) do |f|
8
5
  = f.pg_associable :email
9
6
  = f.input :log_id
10
7
  = f.input :event
@@ -1,17 +1,17 @@
1
- / # locals: (object: nil, asociable: false)
1
+ / # locals: (object: nil)
2
2
 
3
- div style="max-width: 22em" data-controller="pg_form"
4
- = pg_form_for(@email || object, asociable:) do |f|
5
- = f.mensajes_de_error
6
-
7
- / = hidden_field_tag :asociable, true if asociable
8
- / = f.input :from_address
9
- / = f.input :from_name
10
- / = f.input :reply_to
11
- / = f.input :to
12
- / = f.input :subject
13
- / = f.input :body_input, as: :text
14
- = f.input :status
3
+ - object ||= @email
4
+ div style="max-width: 52em" data-controller="pg_form"
5
+ = pg_form_for(object) do |f|
6
+ - if object.persisted?
7
+ = f.input :status
8
+ - else
9
+ = f.input :from_name
10
+ = f.input :from_address
11
+ = f.input :to
12
+ = f.input :subject
13
+ = f.input :reply_to
14
+ = f.input :body_input, as: :text, input_html: { rows: 5 }
15
15
 
16
16
  .mt-2
17
17
  = f.button :submit
@@ -1,7 +1,6 @@
1
1
  / # locals: (email:)
2
2
 
3
3
  = pg_form_for email do |f|
4
- = f.mensajes_de_error
5
4
  = f.input :from_name
6
5
  = f.input :from_address
7
6
  = f.input :to
@@ -5,7 +5,7 @@
5
5
  .ms-1
6
6
  = @email.edit_link
7
7
 
8
- table.table.table-borderless.table-sm.w-auto.mb-0.m-3
8
+ table.table.table-borderless.table-sm.w-auto.mb-0
9
9
  - atributos_para_mostrar.each do |att|
10
10
  tr
11
11
  th = @clase_modelo.human_attribute_name(att)
@@ -23,23 +23,22 @@ table.table.table-borderless.table-sm.w-auto.mb-0.m-3
23
23
  th = t('attributes.updated_at')
24
24
  td = @email.updated_at
25
25
 
26
- .m-4
27
- h4 Logs
28
- table.table
26
+ h4 Logs
27
+ table.table
28
+ tr
29
+ th log_id
30
+ th event
31
+ th log_level
32
+ th severity
33
+ th timestamp
34
+ th created_at
35
+ th updated_at
36
+ - @email.email_logs.order(timestamp: :desc).each do |log|
29
37
  tr
30
- th log_id
31
- th event
32
- th log_level
33
- th severity
34
- th timestamp
35
- th created_at
36
- th updated_at
37
- - @email.email_logs.order(timestamp: :desc).each do |log|
38
- tr
39
- td = log.log_id
40
- td = log.event
41
- td = log.log_level
42
- td = log.severity
43
- td = log.timestamp
44
- td = log.created_at
45
- td = log.updated_at
38
+ td = log.log_id
39
+ td = log.event
40
+ td = log.log_level
41
+ td = log.severity
42
+ td = log.timestamp
43
+ td = log.created_at
44
+ td = log.updated_at
@@ -1,6 +1,4 @@
1
1
  = pg_form_for @event, url: admin_eventos_path do |f|
2
- = f.mensajes_de_error
3
-
4
2
  = f.input :type, as: :select, collection: @notifier_types
5
3
  - if params[:plain_text]
6
4
  = link_to 'Change to rich text', url_for
@@ -1,10 +1,7 @@
1
- / # locals: (object: nil, asociable: false)
1
+ / # locals: (object: nil)
2
2
 
3
3
  div style="max-width: 22em"
4
4
  = pg_form_for(@user_account || object) do |f|
5
- = f.mensajes_de_error
6
-
7
- = hidden_field_tag :asociable, true if asociable
8
5
  = f.pg_associable :user
9
6
  = f.pg_associable :account
10
7
  = f.input :profiles
@@ -1,10 +1,7 @@
1
- / # locals: (object: nil, asociable: false)
1
+ / # locals: (object: nil)
2
2
 
3
3
  div style="max-width: 22em"
4
4
  = pg_form_for(@user || object) do |f|
5
- = f.mensajes_de_error
6
-
7
- = hidden_field_tag :asociable, true if asociable
8
5
  = f.input :nombre
9
6
  = f.input :apellido
10
7
  = f.input :email
@@ -2,6 +2,10 @@
2
2
  - content_for :actions do
3
3
  - @actions&.each do |link_args|
4
4
  = link_to(*link_args)
5
+ = link_to request.url, class: 'btn btn-sm btn-outline-primary',
6
+ data: { controller: :tooltip, 'bs-title': 'Actualizar' } do
7
+ i.bi.bi-arrow-clockwise
8
+ .ms-1
5
9
  - if @filtros.present?
6
10
  = render SearchBarTogglerComponent.new
7
11
  .ms-1
@@ -1,5 +1,4 @@
1
1
  - content_for :title do
2
2
  | Crear #{@clase_modelo.nombre_singular.downcase}
3
3
 
4
- .p-3
5
- = render 'form'
4
+ = render 'form'
@@ -1,4 +1,4 @@
1
- / # locals: (object: nil, asociable: false)
1
+ / # locals: (object: nil)
2
2
 
3
3
  .d-none
4
4
  / Preload
@@ -8,10 +8,7 @@
8
8
  h2 Ponete en contacto
9
9
  .d-inline-block style="width: 30em; max-width: 100%"
10
10
  div data-controller="pg_form"
11
- = pg_form_for(@mensaje_contacto || object, asociable:) do |f|
12
- = f.mensajes_de_error
13
-
14
- = hidden_field_tag :asociable, true if asociable
11
+ = pg_form_for(@mensaje_contacto || object) do |f|
15
12
  - unless user_signed_in?
16
13
  = f.input :nombre, input_html: { style: 'max-width: 22em' }
17
14
  = f.input :email, input_html: { style: 'max-width: 23em' }
@@ -0,0 +1,3 @@
1
+ Kaminari.configure do |config|
2
+ config.params_on_first_page = true
3
+ end
@@ -19,20 +19,20 @@ def pg_err(*args)
19
19
  pg_log(:error, *args)
20
20
  end
21
21
 
22
- def pg_warn(*args)
23
- pg_log(:warn, *args)
22
+ def pg_warn(*)
23
+ pg_log(:warn, *)
24
24
  end
25
25
 
26
- def pg_info(*args)
27
- pg_log(:info, *args)
26
+ def pg_info(*)
27
+ pg_log(:info, *)
28
28
  end
29
29
 
30
- def pg_debug(*args)
31
- pg_log(:debug, *args)
30
+ def pg_debug(*)
31
+ pg_log(:debug, *)
32
32
  end
33
33
 
34
- def pg_log(*args)
35
- PgEngine::PgLogger.log(*args)
34
+ def pg_log(*)
35
+ PgEngine::PgLogger.log(*)
36
36
  end
37
37
 
38
38
  module PgEngine
@@ -42,8 +42,8 @@ module PgEngine
42
42
  end
43
43
 
44
44
  class << self
45
- def log(type, *args)
46
- notify_all(build_msg(*args), type)
45
+ def log(type, *)
46
+ notify_all(build_msg(*), type)
47
47
  end
48
48
 
49
49
  private
@@ -200,9 +200,9 @@ RSpec.describe Admin::AccountsController do
200
200
  expect(account.reload.discarded_at).to be_present
201
201
  end
202
202
 
203
- it 'quita el elemento de la lista' do
203
+ it 'envía el pg-event' do
204
204
  subject
205
- expect(response.body).to include('turbo-stream action="remove"')
205
+ expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
206
206
  end
207
207
 
208
208
  context 'si hay redirect_to' do
@@ -162,9 +162,9 @@ RSpec.describe Admin::EmailLogsController do
162
162
  expect { subject }.to change(EmailLog, :count).by(-1)
163
163
  end
164
164
 
165
- it 'quita el elemento de la lista' do
165
+ it 'envía el pg-event' do
166
166
  subject
167
- expect(response.body).to include('turbo-stream action="remove"')
167
+ expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
168
168
  end
169
169
 
170
170
  context 'si hay redirect_to' do
@@ -153,9 +153,9 @@ RSpec.describe Admin::EmailsController do
153
153
  expect { subject }.to change(Email, :count).by(-1)
154
154
  end
155
155
 
156
- it 'quita el elemento de la lista' do
156
+ it 'envía el pg-event' do
157
157
  subject
158
- expect(response.body).to include('turbo-stream action="remove"')
158
+ expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
159
159
  end
160
160
 
161
161
  context 'si hay redirect_to' do
@@ -183,9 +183,9 @@ RSpec.describe Admin::UserAccountsController do
183
183
  expect { subject }.to change(UserAccount, :count).by(-1)
184
184
  end
185
185
 
186
- it 'quita el elemento de la lista' do
186
+ it 'envía el pg-event' do
187
187
  subject
188
- expect(response.body).to include('turbo-stream action="remove"')
188
+ expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
189
189
  end
190
190
 
191
191
  context 'si hay redirect_to' do
@@ -174,9 +174,9 @@ RSpec.describe Admin::UsersController do
174
174
  expect(user.reload.discarded_at).to be_present
175
175
  end
176
176
 
177
- it 'quita el elemento de la lista' do
177
+ it 'envía el pg-event' do
178
178
  subject
179
- expect(response.body).to include('turbo-stream action="remove"')
179
+ expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
180
180
  end
181
181
 
182
182
  context 'si hay redirect_to' do
@@ -0,0 +1,53 @@
1
+ require 'rails_helper'
2
+
3
+ describe PgEngine::FormHelper do
4
+ subject do
5
+ view_context.pg_form_for(cosa, **options) do |f|
6
+ f.submit 'ACEPTAR'
7
+ end
8
+ end
9
+
10
+ let(:options) do
11
+ {}
12
+ end
13
+
14
+ let(:using_modal) { false }
15
+
16
+ let(:view_context) do
17
+ cont = Admin::CosasController.new
18
+ cont.request = ActionDispatch::TestRequest.create
19
+ cont.view_context
20
+ end
21
+ let(:cosa) { Cosa.new }
22
+
23
+ before do
24
+ Current.namespace = :admin
25
+ end
26
+
27
+ it 'renders the form and the button' do
28
+ expect(subject).to include 'ACEPTAR'
29
+ expect(subject).to include '<form'
30
+ end
31
+
32
+ context 'when there are errors' do
33
+ let(:cosa) do
34
+ ret = Cosa.new(nombre: nil)
35
+ ret.validate
36
+ ret
37
+ end
38
+
39
+ it 'renders the errors' do
40
+ expect(subject).to include 'Por favor, revisá los campos obligatorios'
41
+ end
42
+
43
+ context 'and its requested not to render errors' do
44
+ let(:options) do
45
+ { render_errors: false }
46
+ end
47
+
48
+ it 'renders the errors' do
49
+ expect(subject).not_to include 'Por favor, revisá los campos obligatorios'
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,89 @@
1
+ # Initially generated with PgRails::SystemSpecGenerator
2
+ # https://github.com/martin-rosso/pg_rails
3
+
4
+ require 'rails_helper'
5
+
6
+ # By default uses selenium_chrome_headless_iphone driver
7
+ # run with DRIVER environment variable to override, eg:
8
+ #
9
+ # DRIVER=selenium rspec
10
+ describe 'Modal windows' do
11
+ subject(:visitar) do
12
+ visit '/admin/cosas'
13
+ end
14
+
15
+ let(:logged_user) { create :user, :developer }
16
+ let(:account) { logged_user.current_account }
17
+ let!(:categoria_de_cosa) { create :categoria_de_cosa }
18
+
19
+ before do
20
+ login_as logged_user
21
+ end
22
+
23
+ describe 'crear con modal' do
24
+ it do
25
+ visitar
26
+ click_on 'Cargar coso'
27
+ select 'Completar'
28
+ select categoria_de_cosa.to_s
29
+ find('.modal input[type=submit]').click
30
+ expect(page).to have_text 'Por favor, revisá los campos obligatorios'
31
+ fill_in 'Nombre', with: 'bla'
32
+ find('.modal input[type=submit]').click
33
+ expect(page).to have_text 'bla'
34
+ end
35
+ end
36
+
37
+ describe 'show con modal' do
38
+ let!(:cosa) { create :cosa, categoria_de_cosa: }
39
+
40
+ it do
41
+ visit '/admin/cosas/' + cosa.to_param
42
+ click_on 'Ver categoría'
43
+ expect(page).to have_css '.modal', text: categoria_de_cosa.nombre
44
+ end
45
+ end
46
+
47
+ describe 'edit con modal' do
48
+ let!(:cosa) { create :cosa, categoria_de_cosa: }
49
+
50
+ it do
51
+ visit '/admin/cosas/' + cosa.to_param
52
+ click_on 'Modificar'
53
+ fill_in 'Nombre', with: ''
54
+ find('.modal input[type=submit]').click
55
+ expect(page).to have_text 'Por favor, revisá los campos obligatorios'
56
+ fill_in 'Nombre', with: 'bla'
57
+ find('.modal input[type=submit]').click
58
+ expect(page).to have_text 'bla'
59
+ end
60
+ end
61
+
62
+ describe 'destroy con modal' do
63
+ before { create :cosa, categoria_de_cosa: }
64
+
65
+ it do
66
+ visit '/admin/cosas'
67
+ find('span[title=Ver] a').click
68
+ accept_confirm do
69
+ find('.modal span[title=Eliminar] a').click
70
+ end
71
+ expect(page).to have_text 'No hay cosos aún'
72
+ end
73
+
74
+ context 'cuando da error' do
75
+ before do
76
+ allow_any_instance_of(Cosa).to receive(:discard).and_return(false)
77
+ end
78
+
79
+ it do
80
+ visit '/admin/cosas'
81
+ find('span[title=Ver] a').click
82
+ accept_confirm do
83
+ find('.modal span[title=Eliminar] a').click
84
+ end
85
+ expect(page).to have_text 'No se pudo eliminar el registro'
86
+ end
87
+ end
88
+ end
89
+ end
@@ -13,7 +13,7 @@ describe 'Enviar email' do
13
13
  # click_on 'Enviar'
14
14
  # expect(page).to have_text 'revisá los campos obligatorios'
15
15
  fill_in 'email_to', with: Faker::Internet.email
16
- click_on 'Enviar'
16
+ click_on 'Crear Email'
17
17
  end
18
18
 
19
19
  around do |example|
@@ -1,3 +1,27 @@
1
1
  import './config'
2
2
  import './channels'
3
3
  import './controllers'
4
+ import './elements'
5
+
6
+ import { Turbo } from '@hotwired/turbo-rails'
7
+
8
+ document.addEventListener('pg:record-created', (ev) => {
9
+ Turbo.visit(window.location)
10
+ setTimeout(() => {
11
+ Turbo.cache.clear()
12
+ }, 1000)
13
+ })
14
+
15
+ document.addEventListener('pg:record-updated', (ev) => {
16
+ Turbo.visit(window.location)
17
+ setTimeout(() => {
18
+ Turbo.cache.clear()
19
+ }, 1000)
20
+ })
21
+
22
+ document.addEventListener('pg:record-destroyed', (ev) => {
23
+ Turbo.visit(window.location)
24
+ setTimeout(() => {
25
+ Turbo.cache.clear()
26
+ }, 1000)
27
+ })
@@ -48,22 +48,23 @@ export default class extends Controller {
48
48
  responseKind: 'json'
49
49
  })
50
50
 
51
+ let json = null
51
52
  if (response.ok) {
52
- const json = await response.json
53
+ json = await response.json
53
54
  fechaEl.value = json.date
54
55
  this.element.querySelector('button').removeAttribute('disabled')
55
56
  this.closePopover()
56
57
  } else {
57
58
  let message = 'Hubo un error'
58
59
  try {
59
- const json = await response.json
60
+ json = await response.json
60
61
  message = json.html || 'Hubo un error'
61
- } catch {
62
+ } catch (e) {
62
63
  // JSON parser error
64
+ Rollbar.error(e)
63
65
  }
64
66
  flashMessage(message, 'warning', true)
65
67
  this.element.querySelector('button').removeAttribute('disabled')
66
- Rollbar.error('date jumper error', json)
67
68
  }
68
69
  }
69
70
  }
@@ -5,9 +5,11 @@ export default class extends Controller {
5
5
  popover = null
6
6
 
7
7
  connect () {
8
+ const container = this.element.closest('.modal-body') ? '.modal-body' : 'body'
8
9
  this.popover = new bootstrap.Popover(this.element, {
9
10
  // WARNING: don't use for user input html
10
11
  sanitize: false,
12
+ container,
11
13
  template: `
12
14
  <div class="popover" role="tooltip" data-controller="popover">
13
15
  <div class="popover-arrow"></div>
@@ -16,8 +18,7 @@ export default class extends Controller {
16
18
  <div class="popover-body">
17
19
  </div>
18
20
  </div>
19
- `,
20
- container: 'body'
21
+ `
21
22
  })
22
23
  }
23
24
 
@@ -0,0 +1 @@
1
+ import './pg_event'
@@ -0,0 +1,12 @@
1
+ class PgEventElement extends HTMLElement {
2
+ connectedCallback () {
3
+ this.dispatchEvent(new MessageEvent(this.dataset.eventName, { bubbles: true, data: this }))
4
+ }
5
+
6
+ disconnectedCallback () {
7
+ }
8
+ }
9
+
10
+ if (customElements.get('pg-event') === undefined) {
11
+ customElements.define('pg-event', PgEventElement)
12
+ }
@@ -1,5 +1,4 @@
1
1
  <%= pg_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
2
- <%= f.mensajes_de_error %>
3
2
  <%= f.full_error :confirmation_token %>
4
3
 
5
4
  <div class="form-inputs">
@@ -1,8 +1,6 @@
1
1
  <h2><%= t(".change_your_password") %></h2>
2
2
 
3
3
  <%= pg_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
4
- <%= f.mensajes_de_error %>
5
-
6
4
  <%= f.input :reset_password_token, as: :hidden %>
7
5
  <%= f.full_error :reset_password_token %>
8
6
 
@@ -1,8 +1,6 @@
1
1
  <h2><%= t(".forgot_your_password") %></h2>
2
2
 
3
3
  <%= pg_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4
- <%= f.mensajes_de_error %>
5
-
6
4
  <div class="form-inputs">
7
5
  <%= f.input :email,
8
6
  required: true,
@@ -1,8 +1,6 @@
1
1
  <h2><%= t(".title", resource: devise_i18n_fix_model_name_case(resource.model_name.human, i18n_key: "registrations.edit.title")) %></h2>
2
2
 
3
3
  <%= pg_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
- <%= f.mensajes_de_error %>
5
-
6
4
  <div class="form-inputs">
7
5
  <%= f.input :email, required: true, autofocus: true %>
8
6
  <%= f.input :nombre, required: true %>