I have a question about using `bin/rails generate ...
# avo-2
w
I have a question about using
bin/rails generate avo:eject
. I read the code and the rake task accepts a symbol for a specific list of templates, or a string for pretty much any template. I ejected a specific template, but when I make changes to that template I don't see them on my local rails app. Is there another step I need to take to get my ejected template to take precedence?
l
no. it should just work
w
hmm, ok. Thanks for the confirmation -- I'm sure it is something else I'm doing.
this specific case is for the table on the map view -- I want to constrain its overflow so that it better matches the height of the map element when they are rendered side by side.
Hmm, maybe I need to do something different since this template is handled by view_component instead of being passed directly to the
render
call
l
so, it's actually a view component, not a partial?
w
correct
l
I think you should have both the
.rb
and
.erb
files duplicated on your end
w
yes, I found a long and very informative discussion on this in an issue on view_component: https://github.com/ViewComponent/view_component/issues/411
l
did it work?
I'd love it if VC had a
def partail_path
method which we could take over or use to extend in Avo
w
I got pulled away, but I will look in view_component and see if there's anything like that
I came up with a way to do it without modifying avo. It's not beautiful, but it does work and maybe it can lead to a cleaner solution. Here's what I did to make it work: 1. Subclass Avo::Index::ResourceMapComponent by creating my own component class and template, Avo::Index::ConstrainedResourceMapComponent. The view template includes a
max-h-[500px]
class on the div that encloses the ResourceTableComponent, which matches the default height for the map that's set by mapkick. 2. Subclass Avo::Views::ResourceIndexComponent by creating my own component class and template, Avo::Views::ConfigurableResourceIndexComponent. On line 52, I call
<%= render(map_component_class_name.constantize.new(...
to allow me to sub in my own ConstrainedResourceMapClass. In the ConfigurableResourceIndexComponent class I define the following method:
Copy code
def map_component_class_name
  if @resource.respond_to?(:map_component_class_name)
    @resource.map_component_class_name
  else
    DEFAULT_MAP_COMPONENT_CLASS_NAME
end
3. In my resource class, I add the following method:
Copy code
def map_component_class
  'Avo::index::ConstrainedResourceMapComponent'
end
With these changes I'm able to constrain the height of the table div to match the height of the map div, and it fixes the overlapping scrollable element problem.
l
Yes. It’s doable, but not pretty
It would be nice to be able to “steal the alias” as you can in JS.
Like say “when the app asks for X component, respond with my own instead of the default one”
4 Views