Sha256: b2154117e637c59d60fe7248b0203c8c717d0894e643150df8c0554f97b0ea15
Contents?: true
Size: 1.3 KB
Versions: 42
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module SirTrevorRails module Blocks ## # Multi-up browse block class BrowseBlock < SirTrevorRails::Block include Displayable attr_reader :solr_helper def with_solr_helper(solr_helper) @solr_helper = solr_helper end def search_options(id) (items.detect { |x| x[:id] == id }) || {} end def searches @searches ||= parent.exhibit.searches.published.where(slug: item_ids).sort do |a, b| ordered_items.index(a.slug) <=> ordered_items.index(b.slug) end end def searches? !searches.empty? end def display_item_counts? send(:'display-item-counts') == 'true' end def as_json(*) result = super result[:data][:item] ||= {} # TODO: This is a temporary fix that simply removes any item if the search identifier does not exist # We should have a more permanent solution that will allow browse blocks to be updated without erroring result[:data][:item].select! { |_, v| parent.exhibit.searches.exists?(v['id']) } result[:data][:item].each_value do |v| v['thumbnail_image_url'] = parent.exhibit.searches.find(v['id']).thumbnail_image_url end result end end end end
Version data entries
42 entries across 42 versions & 1 rubygems