Skip to content

Commit b5f6f59

Browse files
committed
Apply literal to app/components/avo/index/grid_item_component.rb
1 parent 550fadb commit b5f6f59

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

app/components/avo/index/grid_item_component.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ class Avo::Index::GridItemComponent < Avo::BaseComponent
44
include Avo::ResourcesHelper
55
include Avo::Fields::Concerns::HasHTMLAttributes
66

7-
attr_reader :parent_resource, :actions
8-
9-
def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, actions: nil)
10-
@resource = resource
11-
@reflection = reflection
12-
@parent_record = parent_record
13-
@parent_resource = parent_resource
14-
@actions = actions
15-
@card = Avo::ExecutionContext.new(target: resource.grid_view[:card], resource: resource, record: resource.record).handle
16-
@whole_html = Avo::ExecutionContext.new(target: resource.grid_view[:html], resource: resource, record: resource.record).handle
7+
prop :resource, _Nilable(Avo::BaseResource)
8+
prop :reflection, _Nilable(ActiveRecord::Reflection::AssociationReflection)
9+
prop :parent_record, _Nilable(ActiveRecord::Base)
10+
prop :parent_resource, _Nilable(Avo::BaseResource), reader: :public
11+
prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public
12+
13+
def after_initialize
14+
@card = Avo::ExecutionContext.new(target: @resource.grid_view[:card], resource: @resource, record: @resource.record).handle
15+
@whole_html = Avo::ExecutionContext.new(target: @resource.grid_view[:html], resource: @resource, record: @resource.record).handle
1716
end
1817

1918
private

app/components/avo/index/resource_controls_component.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
44
include Avo::ApplicationHelper
55

6-
def initialize(resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, view_type: :table, actions: nil)
7-
@resource = resource
8-
@reflection = reflection
9-
@parent_record = parent_record
10-
@parent_resource = parent_resource
11-
@view_type = view_type
12-
@actions = actions
13-
end
6+
prop :resource, _Nilable(Avo::BaseResource)
7+
prop :reflection, _Nilable(ActiveRecord::Reflection::AssociationReflection)
8+
prop :parent_record, _Nilable(ActiveRecord::Base)
9+
prop :parent_resource, _Nilable(Avo::BaseResource), reader: :public
10+
prop :view_type, Symbol, default: :table, reader: :public
11+
prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public
1412

1513
def can_detach?
1614
is_has_many_association? ? super : false

0 commit comments

Comments
 (0)