pg_rails 7.0.8.pre.alpha.11 → 7.0.8.pre.alpha.12

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: fd8e2d2862617656464a77ffbb81da7f6a4446d013905748392a062e8f3dab7c
4
- data.tar.gz: '082f99be749adde90a68693ebfe00ee234c6a83429c18c0f02b9aff6b831ae53'
3
+ metadata.gz: 84eace9e9d023c54401e822df64d253dd94dcdf3831fd19ce1c77bb0ad674541
4
+ data.tar.gz: 3c1b74610da49e737f4fba5d9b89737a529650831278f95fcfc4c66ebd32a1f6
5
5
  SHA512:
6
- metadata.gz: d34c9e84d88801ea1b973b275ab94923fb0941bdf9e204fa2a3d76321f9bec079427e3df7d9fae905ef31e3144cda6d92c061ca510f108c66084ec68258de446
7
- data.tar.gz: 18fed1f31567205e9ad8bff9e455f9c5e48bf0be4966e2ba9c08fca716995720934e0b8f0011ab1a2bcf7cd39edbd92fb708b296d926849cae2c815c5a1a4352
6
+ metadata.gz: 2c350c91dc1f91c4eb6c2b7ad866296d1057c89637ec3b45922ec89a0720d7942a4706a0ab3659adabb34da2a8f681d56367a722b5d7d4f1595210bb3bda12dc
7
+ data.tar.gz: '0806e415216083b9afe67adb247328764964cd537351a4406e88c7768946b71fe661de0a469f3d61af215d85706312d772e12cf52b03f65c083cb773cf06d687'
@@ -1,24 +1,21 @@
1
1
  ActiveAdmin.register Account do
2
- permit_params :plan, :nombre, :hashid
2
+ permit_params :plan, :nombre
3
3
 
4
4
  index do
5
5
  selectable_column
6
6
  id_column
7
7
  column :plan
8
8
  column :nombre
9
- column :hashid
10
9
  actions
11
10
  end
12
11
 
13
12
  filter :plan
14
13
  filter :nombre
15
- filter :hashid
16
14
 
17
15
  form do |f|
18
16
  f.inputs do
19
17
  f.input :plan
20
18
  f.input :nombre
21
- f.input :hashid
22
19
  end
23
20
  f.actions
24
21
  end
@@ -15,19 +15,19 @@ module Admin
15
15
  private
16
16
 
17
17
  def atributos_permitidos
18
- %i[plan nombre hashid]
18
+ %i[plan nombre]
19
19
  end
20
20
 
21
21
  def atributos_para_buscar
22
- %i[plan nombre hashid]
22
+ %i[plan nombre]
23
23
  end
24
24
 
25
25
  def atributos_para_listar
26
- %i[plan nombre hashid]
26
+ %i[plan nombre]
27
27
  end
28
28
 
29
29
  def atributos_para_mostrar
30
- %i[plan nombre hashid]
30
+ %i[plan nombre]
31
31
  end
32
32
  end
33
33
  end
@@ -210,6 +210,8 @@ module PgEngine
210
210
  def buscar_instancia
211
211
  if Object.const_defined?('FriendlyId') && @clase_modelo.is_a?(FriendlyId)
212
212
  @clase_modelo.friendly.find(params[:id])
213
+ elsif @clase_modelo.respond_to? :find_by_hashid
214
+ @clase_modelo.find_by!(hashid: params[:id])
213
215
  else
214
216
  @clase_modelo.find(params[:id])
215
217
  end
@@ -0,0 +1,11 @@
1
+ module PgEngine
2
+ module PgRailsHelper
3
+ def dev?
4
+ Rails.env.development? || current_user&.developer?
5
+ end
6
+
7
+ def current_account
8
+ current_user&.current_account
9
+ end
10
+ end
11
+ end
@@ -6,25 +6,18 @@
6
6
  #
7
7
  # id :bigint not null, primary key
8
8
  # discarded_at :datetime
9
- # hashid :string
10
9
  # nombre :string not null
11
10
  # plan :integer not null
12
11
  # created_at :datetime not null
13
12
  # updated_at :datetime not null
14
- # actualizado_por_id :bigint
15
- # creado_por_id :bigint
16
- #
17
- # Indexes
18
- #
19
- # index_accounts_on_actualizado_por_id (actualizado_por_id)
20
- # index_accounts_on_creado_por_id (creado_por_id)
13
+ # actualizado_por_id :bigint indexed
14
+ # creado_por_id :bigint indexed
21
15
  #
22
16
  # Foreign Keys
23
17
  #
24
18
  # fk_rails_... (actualizado_por_id => users.id)
25
19
  # fk_rails_... (creado_por_id => users.id)
