This commit is contained in:
seb
2026-10-17 17:11:11 +02:00
parent 20d83b00fc
commit 01d17ebb25
11 changed files with 450 additions and 372 deletions

View File

@@ -242,6 +242,8 @@ export function sortArticlesByRelevance(articles, query) {
export function searchArticlesIndex(query, options = {}) {
const {
excludeSkus = [],
includeSkus = null,
extraArticles = [],
allowParent = false,
categories = [],
offset = 0,
@@ -253,7 +255,15 @@ export function searchArticlesIndex(query, options = {}) {
void articleIndexAutomat.actions.ensureLoaded().catch(() => {});
}
const articles = articleIndexAutomat.state.items ?? [];
let articles = articleIndexAutomat.state.items ?? [];
if (Array.isArray(extraArticles) && extraArticles.length > 0) {
const existingSkus = new Set(articles.map((a) => String(a.sku || '').toLowerCase()));
const missing = extraArticles.filter((a) => a.sku && !existingSkus.has(String(a.sku).toLowerCase()));
if (missing.length > 0) {
articles = [...articles, ...missing];
}
}
const q = String(query ?? '').trim();
const rawMatches = q ? queryFlexSearch(q, articles) : articles;
@@ -266,6 +276,10 @@ export function searchArticlesIndex(query, options = {}) {
if (excludedSet.size > 0) {
pool = pool.filter((a) => a.sku && !excludedSet.has(String(a.sku).toLowerCase()));
}
if (includeSkus != null) {
const includedSet = new Set((includeSkus ?? []).map((s) => String(s).toLowerCase()));
pool = pool.filter((a) => a.sku && includedSet.has(String(a.sku).toLowerCase()));
}
let matchesList = pool;

View File

@@ -441,7 +441,7 @@ export function createDeliveryEditorAutomat(options = {}) {
});
try {
const res = await supplierApi.getArticles(entityId, skus);
const res = await supplierApi.getArticles(entityId);
const articles = Array.isArray(res?.articles) ? res.articles : [];
const map = buildSupplierArticlesMap(articles);