pg_rails 7.0.8.pre.alpha.36 → 7.0.8.pre.alpha.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/pg_engine/app/admin/users.rb +1 -0
- data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +1 -1
- data/pg_engine/app/controllers/pg_engine/base_controller.rb +4 -0
- data/pg_engine/app/decorators/pg_engine/base_decorator.rb +13 -6
- data/pg_engine/app/helpers/pg_engine/form_helper.rb +6 -0
- data/pg_engine/app/helpers/pg_engine/print_helper.rb +7 -1
- data/pg_engine/app/lib/pg_form_builder.rb +1 -17
- data/pg_engine/config/locales/es.yml +0 -2
- data/pg_engine/spec/lib/pg_form_builder_spec.rb +0 -5
- data/pg_layout/app/javascript/controllers/pg_form_controller.js +10 -7
- data/pg_rails/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 683d6ba7d56764dfcf541c11cc57cd17a4e7a07db3cc5381d0b265151370e151
|
4
|
+
data.tar.gz: 6cab86107a332dcf819966a6458b18028dbb2b5e13fc875117f9685217c77c27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d29164b89d0b98c7e884b32be394f8a13244e5c6f4429fa4c0432ca86f548213a267393c8b1ffae197947130cc668ade1cd2e4b2848e9d09b4842f5422c8684c
|
7
|
+
data.tar.gz: 01a039fa9de8f00165a9f6a883c08383cffcb4b478598a38da0661944e2eadce7a342724c9a40e4e1c7c60d5bc7e8258c5ab01c9788b97a6fef61fd61567a94e
|
@@ -46,6 +46,10 @@ module PgEngine
|
|
46
46
|
# [:alert, :notice, :warning, :success]
|
47
47
|
add_flash_types :warning, :success
|
48
48
|
|
49
|
+
before_action do
|
50
|
+
console if params[:show_web_console]
|
51
|
+
end
|
52
|
+
|
49
53
|
before_action do
|
50
54
|
@breakpoint_navbar_expand = 'md'
|
51
55
|
@navbar_opened_class = if cookies[:navbar_expand] == 'false' || !user_signed_in?
|
@@ -78,15 +78,11 @@ module PgEngine
|
|
78
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
|
-
|
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
|
81
|
+
helpers.content_tag :span, rel: :tooltip, title: submit_default_value do
|
86
82
|
helpers.link_to(new_object_url, class: "btn btn-sm #{klass}",
|
87
83
|
remote:) do
|
88
84
|
helpers.content_tag(:span, nil,
|
89
|
-
class: clase_icono('plus').to_s) + "<span class='d-none d-sm-inline'> #{
|
85
|
+
class: clase_icono('plus').to_s) + "<span class='d-none d-sm-inline'> #{submit_default_value}</span>".html_safe
|
90
86
|
end
|
91
87
|
end
|
92
88
|
end
|
@@ -111,6 +107,17 @@ module PgEngine
|
|
111
107
|
pg_namespace.present? ? [pg_namespace, object.class] : object.class
|
112
108
|
end
|
113
109
|
|
110
|
+
# actionview-7.1.3.2/lib/action_view/helpers/form_helper.rb
|
111
|
+
def submit_default_value
|
112
|
+
key = :create
|
113
|
+
model = object.model_name.human
|
114
|
+
defaults = []
|
115
|
+
defaults << :"helpers.submit.#{object.model_name.i18n_key}.#{key}"
|
116
|
+
defaults << :"helpers.submit.#{key}"
|
117
|
+
defaults << "#{key.to_s.humanize} #{model}"
|
118
|
+
I18n.t(defaults.shift, model:, default: defaults)
|
119
|
+
end
|
120
|
+
|
114
121
|
private
|
115
122
|
|
116
123
|
def clase_icono(icono)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module PgEngine
|
4
4
|
module FormHelper
|
5
5
|
def pg_form_for(object, *args, &)
|
6
|
+
resource = object
|
6
7
|
if object.is_a? PgEngine::BaseDecorator
|
7
8
|
object = object.target_object
|
8
9
|
elsif object.is_a?(PgEngine::BaseRecord) &&
|
@@ -21,6 +22,11 @@ module PgEngine
|
|
21
22
|
'pg-form'
|
22
23
|
end
|
23
24
|
|
25
|
+
if resource.errors.any?
|
26
|
+
options[:html][:data] ||= {}
|
27
|
+
options[:html][:data][:errors] = resource.errors.details.to_json
|
28
|
+
end
|
29
|
+
|
24
30
|
simple_form_for(object, *(args << options), &)
|
25
31
|
end
|
26
32
|
|
@@ -101,7 +101,13 @@ module PgEngine
|
|
101
101
|
def print_currency(number, simbolo: '$', precision: nil)
|
102
102
|
return if number.blank?
|
103
103
|
|
104
|
-
|
104
|
+
# FIXME: testear
|
105
|
+
precision ||= if (number % 0.01).positive?
|
106
|
+
3
|
107
|
+
else
|
108
|
+
(number % 1).positive? ? 2 : 0
|
109
|
+
end
|
110
|
+
|
105
111
|
"#{simbolo} #{number_with_precision(number, delimiter: '.', separator: ',',
|
106
112
|
precision:)}"
|
107
113
|
end
|
@@ -32,23 +32,7 @@ class PgFormBuilder < SimpleForm::FormBuilder
|
|
32
32
|
base_message = (base_errors.map(&:to_s).join('<br>') if base_errors.present?)
|
33
33
|
base_tag = error_notification(message: base_message, class: 'alert alert-danger') if base_message
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
"#{title}#{base_tag}#{all_errors_tag}".html_safe # rubocop:disable Rails/OutputSafety
|
38
|
-
end
|
39
|
-
|
40
|
-
def build_all_errors_tag
|
41
|
-
details = object.errors.details.dup
|
42
|
-
details.delete(:base)
|
43
|
-
not_base_errors = details.any?
|
44
|
-
|
45
|
-
return unless not_base_errors
|
46
|
-
|
47
|
-
# TODO!: poder pasar un block para que no se ejecute si no se va a loguear por el log level
|
48
|
-
# TODO: quizá esta warning loguearla pero no mandarla a rollbar por si son demasiadas
|
49
|
-
pg_warn "Not base errors en pg_form: #{object.errors.details}. Record: #{object.inspect}", :warn
|
50
|
-
|
51
|
-
"<span class='not_base_errors' data-errors='#{object.errors.details.to_json}'></span>"
|
35
|
+
"#{title}#{base_tag}".html_safe # rubocop:disable Rails/OutputSafety
|
52
36
|
end
|
53
37
|
|
54
38
|
def mensaje
|
@@ -15,9 +15,6 @@ describe PgFormBuilder do
|
|
15
15
|
describe '#mensajes_de_error' do
|
16
16
|
subject { instancia.mensajes_de_error }
|
17
17
|
|
18
|
-
# expect(subject)
|
19
|
-
# it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
|
20
|
-
|
21
18
|
context 'cuando solo tiene errores de presencia' do
|
22
19
|
before do
|
23
20
|
categoria.nombre = nil
|
@@ -25,7 +22,6 @@ describe PgFormBuilder do
|
|
25
22
|
end
|
26
23
|
|
27
24
|
it { expect(subject).to include 'Por favor, revisá los campos obligatorios:' }
|
28
|
-
it { expect(subject).to include 'not_base_errors' }
|
29
25
|
end
|
30
26
|
|
31
27
|
context 'cuando solo tiene errores de :base' do
|
@@ -35,7 +31,6 @@ describe PgFormBuilder do
|
|
35
31
|
end
|
36
32
|
|
37
33
|
it { expect(subject).to include 'Por favor, revisá los siguientes errores' }
|
38
|
-
it { expect(subject).not_to include 'not_base_errors' }
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
@@ -10,16 +10,19 @@ export default class extends Controller {
|
|
10
10
|
}
|
11
11
|
})
|
12
12
|
})
|
13
|
-
const
|
14
|
-
|
15
|
-
|
16
|
-
const
|
17
|
-
if (!
|
18
|
-
console.error(notBaseErrors.dataset.errors)
|
19
|
-
Rollbar.error(notBaseErrors.dataset.errors)
|
13
|
+
const errorTitle = this.element.querySelector('.error-title')
|
14
|
+
if (errorTitle) {
|
15
|
+
const invalidField = document.querySelector('.is-invalid')
|
16
|
+
const baseAlert = document.querySelector('.alert-danger')
|
17
|
+
if (!invalidField && !baseAlert) {
|
20
18
|
const errorTitle = this.element.querySelector('.error-title')
|
19
|
+
// FIXME: testear con capybara
|
21
20
|
errorTitle.innerText = 'Lo lamentamos mucho pero ocurrió algo inesperado. Por favor, intentá nuevamente o ponete en contacto con nosotros.'
|
22
21
|
// FIXME: link a contacto
|
22
|
+
const form = this.element.querySelector('form')
|
23
|
+
const errorMsg = `${form.id} - ${form.action} - ${form.dataset.errors}`
|
24
|
+
console.error(errorMsg)
|
25
|
+
Rollbar.error(errorMsg)
|
23
26
|
}
|
24
27
|
}
|
25
28
|
}
|
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.38
|
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-04-
|
11
|
+
date: 2024-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|