26
20
  #
27
- # generado con pg_rails
28
21
 
29
22
  class Account < ApplicationRecord
30
23
  audited
@@ -47,10 +47,10 @@ module PgEngine
47
47
 
48
48
  def to_s
49
49
  %i[nombre name].each do |campo|
50
- return "#{send(campo)} ##{id}" if try(campo).present?
50
+ return "#{send(campo)} ##{to_param}" if try(campo).present?
51
51
  end
52
- if id.present?
53
- "#{self.class.nombre_singular} ##{id}"
52
+ if to_param.present?
53
+ "#{self.class.nombre_singular} ##{to_param}"
54
54
  else
55
55
  super
56
56
  end
@@ -3,35 +3,30 @@
3
3
  # Table name: users
4
4
  #
5
5
  # id :bigint not null, primary key
6
+ # apellido :string not null
6
7
  # confirmation_sent_at :datetime
7
- # confirmation_token :string
8
+ # confirmation_token :string indexed
8
9
  # confirmed_at :datetime
9
10
  # current_sign_in_at :datetime
10
11
  # current_sign_in_ip :string
11
12
  # developer :boolean default(FALSE), not null
12
13
  # discarded_at :datetime
13
- # email :string default(""), not null
14
+ # email :string default(""), not null, indexed
14
15
  # encrypted_password :string default(""), not null
15
16
  # failed_attempts :integer default(0), not null
16
17
  # last_sign_in_at :datetime
17
18
  # last_sign_in_ip :string
18
19
  # locked_at :datetime
20
+ # nombre :string not null
19
21
  # remember_created_at :datetime
20
22
  # reset_password_sent_at :datetime
21
- # reset_password_token :string
23
+ # reset_password_token :string indexed
22
24
  # sign_in_count :integer default(0), not null
23
25
  # unconfirmed_email :string
24
- # unlock_token :string
26
+ # unlock_token :string indexed
25
27
  # created_at :datetime not null
26
28
  # updated_at :datetime not null
27
29
  #
28
- # Indexes
29
- #
30
- # index_users_on_confirmation_token (confirmation_token) UNIQUE
31
- # index_users_on_email (email) UNIQUE
32
- # index_users_on_reset_password_token (reset_password_token) UNIQUE
33
- # index_users_on_unlock_token (unlock_token) UNIQUE
34
- #
35
30
  class User < ApplicationRecord
36
31
  # ApplicationRecord should be defined on Application
37
32
 
@@ -8,17 +8,10 @@
8
8
  # profiles :integer default([]), not null, is an Array
9
9
  # created_at :datetime not null
10
10
  # updated_at :datetime not null
11
- # account_id :bigint not null
12
- # actualizado_por_id :bigint
13
- # creado_por_id :bigint
14
- # user_id :bigint not null
15
- #
16
- # Indexes
17
- #
18
- # index_user_accounts_on_account_id (account_id)
19
- # index_user_accounts_on_actualizado_por_id (actualizado_por_id)
20
- # index_user_accounts_on_creado_por_id (creado_por_id)
21
- # index_user_accounts_on_user_id (user_id)
11
+ # account_id :bigint not null, indexed
12
+ # actualizado_por_id :bigint indexed
13
+ # creado_por_id :bigint indexed
14
+ # user_id :bigint not null, indexed
22
15
  #
23
16
  # Foreign Keys
24
17
  #
@@ -27,7 +20,6 @@
27
20
  # fk_rails_... (creado_por_id => users.id)
28
21
  # fk_rails_... (user_id => users.id)
29
22
  #
30
- # generado con pg_rails
31
23
 
32
24
  class UserAccount < ApplicationRecord
33
25
  audited
@@ -7,6 +7,5 @@ div style="max-width: 22em"
7
7
  = hidden_field_tag :asociable, true if asociable
8
8
  = f.input :plan
9
9
  = f.input :nombre
10
- = f.input :hashid
11
10
  .mt-2
12
11
  = f.button :submit
@@ -0,0 +1,5 @@
1
+ class RemoveHashIds < ActiveRecord::Migration[7.1]
2
+ def change
3
+ remove_column :accounts, :hashid
4
+ end
5
+ end
@@ -1,6 +1,8 @@
1
1
  # NOTE: only doing this in development as some production environments (Heroku)
2
2
  # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3
3
  # NOTE: to have a dev-mode tool do its thing in production.
4
+ Dotenv.load
5
+
4
6
  if Rails.env.development?
5
7
  require 'annotate'
6
8
  task :set_annotation_options do
@@ -21,7 +23,8 @@ if Rails.env.development?
21
23
  'show_complete_foreign_keys' => 'false',
