app/assets/javascripts/spree/backend/taxon_autocomplete.js in spree_backend-4.3.3 vs app/assets/javascripts/spree/backend/taxon_autocomplete.js in spree_backend-4.4.0.rc1

- old
+ new

@@ -1,43 +1,44 @@ $.fn.taxonAutocomplete = function() { 'use strict' function formatTaxonList(values) { - console.warn('taxonAutocomplete is deprecated and will be removed in Spree 5.0') - return values.map(function (obj) { return { id: obj.id, - text: obj.pretty_name + text: obj.attributes.pretty_name } }) } this.select2({ multiple: true, placeholder: Spree.translations.taxon_placeholder, minimumInputLength: 2, ajax: { - url: Spree.routes.taxons_api, + url: Spree.routes.taxons_api_v2, dataType: 'json', data: function (params) { return { - q: { + filter: { name_cont: params.term }, - token: Spree.api_key + fields: { + taxon: 'pretty_name' + } } }, + headers: Spree.apiV2Authentication(), processResults: function(data) { return { - results: formatTaxonList(data.taxons) + results: formatTaxonList(data.data) } } } }) } -$(document).ready(function () { +document.addEventListener("spree:load", function() { var productTaxonSelector = document.getElementById('product_taxon_ids') if (productTaxonSelector == null) return if (productTaxonSelector.hasAttribute('data-autocomplete-url-value')) return $('#product_taxon_ids').taxonAutocomplete()