pg_rails 7.0.8.pre.alpha.8 → 7.0.8.pre.alpha.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/pg_engine/app/controllers/admin/users_controller.rb +16 -4
- data/pg_engine/app/controllers/{pg_engine/resource_helper.rb → concerns/pg_engine/resource.rb} +1 -1
- data/pg_engine/app/controllers/pg_engine/base_controller.rb +2 -2
- data/pg_engine/app/controllers/pg_engine/devise_controller.rb +16 -3
- data/pg_engine/app/helpers/pg_engine/print_helper.rb +4 -3
- data/pg_engine/app/lib/pg_engine/error_helper.rb +37 -0
- data/pg_engine/app/lib/pg_form_builder.rb +18 -3
- data/pg_engine/app/models/pg_engine/base_record.rb +12 -0
- data/pg_engine/app/models/user.rb +7 -4
- data/pg_engine/app/views/pg_engine/base/edit.html.slim +5 -0
- data/pg_engine/app/views/pg_engine/base/new.html.slim +5 -0
- data/pg_engine/config/locales/es.yml +4 -10
- data/pg_engine/config/routes.rb +1 -0
- data/pg_engine/config/simple_form/simple_form_bootstrap.rb +3 -1
- data/pg_engine/db/migrate/20240305200900_nombre_user.rb +6 -0
- data/pg_engine/db/seeds.rb +1 -1
- data/pg_engine/lib/pg_engine/engine.rb +12 -8
- data/pg_engine/lib/tasks/auto_anotar_modelos.rake +4 -3
- data/pg_engine/spec/controllers/concerns/pg_engine/error_helper_spec.rb +62 -0
- data/pg_engine/spec/controllers/devise/registrations_controller_spec.rb +33 -0
- data/pg_engine/spec/controllers/devise/sessions_controller_spec.rb +18 -0
- data/pg_engine/spec/factories/users.rb +2 -0
- data/pg_engine/spec/lib/pg_form_builder_spec.rb +32 -0
- data/pg_engine/spec/models/pg_engine/base_record_spec.rb +15 -0
- data/pg_layout/app/javascript/utils.ts +3 -21
- data/pg_layout/app/lib/navbar.rb +13 -3
- data/pg_layout/app/views/devise/registrations/edit.html.erb +2 -0
- data/pg_layout/app/views/devise/registrations/new.html.erb +2 -0
- data/pg_layout/app/views/devise/sessions/new.html.erb +11 -0
- data/pg_layout/app/views/pg_layout/_flash.html.slim +2 -1
- data/pg_layout/app/views/pg_layout/_navbar.html.erb +13 -2
- data/pg_rails/lib/version.rb +1 -1
- data/pg_scaffold/lib/generators/pg_slim/pg_slim_generator.rb +2 -2
- data/pg_scaffold/lib/generators/pg_slim/templates/_form.html.slim +1 -1
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3efd952ef548d103ed1c4aea21b903f039792ed601fc66e93fb5b84dce4d39d
|
4
|
+
data.tar.gz: 148ae25de52ab06846c1b7b313f6f87db0d6d6ba502a9186104559e0e37ec114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b63352e0ac30ff6f3c7a22e3a2fb73f8918ee91dfefe51b2c8371915c9d7adde99eb114c1ba935387182fa10966d0c5776c672e477486cff17a82993ff68fb
|
7
|
+
data.tar.gz: 1fda6ee9f5416f813e811268f307b87638b69de4a3db4659a7259c6101dc6b8281d9b351e92998e517a0d492cc39eea71780add28b2c240c4971aa26f87a2000
|
data/README.md
CHANGED
@@ -26,22 +26,34 @@ module Admin
|
|
26
26
|
pg_respond_update
|
27
27
|
end
|
28
28
|
|
29
|
+
skip_before_action :authenticate_user!, only: [:login_as]
|
30
|
+
|
31
|
+
# :nocov:
|
32
|
+
def login_as
|
33
|
+
if current_user&.developer? || Rails.env.development?
|
34
|
+
usuario = User.find(params[:id])
|
35
|
+
sign_in(:user, usuario)
|
36
|
+
end
|
37
|
+
redirect_to '/'
|
38
|
+
end
|
39
|
+
# :nocov:
|
40
|
+
|
29
41
|
private
|
30
42
|
|
31
43
|
def atributos_permitidos
|
32
|
-
%i[email password developer]
|
44
|
+
%i[email nombre apellido password developer]
|
33
45
|
end
|
34
46
|
|
35
47
|
def atributos_para_buscar
|
36
|
-
%i[email developer]
|
48
|
+
%i[email nombre apellido developer]
|
37
49
|
end
|
38
50
|
|
39
51
|
def atributos_para_listar
|
40
|
-
%i[email developer]
|
52
|
+
%i[email nombre apellido developer]
|
41
53
|
end
|
42
54
|
|
43
55
|
def atributos_para_mostrar
|
44
|
-
%i[email developer]
|
56
|
+
%i[email nombre apellido developer]
|
45
57
|
end
|
46
58
|
end
|
47
59
|
end
|
@@ -1,9 +1,22 @@
|
|
1
1
|
module PgEngine
|
2
2
|
class DeviseController < ApplicationController
|
3
|
-
|
3
|
+
before_action :configure_permitted_parameters
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
layout :layout_by_resource
|
6
|
+
|
7
|
+
def layout_by_resource
|
8
|
+
if controller_name == 'registrations' && action_name.in?(%w[edit update])
|
9
|
+
'pg_layout/layout'
|
10
|
+
else
|
11
|
+
'pg_layout/devise'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def configure_permitted_parameters
|
18
|
+
devise_parameter_sanitizer.permit(:sign_up, keys: %i[nombre apellido])
|
19
|
+
devise_parameter_sanitizer.permit(:account_update, keys: %i[nombre apellido])
|
7
20
|
end
|
8
21
|
end
|
9
22
|
end
|
@@ -98,11 +98,12 @@ module PgEngine
|
|
98
98
|
'No'
|
99
99
|
end
|
100
100
|
|
101
|
-
def print_currency(number,
|
101
|
+
def print_currency(number, simbolo: '$')
|
102
102
|
return if number.blank?
|
103
103
|
|
104
|
-
|
105
|
-
|
104
|
+
precision = (number % 1).positive? ? 2 : 0
|
105
|
+
"#{simbolo} #{number_with_precision(number, delimiter: '.', separator: ',',
|
106
|
+
precision:)}"
|
106
107
|
end
|
107
108
|
|
108
109
|
def simbolo_moneda(moneda)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module PgEngine
|
2
|
+
module ErrorHelper
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def merge_association_errors(object, details, assoc_key)
|
6
|
+
details = details.except(assoc_key)
|
7
|
+
assoc_items = object.send(assoc_key).map(&:errors).map(&:details)
|
8
|
+
merged = assoc_items.inject({}) { |acc, el| acc.merge(el) }
|
9
|
+
merged = merged.transform_values { |errs| errs.pluck(:error) }
|
10
|
+
details.merge(merged)
|
11
|
+
end
|
12
|
+
|
13
|
+
def error_types(object, associations: [])
|
14
|
+
details = object.errors.details.transform_values do |errs|
|
15
|
+
errs.pluck(:error)
|
16
|
+
end
|
17
|
+
associations.each do |assoc_key|
|
18
|
+
next unless details.key? assoc_key
|
19
|
+
|
20
|
+
details = merge_association_errors(object, details, assoc_key)
|
21
|
+
end
|
22
|
+
details.values.flatten.uniq
|
23
|
+
end
|
24
|
+
|
25
|
+
def error_message_for(object, associations: [])
|
26
|
+
types = error_types(object, associations:)
|
27
|
+
|
28
|
+
if types == [:blank]
|
29
|
+
:only_presence_errors
|
30
|
+
elsif types.include? :blank
|
31
|
+
:multiple_error_types
|
32
|
+
elsif types.present?
|
33
|
+
:not_presence_errors
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -2,12 +2,27 @@
|
|
2
2
|
|
3
3
|
class PgFormBuilder < SimpleForm::FormBuilder
|
4
4
|
include PgAssociable::FormBuilderMethods
|
5
|
+
include PgEngine::ErrorHelper
|
5
6
|
|
6
7
|
def mensajes_de_error
|
7
|
-
|
8
|
-
|
8
|
+
base_errors = object.errors[:base]
|
9
|
+
base_message = (base_errors.map(&:to_s).join('<br>') if base_errors.present?)
|
10
|
+
title = error_notification(message: mensaje, class: 'text-danger mb-2') if mensaje
|
11
|
+
base_tag = error_notification(message: base_message, class: 'alert alert-danger') if base_message
|
12
|
+
(title || '') + (base_tag || '')
|
13
|
+
end
|
14
|
+
|
15
|
+
def mensaje
|
16
|
+
scope = error_message_for(object, associations:)
|
17
|
+
return if scope.blank?
|
18
|
+
|
19
|
+
I18n.t("simple_form.error_notification.#{scope}")
|
20
|
+
end
|
9
21
|
|
10
|
-
|
22
|
+
def associations
|
23
|
+
object.class.reflect_on_all_associations
|
24
|
+
.select { |a| a.instance_of? ActiveRecord::Reflection::HasManyReflection }
|
25
|
+
.map(&:name)
|
11
26
|
end
|
12
27
|
|
13
28
|
map_type :date, to: PgEngine::FechaInput
|
@@ -33,6 +33,18 @@ module PgEngine
|
|
33
33
|
model_name.human(count: 1)
|
34
34
|
end
|
35
35
|
|
36
|
+
def self.human_attribute_name(attribute, options = {})
|
37
|
+
if attribute.to_s.ends_with?('_text')
|
38
|
+
# Si es un enumerized
|
39
|
+
super(attribute[0..-6], options)
|
40
|
+
elsif attribute.to_s.ends_with?('_f')
|
41
|
+
# Si es un decorated method
|
42
|
+
super(attribute[0..-3], options)
|
43
|
+
else
|
44
|
+
super(attribute, options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
36
48
|
def to_s
|
37
49
|
%i[nombre name].each do |campo|
|
38
50
|
return "#{send(campo)} ##{id}" if try(campo).present?
|
@@ -36,10 +36,9 @@ class User < ApplicationRecord
|
|
36
36
|
# ApplicationRecord should be defined on Application
|
37
37
|
|
38
38
|
# Include default devise modules. Others available are:
|
39
|
-
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
40
39
|
devise :database_authenticatable, :registerable,
|
41
40
|
:recoverable, :rememberable, :validatable,
|
42
|
-
:
|
41
|
+
:lockable, :timeoutable, :trackable, :confirmable
|
43
42
|
|
44
43
|
audited
|
45
44
|
include Discard::Model
|
@@ -47,12 +46,16 @@ class User < ApplicationRecord
|
|
47
46
|
has_many :user_accounts
|
48
47
|
has_many :accounts, through: :user_accounts
|
49
48
|
|
50
|
-
validates :email, presence: true
|
49
|
+
validates :email, :nombre, :apellido, presence: true
|
51
50
|
|
52
51
|
scope :query, ->(param) { where('email ILIKE ?', "%#{param}%") }
|
53
52
|
|
54
53
|
def to_s
|
55
|
-
|
54
|
+
nombre_completo
|
55
|
+
end
|
56
|
+
|
57
|
+
def nombre_completo
|
58
|
+
"#{nombre} #{apellido}"
|
56
59
|
end
|
57
60
|
|
58
61
|
def current_account
|
@@ -7,15 +7,6 @@ es:
|
|
7
7
|
creado_por: Creado por
|
8
8
|
ancestry:
|
9
9
|
exclude_self: No puede ser hijx de si mismx
|
10
|
-
simple_form:
|
11
|
-
# labels:
|
12
|
-
# user:
|
13
|
-
# username: 'User name'
|
14
|
-
# password: 'Password'
|
15
|
-
# hints:
|
16
|
-
error_notification:
|
17
|
-
default_message: "hubo algunos errores:"
|
18
|
-
|
19
10
|
simple_form:
|
20
11
|
"yes": 'Sí'
|
21
12
|
"no": 'No'
|
@@ -26,7 +17,10 @@ es:
|
|
26
17
|
# When using html, text and mark won't be used.
|
27
18
|
# html: '<abbr title="required">*</abbr>'
|
28
19
|
error_notification:
|
29
|
-
default_message: "Por favor, revisá los errores
|
20
|
+
default_message: "Por favor, revisá los siguientes errores:"
|
21
|
+
not_presence_errors: "Por favor, revisá los siguientes errores:"
|
22
|
+
only_presence_errors: 'Por favor, revisá los campos obligatorios:'
|
23
|
+
multiple_error_types: 'Por favor, revisá los campos obligatorios y otros errores:'
|
30
24
|
# Examples
|
31
25
|
# labels:
|
32
26
|
# defaults:
|
data/pg_engine/config/routes.rb
CHANGED
@@ -32,7 +32,7 @@ SimpleForm.setup do |config|
|
|
32
32
|
config.include_default_input_wrapper_class = false
|
33
33
|
|
34
34
|
# CSS class to add for error notification helper.
|
35
|
-
config.error_notification_class = '
|
35
|
+
config.error_notification_class = ''
|
36
36
|
|
37
37
|
# Method used to tidy up errors. Specify any Rails Array method.
|
38
38
|
# :first lists the first message for each field.
|
@@ -57,6 +57,7 @@ SimpleForm.setup do |config|
|
|
57
57
|
b.use :label, class: 'form-label'
|
58
58
|
b.use :input, class: 'form-control', error_class: 'is-invalid'
|
59
59
|
b.use :full_error, wrap_with: { class: 'invalid-feedback' }
|
60
|
+
b.optional :error, wrap_with: { class: 'invalid-feedback' }
|
60
61
|
b.use :hint, wrap_with: { class: 'form-text' }
|
61
62
|
end
|
62
63
|
|
@@ -66,6 +67,7 @@ SimpleForm.setup do |config|
|
|
66
67
|
b.use :label, class: 'form-label'
|
67
68
|
b.use :input, class: 'form-select', error_class: 'is-invalid'
|
68
69
|
b.use :full_error, wrap_with: { class: 'invalid-feedback' }
|
70
|
+
b.optional :error, wrap_with: { class: 'invalid-feedback' }
|
69
71
|
b.use :hint, wrap_with: { class: 'form-text' }
|
70
72
|
end
|
71
73
|
|
data/pg_engine/db/seeds.rb
CHANGED
@@ -3,6 +3,6 @@ DatabaseCleaner.clean_with(:truncation, except: %w(ar_internal_metadata users ac
|
|
3
3
|
MAIL = 'mrosso10@gmail.com'
|
4
4
|
|
5
5
|
unless User.where(email: MAIL).exists?
|
6
|
-
FactoryBot.create :user, email: MAIL, password: 'admin123',
|
6
|
+
FactoryBot.create :user, email: MAIL, nombre: 'Martín', apellido: 'Rosso', password: 'admin123',
|
7
7
|
confirmed_at: Time.now, developer: true
|
8
8
|
end
|
@@ -47,16 +47,20 @@ module PgEngine
|
|
47
47
|
initializer 'byebug_bullet' do
|
48
48
|
if Rails.env.local?
|
49
49
|
# Byebug
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
# :nocov:
|
51
|
+
if ENV['RUBY_DEBUG_OPEN']
|
52
|
+
require 'byebug/core'
|
53
|
+
begin
|
54
|
+
Byebug.start_server 'localhost', ENV.fetch('BYEBUG_SERVER_PORT', 8989).to_i
|
55
|
+
if ENV.fetch('SLEEP_AFTER_BYEBUG', false)
|
56
|
+
puts 'waiting 3 secs after starting byebug server for connections'
|
57
|
+
sleep 3
|
58
|
+
end
|
59
|
+
rescue Errno::EADDRINUSE
|
60
|
+
Rails.logger.debug 'Byebug server already running'
|
56
61
|
end
|
57
|
-
rescue Errno::EADDRINUSE
|
58
|
-
Rails.logger.debug 'Byebug server already running'
|
59
62
|
end
|
63
|
+
# :nocov:
|
60
64
|
|
61
65
|
# Bullet
|
62
66
|
Bullet.enable = true
|
@@ -19,9 +19,10 @@ if Rails.env.development?
|
|
19
19
|
'position_in_serializer' => 'before',
|
20
20
|
'show_foreign_keys' => 'true',
|
21
21
|
'show_complete_foreign_keys' => 'false',
|
22
|
-
'show_indexes' => '
|
23
|
-
'simple_indexes' => '
|
24
|
-
'model_dir' => 'app/models',
|
22
|
+
'show_indexes' => 'false',
|
23
|
+
'simple_indexes' => 'true',
|
24
|
+
'model_dir' => ['app/models', 'app/overrides'],
|
25
|
+
# 'model_dir' => 'app/models',
|
25
26
|
'root_dir' => '',
|
26
27
|
'include_version' => 'false',
|
27
28
|
'require' => '',
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe PgEngine::ErrorHelper do
|
4
|
+
let(:dummy) { Class.new { include PgEngine::ErrorHelper }.new }
|
5
|
+
|
6
|
+
describe '#error_message_for' do
|
7
|
+
subject do
|
8
|
+
categoria.validate
|
9
|
+
dummy.error_message_for(categoria, associations: [:cosas])
|
10
|
+
end
|
11
|
+
|
12
|
+
let!(:categoria) { create :categoria_de_cosa }
|
13
|
+
|
14
|
+
before { create_list :cosa, 2, categoria_de_cosa: categoria }
|
15
|
+
|
16
|
+
it do
|
17
|
+
expect(subject).to be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'cuando solo tiene errores de presencia' do
|
21
|
+
before do
|
22
|
+
categoria.nombre = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it do
|
26
|
+
expect(subject).to eq :only_presence_errors
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'cuando solo tiene otros errores' do
|
31
|
+
before do
|
32
|
+
categoria.validate_aux = true
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
expect(subject).to eq :not_presence_errors
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'cuando tiene multiples errores' do
|
41
|
+
before do
|
42
|
+
categoria.validate_aux = true
|
43
|
+
categoria.nombre = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it do
|
47
|
+
expect(subject).to eq :multiple_error_types
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'cuando tiene errores anidados' do
|
52
|
+
before do
|
53
|
+
categoria.reload
|
54
|
+
categoria.cosas[0].nombre = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it do
|
58
|
+
expect(subject).to eq :only_presence_errors
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Devise::RegistrationsController do
|
4
|
+
before do
|
5
|
+
# rubocop:disable RSpec/InstanceVariable
|
6
|
+
@request.env['devise.mapping'] = Devise.mappings[:user]
|
7
|
+
# rubocop:enable RSpec/InstanceVariable
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
subject { get :new }
|
12
|
+
|
13
|
+
it do
|
14
|
+
subject
|
15
|
+
expect(response).to have_http_status(:ok)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#edit' do
|
20
|
+
subject { get :edit }
|
21
|
+
|
22
|
+
let(:logger_user) { create :user, :admin }
|
23
|
+
|
24
|
+
before do
|
25
|
+
sign_in logger_user
|
26
|
+
end
|
27
|
+
|
28
|
+
it do
|
29
|
+
subject
|
30
|
+
expect(response).to have_http_status(:ok)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Devise::SessionsController do
|
4
|
+
before do
|
5
|
+
# rubocop:disable RSpec/InstanceVariable
|
6
|
+
@request.env['devise.mapping'] = Devise.mappings[:user]
|
7
|
+
# rubocop:enable RSpec/InstanceVariable
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
subject { get :new }
|
12
|
+
|
13
|
+
it do
|
14
|
+
subject
|
15
|
+
expect(response).to have_http_status(:ok)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe PgFormBuilder do
|
4
|
+
let(:categoria) { create :categoria_de_cosa }
|
5
|
+
let(:template) { double }
|
6
|
+
let(:instancia) { described_class.new('bla', categoria, template, {}) }
|
7
|
+
|
8
|
+
before { create_list :cosa, 2, categoria_de_cosa: categoria }
|
9
|
+
|
10
|
+
describe '#mensaje' do
|
11
|
+
subject { instancia.mensaje }
|
12
|
+
|
13
|
+
context 'cuando solo tiene errores de presencia' do
|
14
|
+
before do
|
15
|
+
categoria.nombre = nil
|
16
|
+
categoria.validate
|
17
|
+
end
|
18
|
+
|
19
|
+
it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'cuando solo tiene errores de presencia en nested' do
|
23
|
+
before do
|
24
|
+
categoria.reload
|
25
|
+
categoria.cosas[0].nombre = nil
|
26
|
+
categoria.validate
|
27
|
+
end
|
28
|
+
|
29
|
+
it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe PgEngine::BaseRecord do
|
4
|
+
describe '#human_attribute_name' do
|
5
|
+
it do
|
6
|
+
obj = described_class.human_attribute_name('bla_text')
|
7
|
+
expect(obj).to eq described_class.human_attribute_name('bla')
|
8
|
+
end
|
9
|
+
|
10
|
+
it do
|
11
|
+
obj = described_class.human_attribute_name('bla_f')
|
12
|
+
expect(obj).to eq described_class.human_attribute_name('bla')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,33 +2,15 @@ export function round (value) {
|
|
2
2
|
return Math.round(value * 100) / 100
|
3
3
|
}
|
4
4
|
|
5
|
-
export function printCurrency (value,
|
6
|
-
|
5
|
+
export function printCurrency (value, simboloMoneda = '$') {
|
6
|
+
const decimals = (value % 1 > 0) ? 2 : 0
|
7
|
+
return simboloMoneda + ' ' + numberWithDots(value.toFixed(decimals).replace('.', ','))
|
7
8
|
}
|
8
9
|
|
9
10
|
export function showPercentage (value) {
|
10
11
|
return '% ' + value
|
11
12
|
}
|
12
13
|
|
13
|
-
export function monedaSimbolo (moneda) {
|
14
|
-
switch (moneda) {
|
15
|
-
case 'pesos':
|
16
|
-
return '$ '
|
17
|
-
case 'dolares':
|
18
|
-
return 'U$S '
|
19
|
-
case 'euros':
|
20
|
-
return '€ '
|
21
|
-
case 'reales':
|
22
|
-
return 'R$ '
|
23
|
-
case 'pesos_chilenos':
|
24
|
-
return 'CLP '
|
25
|
-
case 'pesos_mexicanos':
|
26
|
-
return 'MXN '
|
27
|
-
default:
|
28
|
-
return '$ '
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
14
|
export function numberWithDots (x) {
|
33
15
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.')
|
34
16
|
}
|
data/pg_layout/app/lib/navbar.rb
CHANGED
@@ -5,15 +5,25 @@ class Navbar
|
|
5
5
|
@user = user
|
6
6
|
end
|
7
7
|
|
8
|
+
def topbar
|
9
|
+
bar('topbar')
|
10
|
+
end
|
11
|
+
|
8
12
|
def sidebar
|
13
|
+
bar('sidebar')
|
14
|
+
end
|
15
|
+
|
16
|
+
def bar(key)
|
9
17
|
yaml_data = YAML.load_file("#{Rails.application.root}/config/pg_rails.yml")
|
10
|
-
|
18
|
+
bar_data = ActiveSupport::HashWithIndifferentAccess.new(yaml_data)[key]
|
19
|
+
return [] if bar_data.blank?
|
20
|
+
|
11
21
|
# rubocop:disable Security/Eval
|
12
|
-
|
22
|
+
bar_data.map do |item|
|
13
23
|
{
|
14
24
|
title: item['name'],
|
15
25
|
path: eval(item['path']),
|
16
|
-
show: true
|
26
|
+
show: item['policy'] ? eval(item['policy']) : true
|
17
27
|
}
|
18
28
|
end
|
19
29
|
# rubocop:enable Security/Eval
|
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
<div class="form-inputs">
|
7
7
|
<%= f.input :email, required: true, autofocus: true %>
|
8
|
+
<%= f.input :nombre, required: true %>
|
9
|
+
<%= f.input :apellido, required: true %>
|
8
10
|
|
9
11
|
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
10
12
|
<p><%= t(".currently_waiting_confirmation_for_email", email: resource.unconfirmed_email) %></p>
|
@@ -8,6 +8,8 @@
|
|
8
8
|
required: true,
|
9
9
|
autofocus: true ,
|
10
10
|
input_html: { autocomplete: "email" }%>
|
11
|
+
<%= f.input :nombre, required: true %>
|
12
|
+
<%= f.input :apellido, required: true %>
|
11
13
|
<%= f.input :password,
|
12
14
|
required: true,
|
13
15
|
hint: (t('devise.shared.minimum_password_length', count: @minimum_password_length) if @minimum_password_length),
|
@@ -18,3 +18,14 @@
|
|
18
18
|
<% end %>
|
19
19
|
|
20
20
|
<%= render "devise/shared/links" %>
|
21
|
+
|
22
|
+
<% if Rails.env.development? %>
|
23
|
+
<br>
|
24
|
+
<br>
|
25
|
+
<br>
|
26
|
+
<ul>
|
27
|
+
<% User.all.each do |user| %>
|
28
|
+
<li><%= link_to user, admin_login_as_path(id: user.id) %></li>
|
29
|
+
<% end %>
|
30
|
+
</ul>
|
31
|
+
<% end %>
|
@@ -3,8 +3,9 @@
|
|
3
3
|
- flash_to_show = flash.select { |flash_message| flash_message[0].to_sym.in? ApplicationController._flash_types }
|
4
4
|
/ slim-lint:enable LineLength
|
5
5
|
|
6
|
+
/ TODO: data-turbo-temporary, setear al activar toast?
|
6
7
|
- flash_to_show.each do |flash_type, message|
|
7
8
|
.toast(class="bg-#{flash_type_to_class(flash_type)}-subtle" role="alert" data-bs-autohide="true"
|
8
|
-
data-
|
9
|
+
data-xturbo-temporary="true" aria-live="assertive" aria-atomic="true")
|
9
10
|
.toast-body
|
10
11
|
= message
|
@@ -9,16 +9,25 @@
|
|
9
9
|
<!-- <span class="navbar-toggler-icon"></span> -->
|
10
10
|
</button>
|
11
11
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
12
|
-
<ul class="navbar-nav
|
12
|
+
<ul class="navbar-nav xme-auto mb-2 mb-lg-0">
|
13
13
|
<% if user_signed_in? %>
|
14
14
|
<li class="nav-item dropdown">
|
15
15
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
16
|
-
<%= current_user
|
16
|
+
<%= current_user %>
|
17
17
|
</a>
|
18
18
|
<ul class="dropdown-menu">
|
19
19
|
<li>
|
20
20
|
<%= link_to "Mi perfil", edit_user_registration_path, class: 'dropdown-item' %>
|
21
21
|
</li>
|
22
|
+
<% @navbar.topbar.each do |entry| %>
|
23
|
+
<% next if @navbar.hide_entry?(entry) %>
|
24
|
+
<li>
|
25
|
+
<a class="dropdown-item" href="<%= entry[:path] %>">
|
26
|
+
<%= entry[:title] %>
|
27
|
+
</a>
|
28
|
+
</li>
|
29
|
+
<% end %>
|
30
|
+
|
22
31
|
<li>
|
23
32
|
<%= link_to "Cerrar sesión", destroy_user_session_path, data: { 'turbo-method': 'delete' }, class: 'dropdown-item' %>
|
24
33
|
</li>
|
@@ -40,6 +49,8 @@
|
|
40
49
|
</li>
|
41
50
|
<% end %>
|
42
51
|
</ul>
|
52
|
+
<%= content_for :navbar_ext %>
|
53
|
+
|
43
54
|
</div>
|
44
55
|
</div>
|
45
56
|
</nav>
|
data/pg_rails/lib/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/ # locals: (object: nil, asociable: false)
|
2
2
|
|
3
3
|
div style="max-width: 22em" data-controller="pg_form"
|
4
|
-
= pg_form_for(@<%= singular_name %> || object, asociable:)
|
4
|
+
= pg_form_for(@<%= singular_name %> || object, asociable:) do |f|
|
5
5
|
= f.mensajes_de_error
|
6
6
|
|
7
7
|
= hidden_field_tag :asociable, true if asociable
|
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.10
|
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-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rails goodies.
|
14
14
|
email:
|
@@ -42,10 +42,10 @@ files:
|
|
42
42
|
- pg_engine/app/controllers/admin/accounts_controller.rb
|
43
43
|
- pg_engine/app/controllers/admin/user_accounts_controller.rb
|
44
44
|
- pg_engine/app/controllers/admin/users_controller.rb
|
45
|
+
- pg_engine/app/controllers/concerns/pg_engine/resource.rb
|
45
46
|
- pg_engine/app/controllers/pg_engine/base_controller.rb
|
46
47
|
- pg_engine/app/controllers/pg_engine/devise_controller.rb
|
47
48
|
- pg_engine/app/controllers/pg_engine/require_sign_in.rb
|
48
|
-
- pg_engine/app/controllers/pg_engine/resource_helper.rb
|
49
49
|
- pg_engine/app/decorators/account_decorator.rb
|
50
50
|
- pg_engine/app/decorators/pg_engine/base_decorator.rb
|
51
51
|
- pg_engine/app/decorators/user_account_decorator.rb
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- pg_engine/app/helpers/pg_engine/print_helper.rb
|
58
58
|
- pg_engine/app/helpers/pg_engine/route_helper.rb
|
59
59
|
- pg_engine/app/inputs/pg_engine/fecha_input.rb
|
60
|
+
- pg_engine/app/lib/pg_engine/error_helper.rb
|
60
61
|
- pg_engine/app/lib/pg_engine/filtros_builder.rb
|
61
62
|
- pg_engine/app/lib/pg_form_builder.rb
|
62
63
|
- pg_engine/app/models/account.rb
|
@@ -83,7 +84,9 @@ files:
|
|
83
84
|
- pg_engine/app/views/admin/users/new.html.slim
|
84
85
|
- pg_engine/app/views/admin/users/show.html.slim
|
85
86
|
- pg_engine/app/views/pg_engine/base/download.xlsx.axlsx
|
87
|
+
- pg_engine/app/views/pg_engine/base/edit.html.slim
|
86
88
|
- pg_engine/app/views/pg_engine/base/index.html.slim
|
89
|
+
- pg_engine/app/views/pg_engine/base/new.html.slim
|
87
90
|
- pg_engine/config/initializers/active_admin.rb
|
88
91
|
- pg_engine/config/initializers/devise.rb
|
89
92
|
- pg_engine/config/locales/devise.en.yml
|
@@ -98,6 +101,7 @@ files:
|
|
98
101
|
- pg_engine/db/migrate/20240211152951_create_accounts.rb
|
99
102
|
- pg_engine/db/migrate/20240211153049_create_user_accounts.rb
|
100
103
|
- pg_engine/db/migrate/20240222115722_create_active_storage_tables.active_storage.rb
|
104
|
+
- pg_engine/db/migrate/20240305200900_nombre_user.rb
|
101
105
|
- pg_engine/db/seeds.rb
|
102
106
|
- pg_engine/lib/pg_engine.rb
|
103
107
|
- pg_engine/lib/pg_engine/configuracion.rb
|
@@ -110,11 +114,16 @@ files:
|
|
110
114
|
- pg_engine/spec/controllers/admin/accounts_controller_spec.rb
|
111
115
|
- pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb
|
112
116
|
- pg_engine/spec/controllers/admin/users_controller_spec.rb
|
117
|
+
- pg_engine/spec/controllers/concerns/pg_engine/error_helper_spec.rb
|
118
|
+
- pg_engine/spec/controllers/devise/registrations_controller_spec.rb
|
119
|
+
- pg_engine/spec/controllers/devise/sessions_controller_spec.rb
|
113
120
|
- pg_engine/spec/factories/accounts.rb
|
114
121
|
- pg_engine/spec/factories/user_accounts.rb
|
115
122
|
- pg_engine/spec/factories/users.rb
|
116
123
|
- pg_engine/spec/fixtures/test.pdf
|
124
|
+
- pg_engine/spec/lib/pg_form_builder_spec.rb
|
117
125
|
- pg_engine/spec/models/account_spec.rb
|
126
|
+
- pg_engine/spec/models/pg_engine/base_record_spec.rb
|
118
127
|
- pg_engine/spec/models/user_account_spec.rb
|
119
128
|
- pg_engine/spec/models/user_spec.rb
|
120
129
|
- pg_engine/spec/pg_engine/pdf_preview_generator_spec.rb
|