Sha256: 8e86df7505f142ef6b8d7be9d35308526a7f6ae920d7d22c9082619802f58734

Contents?: true

Size: 1.43 KB

Versions: 62

Compression:

Stored size: 1.43 KB

Contents

module Workarea
  module Admin
    module ProductRulesHelper
      def product_rule_types_options
        Search::Storefront::Product.current_product_rule_fields.keys.map do |key|
          translated = t(
            "workarea.admin.fields.#{key}",
            default: key.to_s.humanize
          )

          [translated.downcase, key]
        end
      end

      def product_rule_operators
        ProductRule::OPERATORS.map { |o| [o.humanize.downcase, o] }
      end

      def category_rule_names_for(rule)
        Catalog::Category
          .any_in(id: rule.terms)
          .map(&:name)
          .join(', ')
      end

      def exclude_products_rule_names_for(rule)
        Catalog::Product
          .any_in(id: rule.terms)
          .map(&:name)
          .join(', ')
      end

      def render_product_rule_fields_for(rule)
        render "workarea/admin/product_rules/fields/#{rule.slug}", rule: rule
      rescue ActionView::MissingTemplate
        render "workarea/admin/product_rules/fields/generic", rule: rule
      end

      def render_product_rule_summary_for(rule)
        render "workarea/admin/product_rules/summaries/#{rule.slug}", rule: rule
      rescue ActionView::MissingTemplate
        render "workarea/admin/product_rules/summaries/generic", rule: rule
      end

      def product_rules_show_all_query_string(show_all: true)
        "?#{request.query_parameters.merge('show_all' => show_all).to_query}"
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.26 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.45 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.25 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.23 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.44 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.22 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.43 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.21 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.42 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.20 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.41 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.19 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.40 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.18 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.39 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.17 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.38 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.16 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.37 app/helpers/workarea/admin/product_rules_helper.rb