Skip to content

Commit

Permalink
fix: assets outputted multiple times (#3027)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Bob <[email protected]>
  • Loading branch information
adrianthedev and Paul-Bob authored Jul 19, 2024
1 parent 0d08ec7 commit 6109d2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/components/avo/turbo_frame_wrapper_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# We're appending it back if it's a turbo_frame_request.
%>
<% if helpers.turbo_frame_request? %>
<%= helpers.turbo_stream_action_tag :append, target: 'alerts', template: render(Avo::FlashAlertsComponent.new(flashes: helpers.flash)) %>
<%= helpers.turbo_stream_action_tag :append, target: "alerts", template: render(Avo::FlashAlertsComponent.new(flashes: helpers.flash)) %>
<% end %>
<%= content %>
<% if name.present? %></turbo-frame><% end %>
11 changes: 8 additions & 3 deletions lib/avo/asset_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ module Avo
class AssetManager
include ActionView::Helpers::AssetTagHelper

attr_reader :stylesheets
attr_reader :javascripts

def initialize
@stylesheets = []
@javascripts = []
Expand All @@ -22,6 +19,14 @@ def add_stylesheet(path)
def add_javascript(path)
@javascripts.push path
end

def stylesheets
@stylesheets.uniq
end

def javascripts
@javascripts.uniq
end
end

def self.asset_manager
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/avo/eject_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def eject_component(component_to_eject = options[:component], confirmation: true
[dest_rb, dest_erb].each do |path|
if component.starts_with?("avo/views/")
modified_content = File.read(path).gsub("Avo::Views::", "Avo::Views::#{options[:scope].camelize}::")
elsif component.starts_with?("avo/fields/")
elsif component.starts_with?("avo/fields/") && options["field-components"].present?
modified_content = File.read(path).gsub("#{options["field-components"].camelize}Field", "#{options[:scope].camelize}::#{options["field-components"].camelize}Field")
end

Expand Down

0 comments on commit 6109d2e

Please sign in to comment.