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.4.27 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.4 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.26 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.3 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.25 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.2 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.24 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.1 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.23 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.22 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.0 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.21 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.5.0.beta.1 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.20 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.19 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.18 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.17 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.16 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.15 app/helpers/workarea/admin/product_rules_helper.rb
workarea-admin-3.4.14 app/helpers/workarea/admin/product_rules_helper.rb