Skip to content

Commit

Permalink
fix: action visibility on show controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Jul 5, 2023
1 parent 1cf596c commit e6cdc9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
24 changes: 13 additions & 11 deletions app/components/avo/views/resource_show_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@
<% end %>
<% end %>
<% elsif control.action? %>
<%= a_link control.path,
color: control.color,
style: control.style,
icon: control.icon,
title: control.title,
data: {
tippy: control.title ? :tooltip : nil,
'turbo-frame': 'actions_show',
'action': 'click->actions-picker#visitAction',
} do %>
<%= control.label %>
<% if control.action.visible_in_view(parent_resource: @parent_resource) %>
<%= a_link control.path,
color: control.color,
style: control.style,
icon: control.icon,
title: control.title,
data: {
tippy: control.title ? :tooltip : nil,
'turbo-frame': 'actions_show',
'action': 'click->actions-picker#visitAction',
} do %>
<%= control.label %>
<% end %>
<% end %>
<% elsif control.link_to? %>
<%= a_link control.path,
Expand Down
6 changes: 3 additions & 3 deletions lib/avo/resources/controls/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ module Controls
class Action < BaseControl
attr_reader :klass

def initialize(klass, model: nil, resource: nil, view: nil, **args)
def initialize(klass, record: nil, resource: nil, view: nil, **args)
super(**args)

@klass = klass
@resource = resource
@model = model
@record = record
@view = view
end

def action
@instance ||= @klass.new(model: @model, resource: @resource, view: @view)
@instance ||= @klass.new(model: @record, resource: @resource, view: @view)
end

def path
Expand Down

0 comments on commit e6cdc9f

Please sign in to comment.