pg_rails 7.0.8.pre.alpha.10 → 7.0.8.pre.alpha.11

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: d3efd952ef548d103ed1c4aea21b903f039792ed601fc66e93fb5b84dce4d39d
4
- data.tar.gz: 148ae25de52ab06846c1b7b313f6f87db0d6d6ba502a9186104559e0e37ec114
3
+ metadata.gz: fd8e2d2862617656464a77ffbb81da7f6a4446d013905748392a062e8f3dab7c
4
+ data.tar.gz: '082f99be749adde90a68693ebfe00ee234c6a83429c18c0f02b9aff6b831ae53'
5
5
  SHA512:
6
- metadata.gz: 68b63352e0ac30ff6f3c7a22e3a2fb73f8918ee91dfefe51b2c8371915c9d7adde99eb114c1ba935387182fa10966d0c5776c672e477486cff17a82993ff68fb
7
- data.tar.gz: 1fda6ee9f5416f813e811268f307b87638b69de4a3db4659a7259c6101dc6b8281d9b351e92998e517a0d492cc39eea71780add28b2c240c4971aa26f87a2000
6
+ metadata.gz: d34c9e84d88801ea1b973b275ab94923fb0941bdf9e204fa2a3d76321f9bec079427e3df7d9fae905ef31e3144cda6d92c061ca510f108c66084ec68258de446
7
+ data.tar.gz: 18fed1f31567205e9ad8bff9e455f9c5e48bf0be4966e2ba9c08fca716995720934e0b8f0011ab1a2bcf7cd39edbd92fb708b296d926849cae2c815c5a1a4352
@@ -23,7 +23,7 @@ export default class extends Controller {
23
23
  }
24
24
 
25
25
  disconnect (e) {
26
+ this.modalPuntero.hide()
26
27
  this.modalPuntero.dispose()
27
- document.querySelectorAll('.modal-backdrop').forEach(e => { e.remove() })
28
28
  }
29
29
  }
@@ -98,10 +98,10 @@ module PgEngine
98
98
  'No'
99
99
  end
100
100
 
101
- def print_currency(number, simbolo: '$')
101
+ def print_currency(number, simbolo: '$', precision: nil)
102
102
  return if number.blank?
103
103
 
104
- precision = (number % 1).positive? ? 2 : 0
104
+ precision ||= (number % 1).positive? ? 2 : 0
105
105
  "#{simbolo} #{number_with_precision(number, delimiter: '.', separator: ',',
106
106
  precision:)}"
107
107
  end
@@ -4,6 +4,27 @@ class PgFormBuilder < SimpleForm::FormBuilder
4
4
  include PgAssociable::FormBuilderMethods
5
5
  include PgEngine::ErrorHelper
6
6
 
7
+ def default_prefix(attribute_name)
8
+ at_name = object.class.human_attribute_name(attribute_name.to_s).downcase
9
+ "#{articulo(attribute_name)} #{at_name}"
10
+ end
11
+
12
+ def articulo(attribute_name)
13
+ gender = I18n.t("gender.#{attribute_name}", default: nil)
14
+ if gender.present?
15
+ gender == 'f' ? 'La' : 'El'
16
+ else
17
+ at_name = object.class.human_attribute_name(attribute_name.to_s).downcase
18
+ at_name.ends_with?('a') ? 'La' : 'El'
19
+ end
20
+ end
21
+
22
+ def input(attribute_name, options = {}, &)
23
+ options[:error_prefix] ||= default_prefix(attribute_name)
24
+
25
+ super(attribute_name, options, &)
26
+ end
27
+
7
28
  def mensajes_de_error
8
29
  base_errors = object.errors[:base]
9
30
  base_message = (base_errors.map(&:to_s).join('<br>') if base_errors.present?)
@@ -37,7 +37,7 @@ class User < ApplicationRecord
37
37
 
38
38
  # Include default devise modules. Others available are:
39
39
  devise :database_authenticatable, :registerable,
40
- :recoverable, :rememberable, :validatable,
40
+ :recoverable, :rememberable,
41
41
  :lockable, :timeoutable, :trackable, :confirmable
42
42
 
43
43
  audited
@@ -46,7 +46,19 @@ class User < ApplicationRecord
46
46
  has_many :user_accounts
47
47
  has_many :accounts, through: :user_accounts
48
48
 
49
- validates :email, :nombre, :apellido, presence: true
49
+ validates :nombre, :apellido, presence: true
50
+
51
+ validates_presence_of :email
52
+ validates_uniqueness_of :email, message: 'ya pertenece a un usuario'
53
+ validates_format_of :email, with: /\A[^@\s]+@[^@\s]+\z/
54
+ validates_presence_of :password, if: :password_required?
55
+ validates_confirmation_of :password, if: :password_required?, message: 'Las contraseñas no coinciden'
56
+ validates_length_of :password, if: :password_required?, within: 6..128,
57
+ message: 'es demasiado corta (6 caracteres mínimo)'
58
+
59
+ def password_required?
60
+ !persisted? || !password.nil? || !password_confirmation.nil?
61
+ end
50
62
 
