Sha256: a1e22136425fb48803c3353b9ef75f007d688c3be9afb165d7c836c47becfd8d

Contents?: true

Size: 829 Bytes

Versions: 26

Compression:

Stored size: 829 Bytes

Contents

//= require alchemy/solidus/admin/select2_config

$.fn.alchemyVariantSelect = function(options) {
  var config = Alchemy.Solidus.getSelect2Config(options)

  this.select2($.extend(true, config, {
    ajax: {
      data: function(term, page) {
        return {
          q: $.extend({
            product_name_or_sku_cont: term
          }, options.query_params),
          page: page
        }
      },
      results: function(data, page) {
        return {
          results: data.variants.map(function(variant) {
            return {
              id: variant.id,
              text: variant.frontend_display
            }
          }),
          more: page * data.per_page < data.total_count
        }
      }
    },
    formatSelection: function(variant) {
      return variant.text || variant.frontend_display
    }
  }))
}

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
alchemy-solidus-7.1.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-7.0.1 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-7.0.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.3.2 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.3.1 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.3.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.2.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.1.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.0.1 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-6.0.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-5.0.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-4.1.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-4.0.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-4.0.0.pre.b2 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-4.0.0.pre.b1 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-3.3.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-3.2.2 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-3.2.1 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-3.2.0 app/assets/javascripts/alchemy/solidus/admin/variant_select.js
alchemy-solidus-3.1.1 app/assets/javascripts/alchemy/solidus/admin/variant_select.js