u
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Single source of truth for all backend communication.
|
||||
|
||||
import { requireArray, requireObject } from '../utils/apiShape';
|
||||
|
||||
|
||||
/** WebView consoles stringify objects as [object Object]; log JSON text. */
|
||||
function logApi(tag, details) {
|
||||
@@ -190,37 +190,14 @@ async function httpGetBinary(path) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Company-scoped article search index (selectedCompanyId from session).
|
||||
* GET /api/articleIndex → { articles: [...] }
|
||||
* NOTE: there is no `articleIndex` namespace anymore.
|
||||
*
|
||||
* The whole-company search index (`GET /api/articleIndex`) was abandoned. Article
|
||||
* lists are fetched per category via `category.getArticles(categoryId)`
|
||||
* (`GET /api/category/:id/articles`); `categoryAutomat.loadTree()` warms every
|
||||
* category view right after the tree loads, and `articleIndexAutomat` derives the
|
||||
* client-side search index from those views.
|
||||
*/
|
||||
export const articleIndex = {
|
||||
list() {
|
||||
return http('/api/articleIndex');
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the company article index and maps backend rows to the recordset
|
||||
* shape consumed by the search result list.
|
||||
*
|
||||
* `categories` becomes a comma-joined string because `formatCategoryList`
|
||||
* splits on ','.
|
||||
*
|
||||
* @returns {Promise<Array<ArticleIndexRecord>>}
|
||||
*/
|
||||
async listRecords() {
|
||||
const data = await http('/api/articleIndex');
|
||||
requireObject(data, 'GET /api/articleIndex');
|
||||
const articles = requireArray(data.articles, 'articleIndex.articles');
|
||||
return articles.map((a) => ({
|
||||
id: a.id,
|
||||
sku: a.sku,
|
||||
name: a.name,
|
||||
eans: a.eans ?? [],
|
||||
categories: Array.isArray(a.categoryIds) ? a.categoryIds.join(',') : null,
|
||||
isParent: Boolean(a.isParent ?? a.is_parent),
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
export const article = {
|
||||
search({ target, filter, offset, maxCount } = {}) {
|
||||
@@ -1970,7 +1947,6 @@ export const modelconversation = {
|
||||
export default {
|
||||
auth,
|
||||
article,
|
||||
articleIndex,
|
||||
attributename,
|
||||
attributevalue,
|
||||
brand,
|
||||
|
||||
Reference in New Issue
Block a user