51
63
  scope :query, ->(param) { where('email ILIKE ?', "%#{param}%") }
52
64
 
@@ -39,7 +39,7 @@ div
39
39
  - object = object.decorate
40
40
  tr id="#{dom_id(object)}"
41
41
  - atributos_para_listar.each do |att|
42
- td = object.send(att)
42
+ td.text-nowrap = object.send(att)
43
43
  td.text-nowrap.text-end.ps-5
44
44
  = object.show_link
45
45
  = object.edit_link
@@ -0,0 +1,12 @@
1
+ module SimpleForm
2
+ module Components
3
+ module Errors
4
+ def error_text
5
+ text = has_custom_error? ? options[:error] : errors.reject(&:empty?).send(error_method)
6
+ return if text.blank?
7
+
8
+ "#{html_escape(options[:error_prefix])} #{html_escape(text)}".lstrip.html_safe
9
+ end
10
+ end
11
+ end
12
+ end
@@ -40,3 +40,7 @@ es:
40
40
  # prompts:
41
41
  # defaults:
42
42
  # age: 'Select your age'
43
+ errors:
44
+ messages:
45
+ blank: ''
46
+ empty: ''
@@ -56,8 +56,7 @@ SimpleForm.setup do |config|
56
56
  b.optional :readonly
57
57
  b.use :label, class: 'form-label'
58
58
  b.use :input, class: 'form-control', error_class: 'is-invalid'
59
- b.use :full_error, wrap_with: { class: 'invalid-feedback' }
60
- b.optional :error, wrap_with: { class: 'invalid-feedback' }
59
+ b.use :error, wrap_with: { class: 'invalid-feedback' }
61
60
  b.use :hint, wrap_with: { class: 'form-text' }
62
61
  end
63
62
 
@@ -66,8 +65,7 @@ SimpleForm.setup do |config|
66
65
  b.optional :readonly
67
66
  b.use :label, class: 'form-label'
68
67
  b.use :input, class: 'form-select', error_class: 'is-invalid'
69
- b.use :full_error, wrap_with: { class: 'invalid-feedback' }
70
- b.optional :error, wrap_with: { class: 'invalid-feedback' }
68
+ b.use :error, wrap_with: { class: 'invalid-feedback' }
71
69
  b.use :hint, wrap_with: { class: 'form-text' }
72
70
  end
73
71
 
@@ -29,4 +29,18 @@ describe PgFormBuilder do
29
29
  it { expect(subject).to eq 'Por favor, revisá los campos obligatorios:' }
30
30
  end
31
31
  end
32
+
33
+ describe '#default_prefix' do
34
+ context 'cuando el atributo es masculino' do
35
+ subject { instancia.default_prefix(:nombre) }
36
+
37
+ it { expect(subject).to eq 'El nombre' }
38
+ end
39
+
40
+ context 'cuando el atributo es femenino' do
41
+ subject { instancia.default_prefix(:fecha) }
42
+
43
+ it { expect(subject).to eq 'La fecha' }
44
+ end
45
+ end
32
46
  end
@@ -1,15 +1,14 @@
1
1
  <h2><%= t(".sign_up") %></h2>
2
2
 
3
3
  <%= pg_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
- <%= f.error_notification %>
4
+ <%= f.mensajes_de_error %>
5
5
 
6
6
  <div class="form-inputs">
7
+ <%= f.input :nombre, required: true, autofocus: true %>
8
+ <%= f.input :apellido, required: true %>
7
9
  <%= f.input :email,
8
10
  required: true,
9
- autofocus: true ,
10
11
  input_html: { autocomplete: "email" }%>
11
- <%= f.input :nombre, required: true %>
12
- <%= f.input :apellido, required: true %>
13
12
  <%= f.input :password,
14
13
  required: true,
15
14
  hint: (t('devise.shared.minimum_password_length', count: @minimum_password_length) if @minimum_password_length),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.10'
4
+ VERSION = '7.0.8-alpha.11'
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.10
4
+ version: 7.0.8.pre.alpha.11
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-03-05 00:00:00.000000000 Z
11
+ date: 2024-03-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails goodies.
14
14
  email:
@@ -89,6 +89,7 @@ files:
89
89
  - pg_engine/app/views/pg_engine/base/new.html.slim
90
90
  - pg_engine/config/initializers/active_admin.rb
91
91
  - pg_engine/config/initializers/devise.rb
92
+ - pg_engine/config/initializers/simple_form_monkey_patch.rb
92
93
  - pg_engine/config/locales/devise.en.yml
93
94
  - pg_engine/config/locales/es.yml
94
95
  - pg_engine/config/routes.rb