pg_rails 7.0.5 → 7.0.6

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: d63547ea3619de2194b7906e2344df8fe1ff049cd3b066ba1adcb61cf1ae8102
4
- data.tar.gz: 5845c9d534c94be6ddb71823271d21f3d2c28615ba5d70d5a874478799d48eeb
3
+ metadata.gz: 7c4644fc0bcd9abce95b7cd8ac88f7779b7d8e6096590863d11fd1bbad1f1b7b
4
+ data.tar.gz: df1ffd480c688adc40f24613b9d00eb57fe45940067191a942bd18e9d53e1209
5
5
  SHA512:
6
- metadata.gz: b7611fd24a756c4a7c6e8573f67b48dd0e9598839065feef9ac6345e8e09e0b71087db795647524f6f8bd9734fe67c6da54d4305391306441eddcaf6b0120937
7
- data.tar.gz: 204dc0788a96e724b67038d0c89e1a8cecf69a1a4fd8f8ada7d105289ed0615641eed73e8353cf85acea3be573332d05583070650740c37ed53d891c2ec30579
6
+ metadata.gz: c9afa947ca3962f7e81973a798664900bccdc15ab6dd500c5b8573f5177212585cf35e78194c1219b6137f6dd3198d4e23ffd982702fdc2cac3cbf8ae1f2c8df
7
+ data.tar.gz: 4f26bb070447c9c07829628a2d99a7a8a0ec9a7ac8298ab2f4118444316cffa775ff3254577488d2c139d637468c995bc97c5b9d4adf561f17529cfe398d89c5
@@ -3,7 +3,7 @@ SimpleForm.setup do |config|
3
3
  error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
4
4
  b.use :html5
5
5
  b.optional :readonly
6
- b.use :label, class: 'form-control-label'
6
+ b.use :label, class: 'form-label'
7
7
  b.use :hidden_input
8
8
  b.wrapper tag: 'div', class: 'position-relative' do |ba|
9
9
  ba.use :input, class: 'form-control', disabled: true, placeholder: 'Clic para seleccionar...',
@@ -20,7 +20,7 @@ SimpleForm.setup do |config|
20
20
  error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
21
21
  b.use :html5
22
22
  b.optional :readonly
23
- b.use :label, class: 'form-control-label'
23
+ b.use :label, class: 'form-label'
24
24
  b.use :hidden_input
25
25
  b.wrapper tag: 'div', class: 'search-box position-relative' do |ba|
26
26
  ba.use :search_form, error_class: 'is-invalid'
@@ -30,7 +30,7 @@ module PgEngine
30
30
  end
31
31
 
32
32
  def new
33
- add_breadcrumb "Crear #{@clase_modelo.nombre_singular.downcase}"
33
+ add_breadcrumb 'Crear'
34
34
  end
35
35
 
36
36
  def edit
@@ -71,21 +71,23 @@ module PgEngine
71
71
  session[:page_size].present? ? session[:page_size].to_i : 10
72
72
  end
73
73
 
74
- def pg_respond_update(object: nil)
75
- object ||= instancia_modelo
74
+ def pg_respond_update
75
+ object = instancia_modelo
76
76
  respond_to do |format|
77
77
  if (@saved = object.save)
78
78
  format.html { redirect_to object.decorate.target_object }
79
79
  format.json { render json: object.decorate }
80
80
  else
81
+ # TODO: esto solucionaría el problema?
82
+ # self.instancia_modelo = instancia_modelo.decorate
81
83
  format.html { render :edit, status: :unprocessable_entity }
82
84
  format.json { render json: object.errors, status: :unprocessable_entity }
83
85
  end
84
86
  end
85
87
  end
86
88
 
87
- def pg_respond_create(object: nil)
88
- object ||= instancia_modelo
89
+ def pg_respond_create
90
+ object = instancia_modelo
89
91
  respond_to do |format|
90
92
  if (@saved = object.save)
91
93
  if params[:asociable]
@@ -107,6 +109,8 @@ module PgEngine
107
109
  end
108
110
  format.json { render json: object.decorate }
109
111
  else
112
+ # TODO: esto solucionaría el problema?
113
+ # self.instancia_modelo = instancia_modelo.decorate
110
114
  if params[:asociable]
111
115
  format.turbo_stream do
112
116
  render turbo_stream:
@@ -16,18 +16,20 @@ module PgEngine
16
16
  object.as_json.tap { |o| o[:to_s] = to_s }
17
17
  end
18
18
 
19
- # def method_missing(method_name, *args, &block)
20
- # valor = object.attributes[method_name.to_s]
21
- # return super unless valor.present?
22
-
23
- # if valor.instance_of?(Date)
24
- # dmy(valor)
25
- # # elsif valor.class == ActiveSupport::TimeWithZone
26
- # # dmy_time(valor)
27
- # else
28
- # super
29
- # end
30
- # end
19
+ # rubocop:disable Style/MissingRespondToMissing
20
+ def method_missing(method_name, *args, &)
21
+ valor = object.attributes[method_name.to_s]
22
+ return super if valor.blank?
23
+
24
+ if valor.instance_of?(Date)
25
+ dmy(valor)
26
+ elsif valor.instance_of?(ActiveSupport::TimeWithZone)
27
+ dmy_time(valor)
28
+ else
29
+ super
30
+ end
31
+ end
32
+ # rubocop:enable Style/MissingRespondToMissing
31
33
 
