avo 2.21.1.pre.issue1444 → 2.21.1.pre.issue1450

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24cf9486da47ba10e6a5daa1580d555a14c87f9c642a5a8d56d69a9f47784f4e
4
- data.tar.gz: e85a3b0a6bc76ba138b523601a64a74539559d919a4c984dc18a7361304527e1
3
+ metadata.gz: ebf134b0ec573fefe33360ace54658cdaafcf1904a0d88f63e89398f12e34377
4
+ data.tar.gz: 4c1ccd709c542910c2590e4b508a549463d0777b33e3baff83a63e4c97a834f9
5
5
  SHA512:
6
- metadata.gz: 34db8a5f063bef99fd6a4cdb5cc72df589e1f0329286ec7f22653de5c96a47788a7c9ad82a7197b11acb90355f9c8f5fd4ba594bf29dace1613d74d31a520917
7
- data.tar.gz: 05b2170b8af382365f157c31335b1f913f44a7d5117fe22a1cf6130200362b788812315604e7836570e384a1f2708d58625503aad2fcbbad3a738cb2163ba0f1
6
+ metadata.gz: e8bb307e086e09eb90b5cbfcddaee9f0f7fd4437ee742a98a0eaeea24171c68828dfa664a0076c332ce9df0955fb931bd3fe34c41941b4988ebe850d2e7cc682
7
+ data.tar.gz: e8169c3475feda95dcf85a9532c26b7157fe598e9544a033684fa343bb15aac0c68f5da776c7120a61d52dc2816ea84b7ac059444f4520e549aeaa09e694f017
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.21.1.pre.issue1444)
4
+ avo (2.21.1.pre.issue1450)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -172,11 +172,11 @@ module Avo
172
172
  end
173
173
 
174
174
  def hydrate_resource
175
- @resource.hydrate(view: action_name.to_sym, user: _current_user, model: @model)
175
+ @resource.hydrate(view: action_name.to_sym, user: _current_user)
176
176
  end
177
177
 
178
178
  def hydrate_related_resource
179
- @related_resource.hydrate(view: action_name.to_sym, user: _current_user, model: @related_model)
179
+ @related_resource.hydrate(view: action_name.to_sym, user: _current_user, model: @model)
180
180
  end
181
181
 
182
182
  def authorize_base_action
@@ -3,13 +3,12 @@ require_dependency "avo/base_controller"
3
3
  module Avo
4
4
  class AssociationsController < BaseController
5
5
  before_action :set_model, only: [:show, :index, :new, :create, :destroy, :order]
6
- before_action :hydrate_resource, only: [:show, :index, :new, :create, :destroy, :order]
7
6
  before_action :set_related_resource_name
8
7
  before_action :set_related_resource, only: [:show, :index, :new, :create, :destroy, :order]
9
8
  before_action :set_related_authorization
10
9
  before_action :set_reflection_field
11
- before_action :set_related_model, only: [:show, :order]
12
10
  before_action :hydrate_related_resource, only: [:show, :index, :create, :destroy, :order]
11
+ before_action :set_related_model, only: [:show, :order]
13
12
  before_action :set_reflection
14
13
  before_action :set_attachment_class, only: [:show, :index, :new, :create, :destroy, :order]
15
14
  before_action :set_attachment_resource, only: [:show, :index, :new, :create, :destroy, :order]
@@ -315,7 +315,7 @@ module Avo
315
315
  filter[:class].new arguments: filter[:arguments]
316
316
  end
317
317
  .select do |filter|
318
- filter.visible_in_view(resource: @resource, parent_resource: @parent_resource)
318
+ filter.visible_in_view(resource: @resource, parent_model: @parent_model, parent_resource: @parent_resource)
319
319
  end
320
320
  end
321
321
 
@@ -326,7 +326,7 @@ module Avo
326
326
  action[:class].new(model: @model, resource: @resource, view: @view, arguments: action[:arguments])
327
327
  end
328
328
  .select do |action|
329
- action.visible_in_view(parent_resource: @parent_resource)
329
+ action.visible_in_view(parent_model: @parent_model, parent_resource: @parent_resource)
330
330
  end
331
331
  end
332
332
 
@@ -116,7 +116,7 @@ module Avo
116
116
  self
117
117
  end
118
118
 
119
- def visible_in_view(parent_resource: nil)
119
+ def visible_in_view(parent_model: nil, parent_resource: nil)
120
120
  if visible.blank?
121
121
  # Hide on the :new view by default
122
122
  return false if view == :new
@@ -128,7 +128,9 @@ module Avo
128
128
  # Run the visible block if available
129
129
  Avo::Hosts::VisibilityHost.new(
130
130
  block: visible,
131
+ model: self.class.model,
131
132
  params: params,
133
+ parent_model: parent_model,
132
134
  parent_resource: parent_resource,
133
135
  resource: self.class.resource,
134
136
  view: self.class.view,
@@ -58,7 +58,7 @@ module Avo
58
58
 
59
59
  # Cache options as options given on block or as options received from arguments
60
60
  def options
61
- @options ||= if options_from_args.respond_to? :call
61
+ if options_from_args.respond_to? :call
62
62
  options_from_args.call model: model, resource: resource, view: view, field: self
63
63
  else
64
64
  options_from_args
@@ -60,13 +60,14 @@ module Avo
60
60
  self.class.decode_filters params[PARAM_KEY]
61
61
  end
62
62
 
63
- def visible_in_view(resource: nil, parent_resource: nil)
63
+ def visible_in_view(resource: nil, parent_model: nil, parent_resource: nil)
64
64
  return true if visible.blank?
65
65
 
66
66
  # Run the visible block if available
67
67
  Avo::Hosts::VisibilityHost.new(
68
68
  block: visible,
69
69
  params: params,
70
+ parent_model: parent_model,
70
71
  parent_resource: parent_resource,
71
72
  resource: resource,
72
73
  arguments: arguments
@@ -1,6 +1,7 @@
1
1
  module Avo
2
2
  module Hosts
3
3
  class VisibilityHost < BaseHost
4
+ option :parent_model
4
5
  option :parent_resource
5
6
  option :resource
6
7
  option :arguments
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.21.1.pre.issue1444" unless const_defined?(:VERSION)
2
+ VERSION = "2.21.1.pre.issue1450" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.1.pre.issue1444
4
+ version: 2.21.1.pre.issue1450
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-26 00:00:00.000000000 Z
12
+ date: 2022-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord