Допустим, у меня есть 3 Таксона (Строители, Государства, Услуги).Есть ли способ отфильтровать «Редактировать таксоны продуктов», чтобы при щелчке по списку отображался только таксон «Услуги» в раскрывающемся списке?Представление spree - edit_product.html.erb
Спасибо
taxons.js
//= require solidus_admin/Sortable
Spree.ready(function() {
var productTemplate = HandlebarsTemplates['products/sortable'];
var productListTemplate = function(products) {
return _.map(products, productTemplate).join('') || "<h4>" + Spree.translations.no_results + "</h4>";
};
var saveSort = function(e) {
var item = e.item;
Spree.ajax({
url: Spree.routes.classifications_api,
method: 'PUT',
data: {
product_id: item.getAttribute('data-product-id'),
taxon_id: $('#taxon_id').val(),
position: e.newIndex
}
});
};
var formatTaxon = function(taxon) {
return Select2.util.escapeMarkup(taxon.pretty_name);
};
$('#taxon_id').select2({
dropdownCssClass: "taxon_select_box",
placeholder: Spree.translations.find_a_taxon,
ajax: {
url: Spree.routes.taxons_search,
params: {
"headers": {
"X-Spree-Token": Spree.api_key
}
},
data: function(term, page) {
return {
per_page: 50,
page: page,
q: {
name_cont: term
}
};
},
results: function(data) {
return {
results: data['taxons'],
more: data.current_page < data.pages
};
}
},
formatResult: formatTaxon,
formatSelection: formatTaxon
});
$('#taxon_id').on("change", function(e) {
Spree.ajax({
url: Spree.routes.taxon_products_api,
data: {
id: e.val,
simple: 1
},
success: function(data) {
$('#taxon_products').html(productListTemplate(data.products));
var el = document.querySelector('#taxon_products')
new Sortable(el, {
draggable: ".sort_item",
onEnd: saveSort
});
}
});
});
});
Приведенный выше JS относится к платформам электронной коммерции Spree или Solidus.
Хотелось бы иметь возможность фильтровать таксоны по названию "Службы".
Чтобы уточнить: Допустим, у меня есть таксономии "Строители, состояния и службы".В Admin Edit Product все таксоны для строителей, состояний и сервисов перечислены в раскрывающемся списке.
Я бы хотел иметь возможность отфильтровать, какие таксономии перечислены.В этом случае я бы хотел, чтобы в раскрывающемся списке были перечислены только таксоны " Services ".
**Would like to see this:**
Services -> Senior Care
Services -> Nurse
**Do not want this:**
Builders -> Wall
Builders-> Mason
Services -> Senior Care
Services -> Nurse
States -> Utah
States -> Texas