pg_rails 7.0.4 → 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: f938c5e60b8cb063472ebc6a8f42445714d5e2ade2b86d2863b9a98d7bd8eb32
4
- data.tar.gz: abea2aba977e1ed3c33a4d0e39e27e84943a0a3066514e1123bec424c03d2014
3
+ metadata.gz: 7c4644fc0bcd9abce95b7cd8ac88f7779b7d8e6096590863d11fd1bbad1f1b7b
4
+ data.tar.gz: df1ffd480c688adc40f24613b9d00eb57fe45940067191a942bd18e9d53e1209
5
5
  SHA512:
6
- metadata.gz: 1383e921c7de060743dfa1d2d4f68c9bd0b8308cb72c35ed5a41beac46b007281de7427fae3c52930b31f8c77a853c62b4cdf5774d95d5f27ef3fa110e8c1e0b
7
- data.tar.gz: dbb40317f97d3d7678140e6d5c92bfdd70119e1eda35093d55d33fe2364156718fcd8a45bebd27ba2c7c388760ef269b594f0c17d65c8c02b6c79eab97c22ac1
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
@@ -1,34 +1,59 @@
1
- # frozen_string_literal: true
2
-
3
- # # frozen_string_literal: true
4
-
1
+ # NOTE: only doing this in development as some production environments (Heroku)
2
+ # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3
+ # NOTE: to have a dev-mode tool do its thing in production.
5
4
  if Rails.env.development?
6
- Annotate.set_defaults(
7
- # 'show_migration' => 'true',
8
- 'show_foreign_keys' => 'true',
9
- 'show_indexes' => 'true',
10
- 'exclude_controllers' => 'true',
11
- 'exclude_helpers' => 'true',
12
- 'exclude_tests' => 'true',
13
- 'classified_sort' => 'true',
14
- 'with_comment' => 'true',
15
-
16
- 'models' => 'true'
17
- )
18
-
19
- # Annotate models
20
- task annotate: :environment do
21
- puts 'Annotating models...'
22
- system 'bundle exec annotate'
5
+ require 'annotate'
6
+ task :set_annotation_options do
7
+ # You can override any of these by setting an environment variable of the
8
+ # same name.
9
+ Annotate.set_defaults(
10
+ 'active_admin' => 'false',
11
+ 'additional_file_patterns' => [],
12
+ 'routes' => 'true',
13
+ 'models' => 'true',
14
+ 'position_in_routes' => 'before',
15
+ 'position_in_class' => 'before',
16
+ 'position_in_test' => 'before',
17
+ 'position_in_fixture' => 'before',
18
+ 'position_in_factory' => 'before',
19
+ 'position_in_serializer' => 'before',
20
+ 'show_foreign_keys' => 'true',
21
+ 'show_complete_foreign_keys' => 'false',
22
+ 'show_indexes' => 'true',
23
+ 'simple_indexes' => 'false',
24
+ 'model_dir' => 'app/models',
25
+ 'root_dir' => '',
26
+ 'include_version' => 'false',
27
+ 'require' => '',
28
+ 'exclude_tests' => 'true',
29
+ 'exclude_fixtures' => 'true',
30
+ 'exclude_factories' => 'false',
31
+ 'exclude_serializers' => 'true',
32
+ 'exclude_scaffolds' => 'true',
33
+ 'exclude_controllers' => 'true',
34
+ 'exclude_helpers' => 'true',
35
+ 'exclude_sti_subclasses' => 'false',
36
+ 'ignore_model_sub_dir' => 'false',
37
+ 'ignore_columns' => nil,
38
+ 'ignore_routes' => 'rails|active_admin',
39
+ 'ignore_unknown_models' => 'false',
40
+ # 'hide_limit_column_types' => '<%= AnnotateModels::NO_LIMIT_COL_TYPES.join(",") %>',
41
+ # 'hide_default_column_types' => '<%= AnnotateModels::NO_DEFAULT_COL_TYPES.join(",") %>',
42
+ 'skip_on_db_migrate' => 'false',
43
+ 'format_bare' => 'true',
44
+ 'format_rdoc' => 'false',
45
+ 'format_yard' => 'false',
46
+ 'format_markdown' => 'false',
47
+ 'sort' => 'false',
48
+ 'force' => 'false',
49
+ 'frozen' => 'false',
50
+ 'classified_sort' => 'true',
51
+ 'trace' => 'false',
52
+ 'wrapper_open' => nil,
53
+ 'wrapper_close' => nil,
54
+ 'with_comment' => 'true'
55
+ )
23
56
  end
24
57
 
25
- # Run annotate task after db:migrate
26
- # and db:rollback tasks
27
- Rake::Task['db:migrate'].enhance do
28
- Rake::Task['annotate'].invoke
29
- end
30
-
31
- Rake::Task['db:rollback'].enhance do
32
- Rake::Task['annotate'].invoke
33
- end
58
+ Annotate.load_tasks
34
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.4'
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.4
4
+ version: 7.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso