Skip to content

Commit

Permalink
Update matrix_box_helper.rb
Browse files Browse the repository at this point in the history
pass partial args through in render_cached_matrix_boxes
  • Loading branch information
nimmolo committed Jan 25, 2024
1 parent 35fb495 commit a6000d0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/helpers/matrix_box_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def matrix_table(**args, &block)
partial = args[:partial] || "shared/matrix_box"
as = args[:as] || :object
cached = args[:cached] || false
objects = args[:objects] || []
locals = args.except(:objects, :as, :partial, :cached)

[
tag.ul(
Expand All @@ -15,23 +17,23 @@ def matrix_table(**args, &block)
) do
if block
capture(&block)
elsif cached && args[:objects]
render_cached_matrix_boxes(args[:objects])
elsif cached && objects
render_cached_matrix_boxes(objects, locals)
else
render(partial: partial,
locals: args.except(:objects, :as, :partial, :cached),
collection: args[:objects], as: as, cached: cached)
render(partial: partial, locals: locals,
collection: objects, as: as)
end
end,
tag.div("", class: "clearfix")
].safe_join
end

def render_cached_matrix_boxes(objects)
def render_cached_matrix_boxes(objects, locals)
# matrix box has two versions (image vote UI, or no)
objects.each do |object|
cache([object, logged_in_status]) do
concat(render(partial: "shared/matrix_box", locals: { object: object }))
concat(render(partial: "shared/matrix_box",
locals: { object: object }.merge(locals)))
end
end
end
Expand Down

0 comments on commit a6000d0

Please sign in to comment.