32
34
  def destroy_link(message = '¿Estás seguro?')
33
35
  return unless Pundit.policy!(helpers.send(PgEngine.configuracion.current_user_method), object).destroy?
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # require 'activesupport/time'
4
- module ActiveSupport
5
- class TimeWithZone
6
- def to_s(format = :default)
7
- if format == :db
8
- utc.to_s(format)
9
- elsif formatter = ::Time::DATE_FORMATS[format] # rubocop:disable Lint/AssignmentInCondition
10
- formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
11
- else
12
- # "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format
13
- time.strftime('%d/%m/%Y %H:%M')
14
- end
15
- end
16
- end
17
- end
4
+ # module ActiveSupport
5
+ # class TimeWithZone
6
+ # def to_s(format = :default)
7
+ # if format == :db
8
+ # utc.to_s(format)
9
+ # elsif formatter = ::Time::DATE_FORMATS[format]
10
+ # formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
11
+ # else
12
+ # # "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby Time#to_s format
13
+ # time.strftime('%d/%m/%Y %H:%M')
14
+ # end
15
+ # end
16
+ # end
17
+ # end
@@ -1,7 +1,7 @@
1
1
  module PgEngine
2
2
  module RouteHelpers
3
- def pg_resource(key)
4
- resources(key) do
3
+ def pg_resource(key, options = {})
4
+ resources(key, options) do
5
5
  collection do
6
6
  get :abrir_modal
7
7
  post :buscar
@@ -27,7 +27,7 @@ if Rails.env.development?
27
27
  'require' => '',
28
28
  'exclude_tests' => 'true',
29
29
  'exclude_fixtures' => 'true',
30
- 'exclude_factories' => 'true',
30
+ 'exclude_factories' => 'false',
31
31
  'exclude_serializers' => 'true',
32
32
  'exclude_scaffolds' => 'true',
33
33
  'exclude_controllers' => 'true',
@@ -35,7 +35,7 @@ if Rails.env.development?
35
35
  'exclude_sti_subclasses' => 'false',
36
36
  'ignore_model_sub_dir' => 'false',
37
37
  'ignore_columns' => nil,
38
- 'ignore_routes' => nil,
38
+ 'ignore_routes' => 'rails|active_admin',
39
39
  'ignore_unknown_models' => 'false',
40
40
  # 'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(",") %>',
41
41
  # 'hide_default_column_types' => '<%= AnnotateModels::NO_DEFAULT_COL_TYPES.join(",") %>',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.5'
4
+ VERSION = '7.0.6'
5
5
  end
@@ -17,7 +17,7 @@ table.table.table-borderless.table-sm.w-auto.mb-0.m-3
17
17
  <%- end -%>
18
18
  tr
19
19
  th = t('attributes.created_at')
20
- td = dmy_time @<%= singular_name %>.created_at
20
+ td = @<%= singular_name %>.created_at
21
21
  <%- if options[:trackeo_de_usuarios] -%>
22
22
  tr
23
23
  th = t('attributes.actualizado_por')
@@ -25,14 +25,14 @@ table.table.table-borderless.table-sm.w-auto.mb-0.m-3
25
25
  <%- end -%>
26
26
  tr
27
27
  th = t('attributes.updated_at')
28
- td = dmy_time @<%= singular_name %>.updated_at
28
+ td = @<%= singular_name %>.updated_at
29
29
  <%- if options[:paranoia] -%>
30
30
  tr
31
31
  th = t('attributes.deleted_at')
32
- td = dmy_time @<%= singular_name %>.deleted_at
32
+ td = @<%= singular_name %>.deleted_at
33
33
  <%- end -%>
34
34
  <%- if options[:discard] -%>
35
35
  tr
36
36
  th = t('attributes.discarded_at')
37
- td = dmy_time @<%= singular_name %>.discarded_at
37
+ td = @<%= singular_name %>.discarded_at
38
38
  <%- end -%>
@@ -12,9 +12,9 @@ module Rails
12
12
 
13
13
  def parse_type_and_options(type)
14
14
  case type
15
- when /(string|text|binary|integer)\{(\d+)\}/
15
+ when /(string|text|binary|integer|decimal)\{(\d+)\}/
16
16
  [Regexp.last_match(1), { limit: Regexp.last_match(2).to_i }]
17
- when /(string|text|binary|float|integer|date|datetime)\{(.+)\}/
17
+ when /(string|text|binary|float|integer|date|datetime|boolean|json|decimal)\{(.+)\}/
18
18
  type = Regexp.last_match(1)
19
19
  provided_options = Regexp.last_match(2).split(/[,.-]/)
20
20
  options = provided_options.to_h { |opt| [opt.to_sym, true] }
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.5
4
+ version: 7.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso