Sha256: 4cc2b0e8e70de5f7ed0bb5f5befa00713c2381e921445df02570c79d17ed8e1b

Contents?: true

Size: 823 Bytes

Versions: 34

Compression:

Stored size: 823 Bytes

Contents

module Workarea
  module Admin
    class SearchCustomizationProductRulesViewModel < ProductRulesPreviewViewModel
      # Fetches search results of products for product search. Extends
      # search class with {Search::AdminProductRulesPreview} to allow
      # overriding display rules.
      #
      # @return [Workarea::Search::ProductSearch]
      #   enumerable collection of the search results
      #
      def search
        @search ||= Search::ProductSearch.new(
          q: model.query,
          rules: model.product_rules.select(&:valid?),
          page: options[:page] || 1,
          show_all: show_all?
        ).tap { |s| s.extend(Search::AdminProductRulesPreview) }
      end

      def display_results?
        true # With query we can always show preview even without rules
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-admin-3.4.25 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.24 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.23 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.22 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.21 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.20 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.19 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.18 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.17 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.16 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.15 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.14 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.13 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb
workarea-admin-3.4.12 app/view_models/workarea/admin/search_customization_product_rules_view_model.rb