22
24
  'show_indexes' => 'false',
23
25
  'simple_indexes' => 'true',
24
- 'model_dir' => ['app/models', 'app/overrides'],
26
+ 'model_dir' => ENV['MODEL_PATHS'],
27
+ # 'model_dir' => ['app/models', 'app/overrides'],
25
28
  # 'model_dir' => 'app/models',
26
29
  'root_dir' => '',
27
30
  'include_version' => 'false',
@@ -6,6 +6,5 @@ FactoryBot.define do
6
6
  factory :account do
7
7
  plan { Account.plan.values.sample }
8
8
  nombre { Faker::Lorem.sentence }
9
- hashid { Faker::Lorem.sentence }
10
9
  end
11
10
  end
@@ -3,6 +3,9 @@ export function round (value) {
3
3
  }
4
4
 
5
5
  export function printCurrency (value, simboloMoneda = '$') {
6
+ if (typeof value === 'string') {
7
+ value = parseFloat(value)
8
+ }
6
9
  const decimals = (value % 1 > 0) ? 2 : 0
7
10
  return simboloMoneda + ' ' + numberWithDots(value.toFixed(decimals).replace('.', ','))
8
11
  }
@@ -14,15 +14,16 @@ html
14
14
  = stylesheet_link_tag 'application', 'data-turbo-track': 'reload'
15
15
  = javascript_include_tag 'application', 'data-turbo-track': 'reload', type: 'module'
16
16
  body
17
- .with-sidebar
18
- = render partial: 'pg_layout/sidebar'
17
+ div class="#{ @sidebar == false ? '' : 'with-sidebar' }"
18
+ - unless @sidebar == false
19
+ = render partial: 'pg_layout/sidebar'
19
20
  div
20
21
  .position-relative.d-flex.justify-content-around
21
22
  #flash.flash.position-absolute.z-1.mt-1
22
23
  = render partial: 'pg_layout/flash'
23
24
  = render partial: 'pg_layout/navbar'
24
25
  div
25
- - if user_signed_in?
26
+ - if user_signed_in? && @breadcrumb != false
26
27
  .d-flex.align-items-center.justify-content-between.px-3.py-1.d-print-none[
27
28
  style="min-height: 2.5em;"]
28
29
  nav aria-label="breadcrumb"
@@ -1,8 +1,10 @@
1
1
  <nav class="navbar navbar-expand-<%= @breakpoint_navbar_expand %> bg-light">
2
2
  <div class="container-fluid">
3
- <button data-controller="navbar" data-action="navbar#expandNavbar" class="btn btn-outline-primary me-2 d-none d-<%= @breakpoint_navbar_expand %>-inline-block">
4
- <i class="bi bi-list"></i>
5
- </button>
3
+ <% unless @sidebar == false %>
4
+ <button data-controller="navbar" data-action="navbar#expandNavbar" class="btn btn-outline-primary me-2 d-none d-<%= @breakpoint_navbar_expand %>-inline-block">
5
+ <i class="bi bi-list"></i>
6
+ </button>
7
+ <% end %>
6
8
  <!-- <a class="navbar-brand" href="#">Navbar</a> -->
7
9
  <button class="navbar-toggler btn btn-outline-primary me-2" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
8
10
  <i class="bi bi-list"></i>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.11'
4
+ VERSION = '7.0.8-alpha.12'
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.11
4
+ version: 7.0.8.pre.alpha.12
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-06 00:00:00.000000000 Z
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails goodies.
14
14
  email:
@@ -53,6 +53,7 @@ files:
53
53
  - pg_engine/app/helpers/pg_engine/flash_helper.rb
54
54
  - pg_engine/app/helpers/pg_engine/form_helper.rb
55
55
  - pg_engine/app/helpers/pg_engine/index_helper.rb
56
+ - pg_engine/app/helpers/pg_engine/pg_rails_helper.rb
56
57
  - pg_engine/app/helpers/pg_engine/postgres_helper.rb
57
58
  - pg_engine/app/helpers/pg_engine/print_helper.rb
58
59
  - pg_engine/app/helpers/pg_engine/route_helper.rb
@@ -103,6 +104,7 @@ files:
103
104
  - pg_engine/db/migrate/20240211153049_create_user_accounts.rb
104
105
  - pg_engine/db/migrate/20240222115722_create_active_storage_tables.active_storage.rb
105
106
  - pg_engine/db/migrate/20240305200900_nombre_user.rb
107
+ - pg_engine/db/migrate/20240314114503_remove_hash_ids.rb
106
108
  - pg_engine/db/seeds.rb
107
109
  - pg_engine/lib/pg_engine.rb
108
110
  - pg_engine/lib/pg_engine/configuracion.rb