pg_rails 7.6.21.pre.4 → 7.6.21.pre.5

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: 52db938b6aad2006d1815247f8b3f1c4bd297b811ca50db7e800760967942045
4
- data.tar.gz: 1a095d3501f50d2b3fa9b123bb62a42e5c3472a1f679b4adf5932716f51693de
3
+ metadata.gz: 2f515ba243d4ef8862ebb74652329637397334f2af37b82a3984a6cab05bf2ab
4
+ data.tar.gz: 7f01717d0f4a9e4ff9aeca5a24286134cf4045c3554986e716c5aa33c6d5a9fd
5
5
  SHA512:
6
- metadata.gz: ab9d327f91d9153cf8e2ebc1e602510db545f1f086a23fb7d1ced3f5480b234f0b231327930b3707f972a5524cff80796488d3a762df95ed5d0ad649f52dd21c
7
- data.tar.gz: 2ca7ae67777a8bac52b5f63642e52d3436fd094c166a97f2c84417bdfcd3305d9f5b5e6a286e2fbd4a655035a69049ddff6ab72ec83abbc6dc5853808ad9d8a9
6
+ metadata.gz: dd6e02da0ef6c884fa7bacf08c3cc38ee9677ba26c26e47d97eb313accdaf14ac82781a70ad54149f40c63b37b0313adf410f14e0b169866078f2d2f3fa30d09
7
+ data.tar.gz: 510037412f74089b74bd7cd632cf70fb2e25d57c0e7d4463d0667f723a4add732319f89f0f7670ccaa6c10874372ee87943c2f92d96fa789badbd04ed4d4fde0
@@ -49,6 +49,13 @@ module PgAssociable
49
49
  puede_crear = Pundit::PolicyFinder.new(klass).policy.new(user, klass).new_from_associable?
50
50
  collection = Pundit::PolicyFinder.new(klass).scope.new(user, klass).resolve
51
51
  collection = collection.kept if collection.respond_to?(:kept)
52
+
53
+ reflect = associacion_for(atributo)
54
+ fkid = object.send(reflect.foreign_key)
55
+ if fkid
56
+ collection = collection.or(klass.where(id: fkid))
57
+ end
58
+
52
59
  [collection, puede_crear]
53
60
  end
54
61
 
@@ -78,11 +85,17 @@ module PgAssociable
78
85
  association atributo, options
79
86
  end
80
87
 
81
- def clase_asociacion(atributo)
88
+ def associacion_for(atributo)
82
89
  asociacion = object.class.reflect_on_all_associations.find { |a| a.name == atributo.to_sym }
83
90
 
84
91
  raise PgEngine::Error, "no existe la asociación para el atributo: #{atributo}" if asociacion.blank?
85
92
 
93
+ asociacion
94
+ end
95
+
96
+ def clase_asociacion(atributo)
97
+ asociacion = associacion_for(atributo)
98
+
86
99
  nombre_clase = asociacion.options[:class_name]
87
100
  nombre_clase = asociacion.name.to_s.camelize if nombre_clase.nil?
88
101
  Object.const_get(nombre_clase)
@@ -1,3 +1,5 @@
1
+ / TODO!: estaría bueno que la policy pueda discriminar permisos para cada atributo
2
+ / y por ejemplo no permitir el edit de un belongs_to a un modelo sobre el cual no tiene permisos
1
3
  - if Current.namespace == :tenant && \
2
4
  @model.class.inline_editable?(@unsuffixed_attribute) && helpers.policy(@model).edit?
3
5
  = helpers.turbo_frame_tag(@frame_id, class: 'inline-edit')
@@ -219,7 +219,7 @@ module PgEngine
219
219
  Request: #{request.inspect}
220
220
  STRING
221
221
 
222
- render_my_component(BadUserInputComponent.new(error_msg: 'Acceso no autorizado'), :unauthorized)
222
+ render_my_component(BadUserInputComponent.new(error_msg: 'Operación no permitida'), :unauthorized)
223
223
  end
224
224
 
225
225
  def go_back(message = nil, type: :alert)
@@ -130,7 +130,10 @@ module PgEngine
130
130
  return false if ActsAsTenant.current_tenant.blank?
131
131
 
132
132
  full_key = "#{profile_prefix}__#{key}"
133
- Current.user_account_owner? || Current.active_user_profiles.include?(full_key)
133
+
134
+ scoped_by_tenant = record.class.respond_to?(:scoped_by_tenant) && record.class.scoped_by_tenant?
135
+ (!scoped_by_tenant || Current.account.id == record.account_id) &&
136
+ (Current.user_account_owner? || Current.active_user_profiles.include?(full_key))
134
137
  end
135
138
  end
136
139
  end
@@ -49,7 +49,9 @@ export default class extends Controller {
49
49
  notif.classList.remove('unseen')
50
50
  }
51
51
  )
52
- document.querySelector('.notifications-unseen-mark').remove()
52
+ document.querySelectorAll('.notifications-unseen-mark').forEach((e) => {
53
+ e.remove()
54
+ })
53
55
  } else {
54
56
  const text = await response.text
55
57
  Rollbar.error('Error marking as seen: ', text)
@@ -5,12 +5,13 @@
5
5
  .offcanvas-body.text-end
6
6
  - if user_signed_in?
7
7
  = render partial: 'pg_layout/signed_in_links'
8
- ul.list-unstyled.mt-4
9
- - @navbar.sidebar.each do |entry|
10
- - next if @navbar.hide_entry?(entry)
11
- li
12
- a href=entry[:path] class="pg--nav-button pe-4 text-light #{@navbar.active_entry?(entry, request) ? 'active' : ''} #{entry[:attributes]}"
13
- = entry[:title]
8
+ - if @navbar.present?
9
+ ul.list-unstyled.mt-4
10
+ - @navbar.sidebar.each do |entry|
11
+ - next if @navbar.hide_entry?(entry)
12
+ li
13
+ a href=entry[:path] class="pg--nav-button pe-4 text-light #{@navbar.active_entry?(entry, request) ? 'active' : ''} #{entry[:attributes]}"
14
+ = entry[:title]
14
15
  css:
15
16
  .offcanvas a { text-decoration: none; }
16
17
  .offcanvas li { xmargin-top: 0.75em; }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.6.21-4'
4
+ VERSION = '7.6.21-5'
5
5
  end
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.6.21.pre.4
4
+ version: 7.6.21.pre.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso